diff options
author | Jim Meyering <meyering@redhat.com> | 2012-09-16 22:31:04 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-10-04 22:06:40 +0200 |
commit | 759ebcb57db73449b5670204f85931d34881b7d2 (patch) | |
tree | 0c72d5266451db1dca993ed5034d8b323a73cf1b /tests/factor | |
parent | 49f5c21fff9241c195d74101a334fdc2c8dc33e8 (diff) | |
download | coreutils-759ebcb57db73449b5670204f85931d34881b7d2.tar.xz |
factor: merge with preexisting factor; integrate tests; avoid warnings
* src/factor.c: Renamed from factor-ng.c, with the following changes:
Adjust copyright header to be consistent with others.
Use xmalloc and xrealloc, to avoid segv upon OOM.
Switch back to using readtokens to handle input.
Diagnose invalid inputs.
s/fprintf+exit/error/
(print_factors): Add comments.
(strto2uintmax): Return strtol_error, not int.
(read_item): Remove, no longer used.
(main): Use atexit(close_stdout) so that we don't ignore failed write.
* cfg.mk: Exempt src/longlong.h from several tests.
Exempt run.sh from the test-list-consistency test.
Exempt make-prime-list.c from numerous tests, since we won't
be making it conform: it must not link with libcoreutils.a.
Exempt factor-ng.c from the no-upper-case error message test.
* AUTHORS (factor): Add Torbjörn and Niels.
* tests/local.mk (factor_tests): Encode the 37 tests.
($(factor_tests)): Rule to generate a test script for each test.
* tests/factor/run.sh: New script, marked as very expensive.
* .gitignore: Ignore new generated files.
* src/local.mk (src/primes.h): New rule.
(noinst_PROGRAMS): Add make-prime-list.
(noinst_HEADERS): Add longlong.h.
Remove all wheel-related rules and files.
* src/wheel-gen.pl: Remove file.
maint: mark set-but-not-used variables with ATTRIBUTE_UNUSED
* src/factor-ng.c (redcify, prime_p, isqrt2): Mark them, so we
don't have to disable -Wunused-but-set-variable.
maint: use __builtin_expect only if __GNUC__
* src/factor-ng.c (LIKELY, UNLIKELY) [__GNUC__]: Add #ifdef guard.
build: avoid warning about unused macro
* src/factor-ng.c (__GMP_DECLSPEC): Don't define here
* src/longlong.h (__GMP_DECLSPEC): Define if not already defined.
Diffstat (limited to 'tests/factor')
-rwxr-xr-x | tests/factor/run.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/factor/run.sh b/tests/factor/run.sh new file mode 100755 index 000000000..6ff24c370 --- /dev/null +++ b/tests/factor/run.sh @@ -0,0 +1,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 |