File: testlong.pm1

package info (click to toggle)
gmp-ecm 7.0.4+ds-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,728 kB
  • sloc: asm: 36,431; ansic: 34,057; xml: 885; python: 799; sh: 698; makefile: 348
file content (49 lines) | stat: -rwxr-xr-x 1,722 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# test file for P-1 method
#
# Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012, 2016
# Paul Zimmermann, Alexander Kruppa, Dave Newman, Jim Fougeron, David Cleaver
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, see
# http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

PM1="${1:-./ecm} -pm1"

# Call with "checkcode $? n" to check that return code is n
# the return code is (see ecm-ecm.h):
# 0: no factor found
# 1: error (for example out of memory)
# 2: composite factor found with composite cofactor
# 6: prime factor found with composite cofactor
# 8: input number found
# 10: composite factor found with prime cofactor
# 14: prime factor found with prime cofactor

checkcode () {
  if [ $1 != $2 ]
  then
    echo "############### ERROR ###############"
    echo "Expected return code $2 but got $1"
    exit 1
  fi
}

# exercise gathering primes between cascade_limit < p < B0
echo 123 | $PM1 4.42e8; checkcode $? 8

# exercise factor of F_15
echo "2^(2^15)+1" | $PM1 -go 2097152 3 193; checkcode $? 6

echo "All ECM tests are ok."