summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* md2-buffer tests: New module.Bruno Haible2021-09-191-0/+0
| | | | | | | * tests/test-md2-buffer.c: Renamed from tests/test-md2.c. * modules/crypto/md2-buffer-tests: Renamed from modules/crypto/md2-tests. Test tests/test-md2-buffer.c instead of tests/test-md2.c.
* stdint-tests: long long preproc on recent Sun CPaul Eggert2021-09-122-4/+5
| | | | | * tests/test-stdint.c: Test long long preprocessor constants on Oracle Developer Studio 12.6, where they should work.
* supersede: Fix test failure under QEMU user-mode for Linux/mips.Bruno Haible2021-08-302-4/+12
| | | | | | * tests/test-supersede-open.h (test_open_supersede): Copy statbuf.st_dev into a local variable of type dev_t. * tests/test-supersede-fopen.h (test_fopen_supersede): Likewise.
* spawn-pipe: Fix test failure when running under QEMU user-mode.Bruno Haible2021-08-301-6/+19
| | | | | | | | * tests/test-spawn-pipe-child.c: Include <stdbool.h>, <string.h>, qemu.h. (main): Under QEMU user-mode, allow fd 2 or fd 3 to be open. * modules/spawn-pipe-tests (Files): Add qemu.h. (Depends-on): Add stdbool.
* execute: Fix test failure when running under QEMU user-mode.Bruno Haible2021-08-301-1/+11
| | | | | | | * tests/test-execute-child.c: Include <stdbool.h>, qemu.h. (main): Under QEMU user-mode, allow fd 3 to be open. * modules/execute-tests (Files): Add qemu.h. (Depends-on): Add stdbool.
* posix_spawn_file_actions_addfchdir: Avoid test failure under QEMU.Bruno Haible2021-08-301-11/+24
| | | | | | | | | | | * tests/test-posix_spawn-fchdir.c: Include qemu.h. (is_qemu): New variable. (test): Under QEMU user-mode, don't expect that "pwd" produces the result "/". (main): Initialize is_qemu. Under QEMU user-mode, skip the relative file name test. * modules/posix_spawn_file_actions_addfchdir-tests (Files): Add qemu.h. (Depends-on): Add stdbool.
* getcwd tests: Avoid test failure when running under QEMU user-mode.Bruno Haible2021-08-301-1/+11
| | | | | | | | * modules/getcwd-tests (Files): Add qemu.h. (Depends-on): Add stdbool. * tests/test-getcwd.c: Include qemu.h. (test_long_name): Skip this test when running under QEMU user-mode. (main): Consider return code 77 from test_long_name.
* explicit_bzero test: Fix test failure due to GCC optimizations.Bruno Haible2021-08-291-4/+17
| | | | | | * tests/test-explicit_bzero.c (do_secret_stuff): Use static variable 'last_stackbuf'. (main): Use an 'if' to combine the two do_secret_stuff invocations.
* base32, base64: fix broken testsPaul Eggert2021-08-292-2/+2
| | | | | | | | | | | | Problem reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2021-08/msg00170.html * lib/base32.c, lib/base64.c: Do not include verify.h, and omit all uses of ‘assume’. * modules/base32, modules/base64 (Depends-on): Remove verify. * tests/test-base32.c, tests/test-base64.c: Don’t pass out-of-range values to allocator, as converting them to idx_t relies on implementation-defined behavior that could trap.
* sigabbrev_np, sigdescr_np: Fix compilation error on Linux/alpha, part 2.Bruno Haible2021-08-292-2/+2
| | | | | * tests/test-sigabbrev_np.c (main): Fix syntax error. * tests/test-sigdescr_np.c (main): Likewise.
* Skip some tests when running under QEMU user-mode.Bruno Haible2021-08-299-4/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tests/qemu.h: New file. * tests/test-get-rusage-as.c: Include qemu.h. (main): Skip the test when running under QEMU. * tests/test-get-rusage-data.c: Include qemu.h. (main): Skip the test when running under QEMU. * tests/test-printf-posix2.c: Include qemu.h. (main): Return with code 77 when running under QEMU. * tests/test-fprintf-posix2.c: Include qemu.h. (main): Return with code 77 when running under QEMU. * tests/test-fprintf-posix3.c: Include qemu.h. (main): Return with code 79 when running under QEMU. * tests/test-fprintf-posix3.sh: Skip the test when the return code was 79. * tests/test-dprintf-posix2.c: Include qemu.h. (main): Return with code 79 when running under QEMU. Use return code 80 instead of 78. * tests/test-dprintf-posix2.sh: Skip the test when the return code was 79. Update for changed return code. * modules/get-rusage-as-tests (Files): Add qemu.h. (Depends-on): Add stdbool. * modules/get-rusage-data-tests (Files): Add qemu.h. (Depends-on): Add stdbool. * modules/fprintf-posix-tests (Files): Add qemu.h. (Depends-on): Add stdbool. * modules/dprintf-posix-tests (Files): Add qemu.h. (Depends-on): Add stdbool.
* sigabbrev_np, sigdescr_np: Fix compilation error on Linux/alpha.Bruno Haible2021-08-282-2/+2
| | | | | | | | * lib/sigabbrev_np.c (sigabbrev_np): When SIGINFO and SIGPWR have the same value, give precendence to SIGPWR. * lib/sigdescr_np.c (sigdescr_np): Likewise. * tests/test-sigabbrev_np.c (main): Likewise. * tests/test-sigdescr_np.c (main): Likewise.
* execle, execve, execvpe tests: Fix test failures under qemu user-mode.Bruno Haible2021-08-283-33/+126
| | | | | | | | * test-execle-main.c: Include <string.h>. (get_environ_assignment, create_minimal_env): New functions. (main): Call create_minimal_env. * test-execve-main.c: Likewise. * test-execvpe-main.c: Likewise.
* base32, base64: prefer signed to unsigned integersPaul Eggert2021-08-272-2/+2
| | | | | | | | | | | | | | | | | | | | * lib/base32.c, lib/base64.c: Include ialloc.h instad of stdlib.h. Include intprops.h, verify.h. * lib/base32.c (base32_encode, base32_encode_alloc, get_8, decode_8) (base32_decode_ctx, base32_decode_alloc_ctx): * lib/base32.h (struct base32_decode_context): * lib/base64.c (base64_encode_fast, base64_encode) (base64_encode_alloc, get_4, decode_4, base64_decode_ctx) (base64_decode_alloc_ctx): * lib/base64.h (struct base64_decode_context): * tests/test-base32.c (main): * tests/test-base64.c (main): Prefer signed to unsigned integers. * lib/base32.c (base32_encode_alloc): * lib/base64.c (base64_encode_alloc): Use simpler and more-direct check for overflow, removing a TODO. * lib/base32.h, lib/base64.h: Include idx.h instead of stddef.h. * modules/base32, modules/base64 (Depends-on): Add ialloc, verify.
* gnulib-common.m4: Use C2x [[maybe_unused]] when possible.Bruno Haible2021-08-2231-31/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * m4/gnulib-common.m4 (gl_COMMON_BODY): Define _GL_UNUSED as an alias of _GL_ATTRIBUTE_MAYBE_UNUSED, not of _GL_ATTRIBUTE_UNUSED. * lib/binary-io.h (__gl_setmode): Put _GL_UNUSED before, not after, the declaration. * lib/c-stack.c (null_action, segv_handler, overflow_handler, c_stack_action): Likewise. * lib/chown.c (chown): Likewise. * lib/clean-temp-simple.c (cleanup_action): Likewise. * lib/fts.c (dirent_inode_sort_may_be_useful, leaf_optimization, fts_set): Likewise. * lib/getgroups.c (getgroups): Likewise. * lib/getopt.c (_getopt_initialize): Likewise. * lib/getugroups.c (getugroups): Likewise. * lib/localename.c (gl_locale_name_thread_unsafe, gl_locale_name_thread, gl_locale_name_posix, gl_locale_name_environ): Likewise. * lib/mkdir.c (rpl_mkdir): Likewise. * lib/mkfifo.c (mkfifo): Likewise. * lib/mkfifoat.c (mkfifoat): Likewise. * lib/mknod.c (mknod): Likewise. * lib/mknodat.c (mknodat): Likewise. * lib/mountlist.c (me_remote): Likewise. * lib/openpty.c (openpty): Likewise. * lib/parse-datetime.y (yyerror): Likewise. * lib/passfd.c (sendfd, recvfd): Likewise. * lib/pthread-cond.c (pthread_condattr_destroy, pthread_cond_init, pthread_cond_wait, pthread_cond_timedwait, pthread_cond_signal, pthread_cond_broadcast, pthread_cond_destroy): Likewise. * lib/pthread-mutex.c (pthread_mutexattr_destroy, pthread_mutex_init, pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_timedlock, pthread_mutex_unlock, pthread_mutex_destroy): Likewise. * lib/pthread-rwlock.c (pthread_rwlockattr_destroy, pthread_rwlock_init, pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock): Likewise. * lib/pthread-spin.c (pthread_spin_init, pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock, pthread_spin_destroy): Likewise. * lib/pthread-thread.c (pthread_attr_destroy): Likewise. * lib/readlink.c (readlink): Likewise. * lib/rename.c (rpl_rename): Likewise. * lib/set-permissions.c (set_permissions): Likewise. * lib/sockets.c (gl_sockets_startup): Likewise. * lib/stat-time.h (get_stat_birthtime_ns, get_stat_birthtime, stat_time_normalize): Likewise. * lib/strptime.c (__strptime_internal): Likewise. * lib/strtod.c (LDEXP): Likewise. * lib/symlink.c (symlink): Likewise. * lib/symlinkat.c (symlinkat): Likewise. * lib/tempname.c (try_dir, try_nocreate): Likewise. * lib/textstyle.in.h (styled_ostream_begin_use_class, styled_ostream_end_use_class, styled_ostream_get_hyperlink_ref, styled_ostream_get_hyperlink_id, styled_ostream_set_hyperlink, styled_ostream_flush_to_current_style, fd_ostream_create, term_ostream_get_color, term_ostream_set_color, term_ostream_get_bgcolor, term_ostream_set_bgcolor, term_ostream_get_weight, term_ostream_set_weight, term_ostream_get_posture, term_ostream_set_posture, term_ostream_get_underline, term_ostream_set_underline, term_ostream_get_hyperlink_ref, term_ostream_get_hyperlink_id, term_ostream_set_hyperlink, term_ostream_create, term_styled_ostream_create, html_styled_ostream_create, handle_color_option, handle_style_option, style_file_prepare, styled_ostream_create, libtextstyle_set_failure_exit_code): Likewise. * lib/unicodeio.c (exit_failure_callback, fallback_failure_callback): Likewise. * lib/wait-process.c (cleanup_slaves_action): Likewise. * tests/signature.h (SIGNATURE_CHECK2): Likewise. * tests/test-areadlink.c (do_areadlink): Likewise. * tests/test-areadlinkat.c (do_areadlinkat): Likewise. * tests/test-ceilf-ieee.c (main): Likewise. * tests/test-ceilf1.c (main): Likewise. * tests/test-dirent.c (dir): Likewise. * tests/test-fchownat.c (main): Likewise. * tests/test-fdopendir.c (main): Likewise. * tests/test-filenamecat.c (main): Likewise. * tests/test-floor1.c (main): Likewise. * tests/test-floorf-ieee.c (main): Likewise. * tests/test-floorf1.c (main): Likewise. * tests/test-fseeko.c (main): Likewise. * tests/test-fstatat.c (main): Likewise. * tests/test-ftello.c (main): Likewise. * tests/test-getdomainname.c (main): Likewise. * tests/test-getgroups.c (main): Likewise. * tests/test-gethostname.c (main): Likewise. * tests/test-math-c++.cc (OVERLOADED_CHECK): Likewise. * tests/test-mkdirat.c (main): Likewise. * tests/test-openat.c (main): Likewise. * tests/test-parse-datetime.c (main): Likewise. * tests/test-quotearg-simple.c (main): Likewise. * tests/test-quotearg.c (main): Likewise. * tests/test-sethostname2.c (main): Likewise. * tests/test-unlinkat.c (main): Likewise. * tests/test-version-etc.c (main): Likewise. * tests/test-xalloc-die.c (main): Likewise. * tests/test-xfprintf-posix.c (main): Likewise. * tests/test-xprintf-posix.c (main): Likewise. * tests/test-xvasprintf.c (main): Likewise.
* memrchr-tests: port to GCC 12Paul Eggert2021-08-121-1/+1
| | | | * tests/test-memrchr.c: Bug#101494 is fixed in GCC 12.
* sigsegv-tests: make more things staticPaul Eggert2021-08-013-19/+19
| | | | | | | | * tests/test-sigsegv-catch-segv1.c: * tests/test-sigsegv-catch-stackoverflow1.c: * tests/test-sigsegv-catch-stackoverflow2.c: Declare some functions and variables static, to pacify GCC when warning about external functions missing declarations.
* argmatch-tests: improve -fanalyzer malloc checkingPaul Eggert2021-08-011-0/+7
|
* limits-h tests: Add tests for BOOL_MAX and BOOL_WIDTH.Bruno Haible2021-08-011-0/+5
| | | | | * tests/test-limits-h.c (bool_attrs): New variable. Check value of BOOL_MAX.
* maint: pacify GCC 11.2 -fanalyzer in crypto testsPaul Eggert2021-07-311-0/+5
| | | | | * tests/bench-digest.h (main): Report an error after memory exhaustion, instead of using a null pointer.
* gnulib-common: update for C2x 2020-12-11 draftPaul Eggert2021-07-312-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use blessed-by-draft-standard way to test for [[__deprecated__]] etc.; this is supported by GCC 11 and the fallback code should work fine with GCC 10 and earlier, clang, etc. * NEWS, doc/attribute.texi: Mention that DEPRECATED etc. must now come first. * lib/fflush.c, lib/unistr.in.h: Do not include unused-parameter.h. All uses of _GL_UNUSED_PARAMETER (after parameters) replaced by _GL_ATTRIBUTE_MAYBE_UNUSED (before parameters). Although perhaps we need a shorter name for _GL_ATTRIBUTE_MAYBE_UNUSED, that should probably be in gnulib-common.m4, due to the ubiquity of this issue. And perhaps the snippet/unused-parameter module should be marked obsolete since it's no longer compatible with its old use. * m4/gnulib-common.m4 (gl_COMMON_BODY): Define the macro _GL_HAS_C_ATTRIBUTE, and use it instead of __STDC_VERSION__ in deciding whether to use C2x attributes like [[__deprecated__]]. (_GL_ATTRIBUTE_MAYBE_UNUSED): Fall back on _GL_ATTRIBUTE_UNUSED. (_GL_ATTRIBUTE_UNUSED): New macro, for labels where C2x [[maybe_unused]] do not work. (_GL_UNUSED, _GL_UNUSED_LABEL): Use it. * modules/fflush, modules/unistr/base (Depends-on): Remove snippet/unused-parameter. * modules/fflush (selinux/selinux.h, selinux/context.h) (selinux/label.h): Do not use $(UNUSED_PARAMETER). Remove useless chmod a-x.
* explicit_bzero-tests: pacify GCC betterPaul Eggert2021-07-181-5/+11
| | | | | | | | Problem reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2021-07/msg00039.html * tests/test-explicit_bzero.c: Ignore -Wmaybe-uninitialized. (stackbuf): Remove this static pointer, reverting recent change. (do_secret_stuff, test_stack): Revert these related changes too.
* memrchr-tests: pacify GCCPaul Eggert2021-07-171-0/+5
| | | | | Pacify GCC 11.1.1 20210531 (Red Hat 11.1.1-3) x86-64. * tests/test-memrchr.c: Disable -Wmaybe-uninitialized.
* explicit_bzero-tests: pacify GCCPaul Eggert2021-07-171-3/+5
| | | | | | | | Redo to pacify -Wmaybe-uninitialized with GCC 11.1.1 20210531 (Red Hat 11.1.1-3) x86-64. * tests/test-explicit_bzero.c (stackbuf): New static pointer. (do_secret_stuff): Use it. (test_stack): Set it to a local buffer.
* regex: modernize to newer regex bugsetPaul Eggert2021-07-141-5/+6
| | | | | | | | | | | Problem reported by Hiroo Hayashi in: https://lists.gnu.org/r/bug-gnulib/2021-07/msg00024.html * m4/regex.m4 (gl_REGEX): Allow newer glibc behavior for ()0|\1, behavior where the regex compiles but does not match. Test for glibc bug 11053. * tests/test-regex.c (bug_regex11, main): Add casts needed for printf portability. (main): Allow newer glibc behavior for ()0|\1.
* sigsegv, sigsegv-tests: Assign my contributions to the FSF.Eric Blake2021-06-213-3/+0
| | | | | | | | | | Following Bruno's lead, I'm also happy with this change. * m4/sigaltstack.m4: Change copyright notice: Write "Copyright (C) FSF" instead of "Copyright (C) Eric Blake". * tests/altstack-util.h: Likewise. * tests/test-sigsegv-catch-stackoverflow1.c: Likewise. * tests/test-sigsegv-catch-stackoverflow2.c: Likewise.
* sigsegv, sigsegv-tests: Assign my contributions to the FSF.Bruno Haible2021-06-196-6/+18
| | | | | | | | | | | | | | | | * lib/sigsegv.in.h: Change copyright notice: Write "Copyright (C) FSF" instead of "Copyright (C) Bruno Haible". * lib/sigsegv.c: Likewise. * lib/stackvma.h: Likewise. * lib/stackvma.c: Likewise. * m4/sigaltstack.m4: Likewise. * m4/stack-direction.m4: Likewise. * tests/altstack-util.h: Likewise. * tests/mmap-anon-util.h: Likewise. * tests/test-sigsegv-catch-segv1.c: Likewise. * tests/test-sigsegv-catch-segv2.c: Likewise. * tests/test-sigsegv-catch-stackoverflow1.c: Likewise. * tests/test-sigsegv-catch-stackoverflow2.c: Likewise.
* pipe-filter-ii tests: Fix long-standing failure on native Windows.Bruno Haible2021-06-152-0/+8
| | | | | | | * tests/test-pipe-filter-ii2-main.c: Include binary-io.h. (main): Avoid NL to CRLF conversion on standard output. * tests/test-pipe-filter-ii2-child.c: Include <unistd.h>, binary-io.h. (main): Avoid NL to CRLF conversion on standard output.
* sigsegv tests: Hide a null pointer from the compiler's optimizations.Bruno Haible2021-06-091-1/+2
| | | | | | | | Patch by Paul Eggert. * tests/test-sigsegv-catch-stackoverflow2.c (null_pointer_to_volatile_int): New variable. (main): Use it.
* ptsname_r: Add support for DragonFly BSD 6.0.Bruno Haible2021-06-081-2/+3
| | | | | * lib/ptsname_r.c (__ptsname_r): Add implementation for DragonFly BSD. * tests/test-ptsname_r.c (main): Treat Dragonfly BSD like Solaris.
* Avoid some test failures on DragonFly BSD 6.0.Bruno Haible2021-06-085-11/+26
| | | | | | | | | * tests/test-c32isalnum.c (main): On Dragonfly BSD, disable tests that fail. * tests/test-c32isalpha.c (main): Likewise. * tests/test-c32islower.c (main): Likewise. * tests/test-c32isupper.c (main): Likewise. * tests/test-ptsname.c (main): Treat Dragonfly BSD like Solaris.
* regex-tests: test for regressions fixed by the previous commitDmitry V. Levin2021-06-061-0/+4
| | | | | | | * tests/test-regex.c (tests): Add test cases for *+ and ** regressions fixed by the previous commit. Link: https://lists.gnu.org/archive/html/bug-gnulib/2021-04/msg00134.html
* regex-tests: remove incorrect commentDmitry V. Levin2021-06-061-1/+0
| | | | | | | | * tests/test-regex.c (tests): Remove the comment saying that some tests are not used. That comment was copied along with tests from glibc where some of these tests are commented out. Fixes: 70b673eb7 ("regex: fix longstanding backref match bug")
* Generate correct license notices in libunistring files.Bruno Haible2021-06-045-0/+80
| | | | | | | | | | | | | | | | | | | * lib/gen-uni-tables.c (output_library_license, output_tests_license): New functions. (output_predicate, output_category, output_combclass, output_bidi_category, output_decimal_digit, output_digit, output_numeric, output_mirror, output_joining_type, output_joining_group, output_scripts, output_scripts_byname, output_blocks, output_ident_category, output_lbrk_tables, output_wbrk_tables, output_gbp_table, output_decomposition_tables, output_composition_tables, output_simple_mapping, output_casing_rules): Invoke output_library_license. (output_predicate_test, output_decimal_digit_test, output_digit_test, output_numeric_test, output_joining_type_test, output_joining_group_test, output_gbp_test, output_simple_mapping_test): Invoke output_tests_license. * lib/uni*/*.h, lib/uni*/*.gperf: Regenerated. * tests/uni*/*.h: Likewise.
* reallocarray-tests: port to weird platformsPaul Eggert2021-05-301-3/+6
| | | | | | * tests/test-reallocarray.c (main): Don’t assume that PTRDIFF_MAX / 2 + 1 <= SIZE_MAX. POSIX allows platforms where this isn’t true, though I don’t know of any examples.
* dfa, etc.: prefer xreallocarray to older namePaul Eggert2021-05-301-4/+4
| | | | | | | | | * lib/dfa.c (addtok_mb, realloc_trans_if_necessary, enlist): * lib/readtokens.c (readtokens): * tests/uninorm/test-u32-normalize-big.c: (read_normalization_test_file): Prefer xreallocarray to the equivalent xnrealloc. The newer name follows the glibc lead of ‘reallocarray’.
* sigsegv: don’t assume SIGSTKSZ is a constantPaul Eggert2021-05-213-9/+15
| | | | | | | | | | | | * m4/sigaltstack.m4 (SV_SIGALTSTACK): Don’t attempt to override SIGSTKSZ. Instead, use an array that is plenty large, while checking that it’s large enough. Also, be consistent about putting that array in static storage rather than on the stack. * tests/altstack-util.h (SIGSTKSZ): Don’t define. (MYSTACK_SIZE): New macro, used consistently instead of SIGSTKSZ. (mystack_storage, mystack): Now static. (prepare_alternate_stack) [defined SIGSTKSZ]: Check that MYSTACK_SIZE is large enough.
* sigsegv: Add tests.Bruno Haible2021-05-166-0/+792
| | | | | | | | | | | * tests/test-sigsegv-catch-segv1.c: New file, from GNU libsigsegv with modifications. * tests/test-sigsegv-catch-segv2.c: Likewise. * tests/test-sigsegv-catch-stackoverflow1.c: Likewise. * tests/test-sigsegv-catch-stackoverflow2.c: Likewise. * tests/altstack-util.h: Likewise. * tests/mmap-anon-util.h: Likewise. * modules/sigsegv-tests: New file.
* realloc-gnu: avoid glibc MALLOC_CHECK_ issuePádraig Brady2021-05-151-1/+4
| | | | | | | | * tests/test-realloc-gnu.c (main): if MALLOC_CHECK_ env var is set then don't check ENOMEM is returned from realloc(). See https://sourceware.org/bugzilla/show_bug.cgi?id=27870 Note it doesn't suffice to unsetenv() this var within the program, as the hooks have already been set up at that stage.
* fcntl tests: Avoid failure in MacPorts.Bruno Haible2021-05-142-1/+12
| | | | | | | | | Reported by Nicholas Gaya <nicholasgaya@gmail.com> in <https://lists.gnu.org/archive/html/bug-gnulib/2021-05/msg00014.html>. * tests/test-fcntl.c (main): Close fd 10 before assuming that it is closed. * tests/test-execute-main.c: Update comment.
* *alloc-gnu tests: Use ASSERT macro.Bruno Haible2021-05-144-24/+31
| | | | | | | | | | | | | | | * tests/test-malloc-gnu.c: Include "macros.h". (main): Use ASSERT. * tests/test-calloc-gnu.c: Include "macros.h". (main): Use ASSERT. * tests/test-realloc-gnu.c: Include "macros.h". (main): Use ASSERT. * tests/test-reallocarray.c: Include "macros.h". (main): Use ASSERT. * modules/malloc-gnu-tests (Files): Add tests/macros.h. * modules/calloc-gnu-tests (Files): Likewise. * modules/realloc-gnu-tests (Files): Likewise. * modules/reallocarray-tests (Files): Likewise.
* reallocarray tests: Avoid test failure on NetBSD.Bruno Haible2021-05-131-1/+2
| | | | * tests/test-reallocarray.c (main): Accept EOVERFLOW error code.
* malloc-gnu, realloc-gnu, calloc-gnu tests: Verify errno is set.Bruno Haible2021-05-093-4/+10
| | | | | | | | * tests/test-malloc-gnu.c: Include <errno.h>. (main): Verify that, when an allocation larger than PTRDIFF_MAX failed, errno is ENOMEM. * tests/test-realloc-gnu.c: Likewise. * tests/test-calloc-gnu.c: Likewise.
* free tests: Avoid test failure on glibc < 2.15.Bruno Haible2021-05-091-1/+3
| | | | * tests/test-free.c (main): Skip the hairy test on glibc < 2.15.
* reallocarray: don’t crash if item size is 0Paul Eggert2021-04-251-2/+7
| | | | | | | | | This problem affects only platforms where xalloc_oversized divides a number by the size arg. Fix this by defining xalloc_oversized (n, s) to work even if s == 0. * lib/malloca.h, lib/xalloc-oversized.h: Document new behavior. * lib/xalloc-oversized.h (__xalloc_oversized): Do not crash if S==0. * tests/test-reallocarray.c (main): Test for the bug.
* reallocarray: check for ptrdiff_t overflowPaul Eggert2021-04-241-16/+21
| | | | | | | | | | | | | | | | * doc/glibc-functions/reallocarray.texi (reallocarray): Mention ptrdiff_t overflow. * lib/reallocarray.c (reallocarray): Reindent as per usual GNU. * lib/stdlib.in.h (reallocarray): Allow reallocarray to be replaced. * m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY): Check for ptrdiff_t overflow. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Set up REPLACE_REALLOCARRAY. * modules/reallocarray (Files): Add malloc.m4. (configure.ac): Also test REPLACE_REALLOCARRAY. * modules/reallocarray-tests (Depends-on): Add stdint. * modules/stdlib (stdlib.h): Substitute REPLACE_REALLOCARRAY. * tests/test-reallocarray.c: Include stdint.h. (main): Check for ptrdiff_t overflow.
* calloc-gnu-tests: add overflow testsPaul Eggert2021-04-241-21/+16
| | | | | | * tests/test-calloc-gnu.c (identity): New function, replacing ‘eight’. (main): Do 2 * log2(SIZE_MAX) tests instead of just two tests. Don’t bother to free on failure.
* execute-tests: pacify compilerPaul Eggert2021-04-211-3/+3
| | | | | | * tests/test-execute-main.c (main): Use 0x7DEADBEE rather than 0xDEADBEEF for nonces, to avoid provoking AIX XLC compiler warning that the latter is out of int range.
* malloc-gnu-tests, etc.: use volatile for clangPaul Eggert2021-04-207-17/+20
| | | | | | | | | | | | | | | In some more test locations, store the result of malloc etc. into a volatile pointer so that clang doesn’t optimize away the malloc and thus bypass the test. This fixes a malloc-gnu test failure on macOS 11.2.3 with clang 12.0.0 on ARM. * tests/test-alloca-opt.c (do_allocation): * tests/test-malloc-gnu.c (main): * tests/test-malloca.c (do_allocation): * tests/test-realloc-gnu.c (main): * tests/test-reallocarray.c (main): * tests/test-aligned-malloc.c (main): * tests/test-aligned_alloc.c (main): Store malloc etc. results into a volatile pointer.
* malloc-gnu-tests: pacify -Walloc-size-larger-thanPaul Eggert2021-04-182-6/+6
| | | | | | | | * tests/test-malloc-gnu.c (main): * tests/test-realloc-gnu.c (main): Hide true intentions from GCC, to prevent diagnostics like “warning: argument 1 value ‘9223372036854775808’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]”.