Commit Graph

67 Commits

Author SHA1 Message Date
Guillem Jover
c9ff83687c 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.
2022-01-29 14:54:24 +01:00
Guillem Jover
62e67bb49e build: Sort test programs in .gitignore 2022-01-29 14:52:39 +01:00
Duncan Overbruck
87b1307040 test: Add fpurge() test case using open_memstream(3) FILE
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-01-29 14:10:55 +01:00
Duncan Overbruck
091097e062 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>
2022-01-26 04:39:42 +01:00
Guillem Jover
eef07993c9 Revert "build: Add missing proctitle unit test program"
This reverts commit beafad2657.

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>
2022-01-25 01:41:14 +01:00
Guillem Jover
e7cf8c5785 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 31f034e386
2021-12-01 04:14:35 +01:00
Guillem Jover
1eba406021 test: Check that strdup() does not fail
Warned-by: gcc
2021-11-27 23:42:37 +01:00
Victor Westerhuis
2716dfd0b7 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>
2021-11-27 06:52:17 +01:00
Guillem Jover
1808d64b77 test: Fix pipe_feed() to allow checking fprintf format strings
Warned-by: gcc -W
2021-11-27 05:06:14 +01:00
Guillem Jover
beafad2657 build: Add missing proctitle unit test program 2021-11-27 05:06:14 +01:00
Guillem Jover
6145b56178 test: Do not pass NULL as the first funopen() argument
Warned-by: gcc -W
2021-11-27 05:06:14 +01:00
Guillem Jover
25e88f6479 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
2021-11-27 05:06:14 +01:00
Guillem Jover
3c305f2873 test: Add proper prototypes for main() function
Warned-by: gcc
2021-02-28 05:30:31 +01:00
Guillem Jover
25278891d8 Mark local functions as static
Warned-by: gcc
2021-02-28 05:30:25 +01:00
Guillem Jover
31f034e386 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.
2021-02-09 06:23:38 +01:00
Guillem Jover
25f9b30678 test: Improve code coverage for strnstr(3) unit tests 2021-02-07 23:24:51 +01:00
Guillem Jover
233cab9d64 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.
2021-02-07 02:03:22 +01:00
Guillem Jover
d54ceb37ce Update copyright claims 2021-02-07 01:28:27 +01:00
Guillem Jover
847e682f8d 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.
2021-02-07 01:28:27 +01:00
Guillem Jover
37a9b56c05 Import pwcache module from OpenBSD 2021-02-07 01:28:27 +01:00
Guillem Jover
d5b04ab19c 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
2020-12-21 17:44:26 +01:00
James Clarke
61d378f5e9 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>
2019-08-08 03:47:04 +02:00
Aaron Dierking
0500a1bd08 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>
2018-06-18 04:31:00 +02:00
Guillem Jover
e4e15ed286 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
2018-05-22 16:07:42 +02:00
Jason Duerstock
9ceac74e91 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>
2018-01-13 16:17:28 +01:00
Guillem Jover
3b2b7938f7 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>
2017-06-25 02:10:26 +02:00
Guillem Jover
c4e58c0950 test: Remove unused variable in nlist() unit test 2017-06-24 16:06:15 +02:00
Guillem Jover
736e12e8d8 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
2017-06-24 16:05:50 +02:00
Guillem Jover
cdbb9d0555 test: Add new strnstr() unit test 2017-06-19 03:17:21 +02:00
Guillem Jover
0365d0efda test: Add new setprogname() and getprogname() unit test 2017-06-19 03:17:21 +02:00
Guillem Jover
10b1328570 test: Add new setmode() and getmode() unit test 2017-06-19 03:17:21 +02:00
Guillem Jover
922eff5c5e test: Add new nlist() unit test 2017-06-19 03:17:21 +02:00
Guillem Jover
7938619254 Update .gitignore for headers generator 2017-06-19 03:17:21 +02:00
Guillem Jover
f1dd5f2e71 test: Add unit test for strlcpy() and strlcat() 2017-06-09 05:47:07 +02:00
Guillem Jover
f3b566bd7c test: Add a unit test for md5 2016-03-27 12:31:58 +02:00
Hanno Boeck
008316aa29 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>
2016-01-27 15:24:39 +01:00
Guillem Jover
e4ab2c62cd test: Fix success return code for arc4random unit test 2016-01-11 02:35:34 +01:00
Lukas Fleischer
bf5573f86c 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>
2016-01-10 17:36:34 +01:00
Guillem Jover
f84004baf2 test: Add new unit tests for individual headers usage 2015-12-14 03:34:40 +01:00
Guillem Jover
da137a0921 Add missing copyright and license headers 2015-12-07 01:56:25 +01:00
Guillem Jover
877732ef4d test: Check asprintf() return code 2015-11-30 23:48:50 +01:00
Guillem Jover
02bccb0a01 test: Add unit test for strmode() 2015-11-30 23:02:23 +01:00
Guillem Jover
58bef83f41 test: Add unit test for arc4random() 2015-11-30 23:02:23 +01:00
Guillem Jover
02c33d5022 build: Move proctitle_LDFLAGS inside BUILD_LIBBSD_CTOR conditional 2015-11-30 04:10:23 +01:00
Guillem Jover
45443583df Add explicit_bzero() function from OpenBSD 2015-09-24 05:47:58 +02:00
Guillem Jover
151bc71d64 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.
2015-09-23 07:59:34 +02:00
Guillem Jover
f50b197ea5 test: Add fparseln() unit test 2015-09-23 07:59:34 +02:00
Guillem Jover
54f153414a test: Refactor stream testing functions into a new module 2015-09-23 07:59:34 +02:00
Guillem Jover
32388fe59f Use reallocarray() instead of malloc() or realloc() 2015-09-23 07:59:34 +02:00
Guillem Jover
3a3d87d730 test: Add closefrom() unit test 2015-09-23 07:59:34 +02:00