summaryrefslogtreecommitdiffstats
path: root/tests/factor
AgeCommit message (Collapse)AuthorLines
2026-02-25tests: factor,numfmt: verify embedded NUL handlingPádraig Brady-2/+23
* tests/factor/factor.pl: Verify that embedded NULs on stdin terminate the _number_. * tests/numfmt/numfmt.p: Verify that embedded NULs on stdin terminate the _line_. https://github.com/coreutils/coreutils/pull/196
2026-01-01maint: run 'make update-copyright'Collin Funk-4/+4
2025-10-02tests: factor: add suggested large prime testsPádraig Brady-2/+9
* tests/factor/create-test.sh: Add 2 new large primes from: https://github.com/coreutils/coreutils/issues/65 * tests/local.mk: Reference the 2 new generated tests.
2025-07-09factor: don’t prove primalityPaul Eggert-0/+5
Suggested for consideration by Torbjörn Granlund in: https://lists.gnu.org/r/coreutils/2025-01/msg00000.html * src/factor.c (PROVE_PRIMALITY): Now defaults to false. (mp_prime_p): Help the compiler by telling it mpz_prob_prime_p returns nonnegative. * tests/factor/create-test.sh (bigprime): Test 2^400 - 593, since that’s now practical. * tests/local.mk (factor_tests): Add new test.
2025-07-09factor: switch from mp to single when doablePaul Eggert-0/+3
This significantly improves performance when a number exceeds 2**(W_TYPE_SIZE - 1) and is the product of a prime less than FIRST_OMITTED_PRIME and another prime less than 2**(W_TYPE_SIZE - 1). On my platform, for example, it doubled the speed of factoring 4999 * (2**128 - 159). * src/factor.c (mp_size, mp_finish_in_single): New functions. (mp_factor_using_division, mp_factor_using_pollard_rho): Finish using single precision when possible. * tests/factor/factor.pl (lt-5000-times-128-bit): New test.
2025-07-09factor: fix test case namePaul Eggert-1/+1
* tests/factor/factor.pl (bug-gmp-plus_2_sup_127_plus_1): Rename from bug-gmp-plus_2_sup_128_plus_1, so that it accurately reflects the test case.
2025-05-17factor: fix bug with 128-bit uintmax_tPaul Eggert-0/+3
On so-far-only-theoretical platforms with 128-bit uintmax_t, 'factor' would misbehave by not factoring enough. Work around the bug (at a performance cost) and document the issue. I hope someone with more time and expertise can fix the performance cost that this introduces. To reproduce the correctness bug, build with 'gcc -DUSE_INT128 -DEXHIBIT_INT128_BUG'; 'make check' should fail due to the new test case. * src/factor.c (USE_INT128): New macro. (wide_uint, wide_int, W_TYPE_SIZE, WIDE_UINT_MAX): Define to proper values if USE_INT128. (prime_p) [!EXHIBIT_INT128_BUG]: Work around bug with 128-bit wide_uint, at some performance cost. * tests/factor/factor.pl (bug-with-128-bit-uintmax_t): New test.
2025-01-20maint: tests: remove duplicate uses of 'my' in PerlCollin Funk-1/+1
* tests/env/env-S.pl (cf): Remove uses of 'my' after the variable has been declared. * tests/factor/factor.pl (t): Likewise. * tests/misc/fold.pl (prog): Remove duplicate assignment.
2025-01-01maint: update all copyright year number rangesPádraig Brady-4/+4
Update to latest gnulib with new copyright year. Run "make update-copyright" and then... * gnulib: Update included in this commit as copyright years are the only change from the previous gnulib commit. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2024-09-27factor: port to platformsPaul Eggert-0/+4
* src/factor.c (mod2): Work even if cntd <= cnta. The old version of the code assumed that shifts by N had unspecified behavior unless 0 <= N < wordsize. Although this assumption is portable to all known practical platforms, the C standard says these shifts have undefined behavior and some pedantic platforms check this. * tests/factor/create-test.sh: * tests/local.mk (factor_tests): New test t37.
2024-01-01maint: update all copyright year number rangesPádraig Brady-4/+4
Update to latest gnulib with new copyright year. Run "make update-copyright" and then... * gnulib: Update included in this commit as copyright years are the only change from the previous gnulib commit. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Manually update copyright year, until we fully sync with gnulib at a later stage. * tests/sample-test: Adjust to use the single most recent year.
2023-06-19tests: move tests to a directory per utilitySylvestre Ledru-0/+159
* cfg.mk: Adjust syntax check exclusion paths. * tests/local.mk: Adjust for renamed tests.
2023-01-01maint: update all copyright year number rangesPádraig Brady-2/+2
Update to latest gnulib with new copyright year. Run "make update-copyright" and then... * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Manually update copyright year, until we fully sync with gnulib at a later stage. * tests/sample-test: Adjust to use the single most recent year.
2022-01-02maint: update all copyright year number rangesPádraig Brady-2/+2
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2021-01-01maint: update all copyright year number rangesPádraig Brady-2/+2
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2020-01-01maint: update all copyright year number rangesPádraig Brady-2/+2
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2019-01-01maint: update all copyright year number rangesAssaf Gordon-2/+2
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2018-01-01maint: update all copyright year number rangesPádraig Brady-2/+2
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2017-01-01maint: update all copyright year number rangesPádraig Brady-2/+2
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2016-01-01maint: update all copyright year number rangesPádraig Brady-2/+2
Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
2015-10-19tests: avoid failure when auto selecting factor testsPádraig Brady-0/+2
* tests/factor/run.sh: If this template is found through `grep -El "print_ver_.* factor"` for example, then just skip it.
2015-01-01maint: update all copyright year number rangesPádraig Brady-2/+2
Run "make update-copyright" and then... * tests/sample-test: Adjust to use the single most recent year. * tests/du/bind-mount-dir-cycle-v2.sh: Fix case in copyright message, so that year is updated automatically in future.
2014-01-02maint: update all copyright year number rangesBernhard Voelker-2/+2
Run "make update-copyright", but then also run this, perl -pi -e 's/2\d\d\d-//' tests/sample-test to make that one script use the single most recent year number.
2013-07-22maint: make some shell and perl scripts executable in 'tests/'Bernhard Voelker-0/+0
Some newer test scripts - partially ones from me - are not executable. It does not seem to be a problem, but for consistency and to avoid future problems on unusual platforms or shells change the permissions by adding the executable bit. * cfg.mk (sc_tests_executable): Add new syntax-check rule to ensure that all test scripts are executable. * tests/df/df-output.sh: Change file mode from 644 to 755. * tests/du/threshold.sh: Likewise. * tests/factor/run.sh: Likewise. * tests/init.sh: Likewise. * tests/misc/csplit-suppress-matched.pl: Likewise. * tests/misc/numfmt.pl: Likewise. * tests/tail-2/retry.sh: Likewise.
2013-01-01maint: update all copyright year number rangesJim Meyering-2/+2
Run "make update-copyright", but then also run this, perl -pi -e 's/2\d\d\d-//' tests/sample-test to make that one script use the single most recent year number.
2012-11-09tests: fix factor's tests to use coreutil's own sha1sumBernhard Voelker-2/+2
The test used the shasum utility which seems to belong to the perl package. On SLES-10.4, perl doesn't include this yet: + seq 0 10000000 + factor + shasum -c --status exp ./tests/factor/t00.sh: line 30: shasum: command not found + Exit 1 It is better to use our own stuff anyway. * tests/factor/run.sh: s/shasum/sha1sum/. Additionally, add sha1sum to the print_ver_ call.
2012-10-27tests: shorten factor's inordinately-long test file namesBernhard Voelker-10/+95
Besides what the subject says, this commit moves the test data for the factor tests from tests/local.mk into the directory tests/factor/ where it belongs. * tests/local.mk (EXTRA_DIST): Add new tests/factor/create-test.sh. (p,q,t1,t2) Factor out the factor-related magic numbers. (factor_tests): Rename the test names to t{00..36}.sh. Factor out the triples of test data. ($(factor_tests)): Add dependency to new tests/factor/create-factor.sh. Call that script to generate the test scripts. * tests/factor/run.sh: Turn this script into a template, and therefore remove it's executable permission bit. Add template variables START, END and CKSUM, replacing the code to split the test data from the test script's file name. Use the new template variables in the call to seq and for creating the exp file. * tests/factor/create-test.sh: Add new script to create the test scripts from the template tests/factor/run.sh. Use test data and magic numbers factored out from the above files. Let the script also change the __TEMPLATE__ line in run.sh to make clear that the test scripts are generated. * cfg.mk (sc_tests_list_consistency): Exempt the new test. (exclude_file_name_regexp--sc_prohibit_test_backticks): Likewise. Improved-by: Stefano Lattarini Improved by: Jim Meyering
2012-10-04factor: merge with preexisting factor; integrate tests; avoid warningsJim Meyering-0/+30
* 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.
2007-09-15Move the sole test in tests/factor to tests/misc/factor.Jim Meyering-122/+0
* tests/factor/basic: Move this file to ... * tests/misc/factor: ...here. Don't rely on $PROG in env. * tests/misc/Makefile.am (TESTS): Add factor. * tests/Makefile.am (SUBDIRS): Remove factor. * tests/factor: Remove the directory. * configure.ac (AC_CONFIG_FILES): Remove tests/factor/Makefile
2007-08-25Remove all .cvsignore files from version control.Jim Meyering-2/+0
2007-08-18Run each Coreutils.pm-based test in its own subdirectory.Jim Meyering-3/+3
* tests/CuTmpdir.pm: New file. * tests/Makefile.am (EXTRA_DIST): Add CuTmpdir.pm. * tests/misc/od, tests/misc/base64, tests/misc/basename: * tests/misc/cut, tests/misc/date, tests/misc/dirname: * tests/misc/expand, tests/misc/fold, tests/misc/head-elide-tail: * tests/misc/paste-no-nl, tests/misc/pr, tests/misc/sha224sum: * tests/misc/sha256sum, tests/misc/sha384sum, tests/misc/sha512sum: * tests/misc/sort-merge, tests/misc/stat-printf, tests/misc/test-diag: * tests/misc/wc-files0-from, tests/misc/xstrtol: * tests/dd/skip-seek, tests/dircolors/simple, tests/du/files0-from: * tests/expr/basic, tests/factor/basic, tests/fmt/basic: * tests/ls-2/tests, tests/md5sum/basic-1, tests/md5sum/newline-1: * tests/seq/basic, tests/sha1sum/basic-1, tests/sha1sum/sample-vec: * tests/sum/basic-1, tests/tsort/basic-1, tests/unexpand/basic-1: * tests/mv/i-1, tests/rm/empty-name, tests/rm/unreadable: Use it. * tests/misc/test-diag: Use "$ENV{abs_top_builddir}/src/test", not "../../src/test", so it works when run from a subdirectory. * tests/ls-2/tests: Create temp files and dirs from within the perl script, so that they're removed, when run from a subdirectory.
2007-07-23Update all copyright notices to use the newer form.Jim Meyering-5/+3
2007-07-10Change "version 2" to "version 3" in all copyright notices.Jim Meyering-1/+1
2007-02-24Remove the "gnits" option; it prohibits my using "+" as a versionJim Meyering-2/+0
string suffix, and all it does (beyond the default "gnu" option) is to _require_ the THANKS file. * configure.ac (AM_INIT_AUTOMAKE): Remove it. Remove all AUTOMAKE_OPTIONS settings in Makefile.am files. * tests/chgrp/Makefile.am, tests/chmod/Makefile.am: * tests/chown/Makefile.am, tests/cp/Makefile.am: * tests/du/Makefile.am, tests/expr/Makefile.am: * tests/factor/Makefile.am, tests/general/Makefile.am: * tests/install/Makefile.am, tests/ln/Makefile.am: * tests/ls/Makefile.am, tests/mkdir/Makefile.am: * tests/mv/Makefile.am, tests/readlink/Makefile.am: * tests/rm/Makefile.am, tests/rmdir/Makefile.am: * tests/seq/Makefile.am, tests/stty/Makefile.am: * tests/tee/Makefile.am, tests/touch/Makefile.am:
2007-01-13Put CU_TEST_NAME in the environment for each test run by "make check".Jim Meyering-0/+1
* Transform all Makefile.am files so that when running "make check", CU_TEST_NAME is set to the name of the test. This is so that when I run valgrind-enabled (--log-file-qualifier=CU_TEST_NAME) "make check" on the entire package it is more convenient to map a leak or error found in a valgrind log file back to the offending test. Use this command: (echo tests/Makefile.am.in; find tests -name Makefile.am) \ |xargs perl -pi -e '/^(\s*)PATH=...VG_PATH_PREFIX/ and ' \ -e 'print $1,q|CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst |,"\\\n"'
2006-08-22* aclocal.m4, config.hin, configure:Paul Eggert-7/+1
Remove from CVS, since ./bootstrap generates them automatically. * .cvsignore: Add INSTALL, Makefile.in, *.cache, *.lineno, *.log. Remove more-specific entries. This catches files like configure.lineno. * man/.cvsignore: Add Makefile.in. * src/.cvsignore: Add Makefile.in. Remove .version, dir.c, install, mvdir, stamp-v, vdir.c, version.c. For .cvsignore file under the tests directory: Add Makefile.in. Sort entries if necessary. Remove *.I, *.E, *.X, *.O, *-tests, build-script, mk-script if they're never created in this directory. * build-aux/.cvsignore: New file. * doc/.cvsignore: Add Makefile.in, coreutils.html, coreutils.pdf, coreutils.ps, coreutils.tps. Remove coreutils.cm (dunno what it is, but the makefile doesn't mention it). Remove coreutils.info as it is subsumed by coreutils.info*. * lib/.cvsignore: Add Makefile.in, getdate.tab.h. Remove stat.c, sysexit.h. * m4/.cvsignore: Remove Makefile, dev-ino.m4, glibc2.m4, intdiv0.m4, inttypes-h.m4, inttypes-pri.m4, jm-glibc-io.m4, lcmessage.m4, lock.m4, printf-posix.m4, same-inode.m4, size_max.m4, uintmax_t.m4, ulonglong.m4, visibility.m4, xsize.m4. Many of these are put in automatically by ../bootstrap, but that's a bootstrap bug that I plan to fix shortly. * po/.cvsignore: More ../bootstrap-related fixes, plus remove old cruft. Add *.po, LINGUAS, Makevars. Remove *.cat, *.msg, cat-id-dbl.c, messages.mo, stamp-cat-id.
2006-08-21Remove from CVS, since the bootstrap script generates them automatically.Paul Eggert-574/+0
2006-08-19.Jim Meyering-1/+1
2006-08-17Add/fix copyright notices and adjust to latest GNU FDL.Paul Eggert-0/+19
2006-08-15.Jim Meyering-39/+46
2006-08-09Regenerate.Paul Eggert-13/+15
2006-08-09Regenerate.Paul Eggert-34/+36
2006-07-17Regenerate.Paul Eggert-36/+35
2006-07-09Regenerate.Paul Eggert-40/+62
2006-07-03* tests/Makefile.am, tests/*/Makefile.am: (TESTS_ENVIRONMENT):Jim Meyering-1/+1
Add $VG_PATH_PREFIX as a prefix to $PATH
2006-05-06.Jim Meyering-2/+0
2006-03-26.Jim Meyering-3/+4
2006-03-12.Jim Meyering-6/+6
2006-02-20.Jim Meyering-5/+7
2006-01-12.Jim Meyering-5/+8