test


Log

Author Commit Date CI Message
Guillem Jover dd0bdb58 2024-01-08T01:58:54 test: Close all descriptors before initializing them for closefrom() On macOS, closefrom() only sets the close-on-exec flag, so we cannot check whether all file descriptors were closed, which means that if on entry our file descriptor table was filled after the 4th file descriptor, then we might fail the assertions for the flags for odd file descriptors which we expect to be closed. This can easily happen when running the test suite in parallel mode with «make -j8 check» for example. Closes: #23
Guillem Jover a44f885c 2023-11-14T19:08:15 test: Fix short-lived memory leak Warned-by: cppcheck
Guillem Jover dc1bd1a2 2023-04-23T02:00:10 build: Conditionalize only id-from-name functions not the entire pwcache On macOS the name-from-id functions are present, but not the id-from-name ones, so we want to provide those instead of suppressing the entire file.
Guillem Jover edc746ea 2023-04-22T22:47:10 build: Conditionalize getprogname()/setprogname on macOS These functions are provided by the system libc, so there is no need for us to provide them.
Guillem Jover 90b7f3ae 2023-04-17T23:59:19 test: Do not use /dev/null as compiler output file Some ld(1) implementations, such as the one on AIX, do not support using /dev/null as the output filename for the compiled object. Use an actual filename that we will then clean up.
Guillem Jover 21d12b02 2023-04-04T23:59:05 build: On macOS do not build functions provided by the system We have never built before on macOS, so we can exclude all the functions that are currently provided in the system. Closes: #1 Closes: !3
Guillem Jover bc65806c 2023-04-06T23:05:27 build: Select whether to include funopen() in the build system This makes sure we include it when expected, alongside the man pages, and the test cases, and do not accidentally break the ABI if the system starts providing such interface.
Guillem Jover fe16f386 2023-04-10T23:11:33 test: Use open_memstream() only if available On Solaris this function is not yet available.
Guillem Jover 7c652a94 2023-04-10T20:57:14 test: Do not hardcode root:root user and group names On some systems the root group is named wheel, and there is no root group.
Guillem Jover ed2eb31d 2023-04-01T02:46:22 test: Fix closefrom() test on macOS On macOS we do not close the file descriptors, and instead mark them all as close-on-exec. So checking whether they are not valid does not work.
Guillem Jover 0f8bcdfd 2023-04-01T02:48:47 test: Fix closefrom() test to handle open file descriptor limits If the system has configured a lower limit (either soft or hard) on the number of open file descriptors, the test will fail. Make sure to check whether we have exceeded that limit and adapt the max number of file descriptors appropriately.
Guillem Jover 07192b31 2023-04-05T00:01:42 test: Disable blank_stack_side_effects() on non-Hurd systems This code was added to cope with Hurd specific behavior, but it is causing flakiness on containers on some Linux systems. Only enable it where it is currently needed to try to get stability back on CI systems. Closes: #14
Guillem Jover 536a7d42 2023-03-21T04:11:03 test: Exempt blank_stack_side_effects() from sanitizer checks This will mean we cannot use sanitizer support on the Hurd, for which this function was added to fix the test. But the sanitizer suppression function attribute is not having any effect, so this is better than nothing.
Guillem Jover 7ed5de01 2023-03-21T04:10:33 test: Import explicit_bzero() sanitizer support changes from OpenBSD
Guillem Jover 05a802a2 2023-03-14T03:05:58 test: Fix memory leaks in fpurge test Warned-by: gcc -fsanitize=leak
Guillem Jover e5089628 2022-11-23T23:31:54 build: Do not require funopen() to be ported This function cannot be easily and (more importantly) correctly ported without cooperation from the libc stdio layer. We already document that users should be prepared to have the function not available on some platforms and that they should ideally switch their code to other more portable and better interfaces. Instead of making the build fail, and requiring porters to add exceptions for something that most probably cannot be ported correctly anyway, simply print a warning and let it build. This will not be a regression because on those systems libbsd would have never been built before. Prompted-by: Jens Finkhaeuser <jens@finkhaeuser.de>
Guillem Jover 00b538ff 2022-11-23T23:28:34 build: Terminate lists in variables with «# EOL» This means we can add a trailing «\» to every element, so that they can be removed without requiring modification of other lines, and can be easily sorted. Replace the old usage of $(nil) which could possibly end up with junk added if such variable is ever defined, in the environment.
Guillem Jover d5865759 2022-08-25T00:52:43 test: Fix explicit_bzero() test on the Hurd On the Hurd a small read(3) might end up (indirectly) copying the data on the stack, which we will end up finding even when we have cleared the buffer. To avoid these side effects, we add a new function, that we force not to be inlined, so that we can reuse the same stack space, that will blank any possible stack side effects. This should be portable regardless of stack growing up or down. Diagnosis-by: Samuel Thibault <sthibault@debian.org>
Guillem Jover c9ff8368 2022-01-29T14:48:22 test: Import explicit_bzero and strtonum test cases from OpenBSD - Remove trailing spaces. - Declare file-scope functions and variables static. - Declare functions with a proper prototype. - Do not mix declarations and code for C90 conformance. - Do not compare size_t and ssize_t variables.
Guillem Jover 62e67bb4 2022-01-29T14:52:08 build: Sort test programs in .gitignore
Duncan Overbruck 87b13070 2022-01-25T20:34:39 test: Add fpurge() test case using open_memstream(3) FILE Signed-off-by: Guillem Jover <guillem@hadrons.org>
Duncan Overbruck 091097e0 2022-01-24T16:47:00 test: Remove static FILE declaration from fpurge test This does not work with libcs that do not declare the structure in a header file, like musl. And gets in the way of supporting non-fd based streams. Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover eef07993 2022-01-25T01:41:14 Revert "build: Add missing proctitle unit test program" This reverts commit beafad2657c7a57109c28f8bad9cb028c84c7dd5. This test was already handled later on as part of the BUILD_LIBBSD_CTOR conditional. Adding it to the unconditional set made the build fail when the system does not have GNU .init_array section support. Closes: #9 Analysis-by: Duncan Overbruck <mail@duncano.de>
Guillem Jover e7cf8c57 2021-11-28T22:44:08 Switch md5 compatibility logic back to direct linking When using the recent dlsym() based wrapper, we are not requiring any symbol from libmd, as we resolve those dynamically at run-time. We were ending up linking against libmd because in another part of the code we require (depending on the architecture) the SHA512 functions for the getentropy() local implementation. But that function might be provided by the system libc on some systems, which means we end up not linking against libmd at all. To solve this we go back to the previous simpler solution of linking directly, which had the main drawback of then making programs fail to link when not specifying -lmd (on platforms that need it). And then switch the .so link point from a symlink to a linker script, so that we can inject the -lmd library as-needed. This is similar to what glibc is doing. Fixes: commit 31f034e3862debda8615a449b1c11c4d6920dcc7
Guillem Jover 1eba4060 2021-11-27T21:09:18 test: Check that strdup() does not fail Warned-by: gcc
Victor Westerhuis 2716dfd0 2021-11-26T20:24:20 test: Explicitly mark symbols as used Because some of the symbols are not otherwise referenced, GCC would like to remove them. Closes: !14 Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover 1808d64b 2021-03-01T05:14:10 test: Fix pipe_feed() to allow checking fprintf format strings Warned-by: gcc -W
Guillem Jover beafad26 2021-03-07T00:22:59 build: Add missing proctitle unit test program
Guillem Jover 6145b561 2021-08-17T03:14:57 test: Do not pass NULL as the first funopen() argument Warned-by: gcc -W
Guillem Jover 25e88f64 2021-03-02T00:48:31 test: Cast literal strings to (char *) on n_name assignment The member is declared as n_name so we cannot directly assign a literal string constant. Warned-by: gcc
Guillem Jover 3c305f28 2021-02-19T06:49:53 test: Add proper prototypes for main() function Warned-by: gcc
Guillem Jover 25278891 2021-02-19T06:49:24 Mark local functions as static Warned-by: gcc
Guillem Jover 31f034e3 2021-02-09T05:57:37 Switch libmd wrapper to use dlsym() Switch from the previous versioned symbol implementation which required users to also link against the message digest provider explicitly, or they would fail to find the symbols, to an implementation that loads the symbols from the linked library providing the functions using dlsym(), thus preserving backwards compatibility.
Guillem Jover 25f9b306 2021-02-07T23:24:51 test: Improve code coverage for strnstr(3) unit tests
Guillem Jover 233cab9d 2021-02-06T23:28:42 Add support for new LIBBSD_VIS_OPENBSD selection macro This will make it possible to explicitly select the OpenBSD vis implementation (the current default) for code of OpenBSD origins.
Guillem Jover d54ceb37 2021-02-07T00:09:45 Update copyright claims
Guillem Jover 847e682f 2021-02-07T00:09:30 Use libmd hashing function implementations instead of embedding our own This splits the implementation responsibilities, and reduces embedded code copies, which was one of the driving points with this project to start with, so it's nice to give a good example.
Guillem Jover 37a9b56c 2021-02-06T23:43:12 Import pwcache module from OpenBSD
Guillem Jover d5b04ab1 2020-08-16T22:01:42 test: Fix short lived memory leaks These are non-issues, but having a clean ASAN test suite makes it possible to detect actual problems in the tested code. Warned-by: gcc ASAN
James Clarke 61d378f5 2019-02-03T00:11:15 Re-allow direct use of nlist.n_name in <nlist.h> Commit e8d340de ("Remove a.out support from nlist()") introduced a copy of the definition of nlist from a.out.h. However, as well as having n_name inside n_un, on the various BSDs n_name could also be accessed as a direct member of nlist, and this is made use of by FreeBSD's usr.bin/netstat/main.c. Thus we should also add the same enclosing anonymous union. [guillem@hadrons.org: - Add a minimal unit test. ] Closes: !4 Signed-off-by: Guillem Jover <guillem@hadrons.org>
Aaron Dierking 0500a1bd 2018-06-14T11:38:32 Don't require <grp.h> This is only used in the overlay test and Windows does not provide it. Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover e4e15ed2 2018-05-22T13:50:44 Fix strnvis() and strnunvis() NetBSD ABI break The NetBSD implementations have different prototypes to the ones coming from OpenBSD, which will break builds, and have caused segfaults at run-time. We provide now both interfaces with different prototypes as different version nodes allow selecting them at compile-time, defaulting for now to the OpenBSD one to avoid build-time breakage, while emitting a compile-time warning. Later on, in 0.10.0, we will be switching the compile-time default to the NetBSD version. Ref: http://gnats.netbsd.org/44977 Fixes: https://bugs.debian.org/899282
Jason Duerstock 9ceac74e 2017-12-03T16:50:07 test: Fix nlist(3) unit test on IA64 On IA64 this is only the case in the ELF binary, but it gets normalized when loaded at run-time. Fixes: https://bugs.debian.org/881611 Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover 3b2b7938 2017-06-25T01:51:30 test: Fix nlist() unit test on IA64 and PowerPC 64-bit ELFv1 At least on IA64 and PowerPC 64-bit ELFv1, the functions are stored in the .text sections but they are accessed through a function descriptor stored in a data section, for example for PowerPC 64-bit ELFv1 that section is called .opd. We should take this into account when checking the n_type for the functions we have requested information from nlist(). Rationale-by: James Clarke <jrtc27@jrtc27.com>
Guillem Jover c4e58c09 2017-06-19T21:41:13 test: Remove unused variable in nlist() unit test
Guillem Jover 736e12e8 2017-06-19T21:32:01 test: Handle libtool executable names in getprogname() unit test Sometimes libtool will prefix the test programs with "lt-", we should handle these and strip the prefix. Fixes: https://bugs.debian.org/865090
Guillem Jover cdbb9d05 2017-06-18T20:30:40 test: Add new strnstr() unit test
Guillem Jover 0365d0ef 2017-06-18T20:30:19 test: Add new setprogname() and getprogname() unit test
Guillem Jover 10b13285 2017-06-18T20:29:52 test: Add new setmode() and getmode() unit test
Guillem Jover 922eff5c 2017-06-14T01:52:12 test: Add new nlist() unit test
Guillem Jover 79386192 2017-06-14T02:45:13 Update .gitignore for headers generator
Guillem Jover f1dd5f2e 2017-06-09T05:13:32 test: Add unit test for strlcpy() and strlcat()
Guillem Jover f3b566bd 2016-03-27T12:31:58 test: Add a unit test for md5
Hanno Boeck 008316aa 2016-01-27T15:06:50 test: Add missing <sys/stat.h> include The test in test/strmode.c can fail to compile depending on the optimization flags used. The constants that are used in this file (S_IFREG etc.) come from the <sys/stat.h> include file. It seems gcc ignores this error if one compiles with "-O2" (default), but if one uses no optimization it fails. Add the missing include and it works all the time. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=93880 Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover e4ab2c62 2016-01-11T02:21:15 test: Fix success return code for arc4random unit test
Lukas Fleischer bf5573f8 2016-01-07T17:26:12 test: Fix race condition in headers-*.sh When running tests in parallel (e.g. using `make -j4 check`), the header tests currently fail due to headers-overlay.sh and headers-system.sh both generating headers-gen.c simultaneously, resulting in garbled output. Fix this by using separate C files for the tests. Signed-off-by: Lukas Fleischer <lfleischer@lfos.de> Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover f84004ba 2015-12-12T14:26:50 test: Add new unit tests for individual headers usage
Guillem Jover da137a09 2015-12-07T01:53:49 Add missing copyright and license headers
Guillem Jover 877732ef 2015-11-30T23:48:17 test: Check asprintf() return code
Guillem Jover 02bccb0a 2015-09-30T04:17:15 test: Add unit test for strmode()
Guillem Jover 58bef83f 2015-11-16T01:12:24 test: Add unit test for arc4random()
Guillem Jover 02c33d50 2015-11-30T02:48:23 build: Move proctitle_LDFLAGS inside BUILD_LIBBSD_CTOR conditional
Guillem Jover 45443583 2015-09-23T19:37:37 Add explicit_bzero() function from OpenBSD
Guillem Jover f50b197e 2015-09-22T22:30:17 test: Add fparseln() unit test
Guillem Jover 151bc71d 2015-09-22T16:22:56 Add compile and link-time deprecation warnings for fgetln() Although the current implementation in libbsd is probably one of the safest ones around, it still poses some problems when used with many file streams. This function has now a replacement, that is both more standard and portable. Ask users to switch to getline(3) instead.
Guillem Jover 54f15341 2015-09-22T20:56:15 test: Refactor stream testing functions into a new module
Guillem Jover 32388fe5 2014-11-03T23:21:52 Use reallocarray() instead of malloc() or realloc()
Guillem Jover 3a3d87d7 2015-09-23T04:40:21 test: Add closefrom() unit test
Guillem Jover d62f7d8f 2014-11-01T00:55:55 test: Add test case for fpurge(NULL)
Guillem Jover cfb4d462 2014-11-01T00:54:09 test: Move and activate fpurge() test case from module to a dedicated file
Guillem Jover 205827a2 2014-11-01T00:52:42 build: Centralize testsuite LDADD setting in a single variable
Guillem Jover e8d3d041 2014-07-20T01:48:20 build: Remove hard requirement for GNU .init_array section support In case the support is not available, just stop building the libbsd-ctor.a library, which is a nice to have thing, but should not have been a hard requirement from the start. This should allow to build libbsd on non-glibc based systems using another libc.
Guillem Jover f41fdcf1 2013-10-21T05:07:56 Add funopen() function This is a wrapper over the glibc fopencookie() function. We diverge from the FreeBSD, OpenBSD and DragonFlyBSD declarations, because seekfn() there wrongly uses fpos_t, assuming it's an integral type, and any code using that on a system where fpos_t is a struct (such as GNU-based systems or NetBSD) will fail to build. In which case, as the code has to be modified anyway, we might just as well use the correct declaration.
Guillem Jover 61b2dbb8 2013-07-15T01:44:30 Fix dehumanize_number() to correctly detect overflows Do not allow numbers greated than INT64_MAX and smaller than INT64_MIN. Clarify the positive sign value by prefixing it with an explicit +. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=66909
Guillem Jover c5b95902 2013-07-11T12:25:54 Move setproctitle() automatic initialization to its own library The automatic initialization cannot be part of the main shared library, because there is no thread-safe way to change the environ global variable. This is not a problem if the initializaion happens just at program load time, but becomes one if the shared library is directly or indirectly dlopen()ed during the execution of the program, which could have either kept references to the old environ or could change it in some other thread. This has been observed for example on systems using Samba NSS modules. To avoid any other possible fallout, the constructor is split into a new static library that needs to be linked explicitly into programs using setproctitle(). As an additional safety measure the pkg-config linker flags will mark the program as not allowing to be dlopen()ed so that we avoid the problem described above. Reported-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=66679
Guillem Jover 367e0365 2013-06-08T08:15:21 test: Try setting and getting an environment variable after setproctitle()
Guillem Jover df5aebd7 2013-05-27T06:49:57 test: Mark a literal integer as long long This fixes build failures on 32-bit architectures.
Guillem Jover 330b569f 2013-05-26T04:34:57 test: Add new humanize unit test
Guillem Jover 8c26c40a 2012-11-27T14:23:26 test: Add setproctitle() unit test
Guillem Jover 7196b4dc 2013-05-23T02:05:19 test: Add new fgetln() and fgetwln() unit test
Guillem Jover 14524b54 2012-06-03T07:39:42 build: Set default compiler variables from configure This centralizes the setting so there's no duplication anymore, makes sure the user supplied variables are never overridden, and are only set when using gcc. Reported-by: Samuli Suominen <ssuominen@gentoo.org>
Guillem Jover 34bf1068 2012-03-23T10:43:33 test: Add a unit test for endian encoder/decoder
Guillem Jover 786d1439 2012-03-24T20:37:55 test: Add new overlay unit test
Guillem Jover 23973e22 2012-03-23T10:43:33 build: Add a test suite infrastructure
Guillem Jover abf14c39 2012-03-24T20:37:55 test: Add new headers unit test