summaryrefslogtreecommitdiff
path: root/tests/factor/run.sh
blob: 6ff24c370b85bc8c0ba6d7ecd745187b84734928 (plain)
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
#!/bin/sh
# Test the factor rewrite.
# Expect to be invoked via a file whose basename matches
# /^(\d+)\-(\d+)\-([\da-f]{40})\.sh$/
# The test is to run this command
# seq $1 $2 | factor | shasum -c --status <(echo $3  -)
# I.e., to ensure that the factorizations of integers $1..$2
# match what we expect.

# Copyright (C) 2012 Free Software Foundation, Inc.

. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src

# Don't run these tests by default.
very_expensive_

print_ver_ factor seq

# Remove the ".sh" suffix:
t=${ME_%.sh}

# Make IFS include "-", so that a simple "set" will separate the args:
IFS=-$IFS
set $t
echo "$3  -" > exp

f=1
seq $1 $2 | factor | shasum -c --status exp && f=0

Exit $f