Commit Graph

326 Commits

Author SHA1 Message Date
Emil Velikov
c5c36b61da testsuite: remove need_spawn = false support
Our test suite is a little unique in my experience in that the test can
be either a normal (fork) child or a (re)spawned one. All the other test
frameworks I have used opt for only one of the two.

I'm not entirely sure why we have both since the latter is sufficient for
all use-cases that we have. Perhaps the former was kept as
micro-optimisation?

Currently I am exploring a way to provide the results summary and the
need_spawn = false ones, are printed multiple times. At a glance I
couldn't quite find a way to fix it.

In addition I am also looking at removing/reducing the use of exit()
across the test suite. Where the two code-flows makes that process more
convoluted.

So let's remove one of the code-paths, simplify things and fix the
logging output. If needed we can re-introduce it later on.

NOTE: there's a lot going on here, because clang-format insist on
reformatting bunch of the DEFINE_TEST() instances :-\

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/246
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-20 22:27:37 -06:00
Emil Velikov
d75b9949aa testsuite/test-init: use distinct test names
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/246
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-20 22:27:37 -06:00
Emil Velikov
eb575e4c0f testsuite: run all tests, don't exit on first failure
Instead of exiting on the first failing test execute all tests and
report overall failure as needed.

This gives us a better overview - which do we have single failure or
multiple instances need work - and more consistent results numbers.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/246
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-20 22:27:37 -06:00
Emil Velikov
49e54bf2ad testsuite: use exitcode 77 for skipped tests
Using 77 is a de-facto standard for skipped tests that both autotools
and meson support OOTB. Use that instead of EXIT_SUCCESS aka 0.

Semi-recently we removed the only skip = true tests, although with more
tests incoming we're need bound to have a few users.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/246
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-20 22:27:37 -06:00
Emil Velikov
a76afe12ab testsuite/modprobe: Simplify modprobe exec
Too much copy and paste for simple exec tests. Just provide an
EXEC_MODPROBE macro to help.

Hats off to Lucas for the initial idea and porting the depmod test.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/246
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-20 22:27:37 -06:00
Lucas De Marchi
ec3baed9f9 testsuite: Test depmod with relative -m
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/243
2024-11-20 22:25:30 -06:00
Lucas De Marchi
d8b2455f40 testsuite: Simplify defines for depmod -m test
Simplify the defines so it's easier to extend the test for another
directory.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/243
2024-11-20 22:25:30 -06:00
Lucas De Marchi
0fd93e6317 testsuite/depmod: Simplify depmod exec
Too much copy and paste for simple exec tests. Just provide an
EXEC_DEPMOD macro to help.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/243
2024-11-20 22:25:30 -06:00
Lucas De Marchi
babcee5c12 testsuite/depmod: Remove bogus rootfs from test
The testsuite rootfs shouldn't be part of the argument.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/243
2024-11-20 22:25:30 -06:00
Lucas De Marchi
c6b4652dd9 Remove scratchbuf implementation
All its unique features have been ported to strbuf and users converted.
Nuke it.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/239
2024-11-17 15:35:14 -06:00
Lucas De Marchi
14ce34d755 strbuf: Add strbuf_shrink_to()
Useful when working with paths on a loop and resetting to a base path
component on every loop iteration.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/239
2024-11-17 15:35:13 -06:00
Lucas De Marchi
5706fb7d61 strbuf: Add strbuf_used()
So users don't feel tempted to look at inside the strbuf. Just add a
function for it and proper tests.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/239
2024-11-17 15:35:13 -06:00
Lucas De Marchi
68c0b9fb8c strbuf: Add strbuf_pushmem()
Wrapper for memcpy(). It's similar to strbuf_pushchars(), but push any
char, including the NUL byte, relying on the size passed as argument.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/239
2024-11-17 15:35:13 -06:00
Lucas De Marchi
952bf223e0 strbuf: Add strbuf_reserve_extra()
To accomplish the same task as scratchbuf_alloc() does: make sure the
buffer has enough space for next operations. One difference is that
ensures **extra** space, not the total space. If needed in future,
a strbuf_reserve(), that resembles C++'s std::vector::reserve(), can be
added on top.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/239
2024-11-17 15:35:13 -06:00
Lucas De Marchi
1e36bfada5 strbuf: Allow to start with stack space
This is the main functionality of the scratchbuf implementation: it
starts with a buffer on stack that covers most of the calls, but also
has a fallback to allocate the buffer if it grows beyond the initial
size.

Port that functionality from scratchbuf to strbuf, so the former can be
eventually removed.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/239
2024-11-17 15:35:13 -06:00
Lucas De Marchi
25f2b2e096 strbuf: Invalidate (only) when stolen
The main for strbuf_steal() to free() on error was to allow the caller
to pass the NULL up the stack with just a return call to
strbuf_steal().

However this is error-prone and surprising that the buffer is still
invalidated on error. Provide an strbuf cleanup attribute that can be
used for the same purpose and make sure that when the string is stolen,
it's set to NULL, so there's no dangling pointer around.

Since we run the  testsuite with AddressSanitizer, a simple test can be
added to make sure the stolen string becomes valid when the attribute is
used.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/239
2024-11-17 15:35:13 -06:00
Lucas De Marchi
b8776806de strbuf: Document strbuf_popchar(s)
Document the behavior for these functions and also clarify why the
testsuite can check the buffer for equality after calling strbuf_str().

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/239
2024-11-17 15:35:13 -06:00
Tobias Stoeckmann
ebd0476972 libkmod: Release memory on error paths
Do not override pointers to first list nodes if appending failed,
otherwise it's impossible to release already existing nodes of these
lists afterwards.

Remove the now unused function kmod_list_remove_n_latest as well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/228
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 12:59:45 -06:00
Emil Velikov
a076809c96 meson: undefine NDEBUG in the tests
When using -D b_ndebug=true or inheriting CFLAGS="-DNDEBUG" from the
environment, the asserts will be no-op thus the checks in the
LD_PRELOADED libraries will be omitted.

Explicitly undefine the macro, so we don't accidentally shoot ourselves
in the foot.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/238
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-11 18:22:01 -06:00
Emil Velikov
ebbca1c240 Revert "testsuite/path: match the full rootpath"
This reverts commit ae0c0c4c89.

The commit reasoning was correct, but did not consider the case where
other third-party files are created. Namely: when generating the code
coverage files.

Thus the gcna files were created in $test_rootdir/$abs_top_builddir
which meant they won't get picked when the coverage info/xml/html files
were created and the statistics reported were quite wrong.

Revert the commit and add an inline comment, so we don't feel tempted to
change it in the future.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/229
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-08 11:51:52 -06:00
Emil Velikov
8d409560e5 meson: switch to / operator instead of join_paths()
The former was introduced with meson v0.49.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/209
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-24 17:46:25 -05:00
Tobias Stoeckmann
25ab561bd5 libkmod: Use ELF offsets more often
Returned pointers are converted back to offsets in some functions. It is
more readable to turn offsets into pointers though.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-22 12:02:56 -05:00
Emil Velikov
b85b2a0ee3 testsuite: update "make rootfs" error message
We have added meson recently, with the goal to remove the make/autotools
one in a release or two. Update the reference to the meson equivalent.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/172
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-18 13:28:23 -05:00
Emil Velikov
b13b6fe70b testsuite/README: update for meson, mention sanitizers
Mention that running outside of `meson test", one needs to set the env.
aka "source scripts/sanitizer-env.sh".

Also gently discourage using sanitizers alongside gdb and strace. While
thing might work it's not the setup we want to support, I think.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/172
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-18 13:28:18 -05:00
Emil Velikov
0b3c45e5c9 scripts/test-wrapper.sh: convert to sanitizer-env.sh
Convert the existing wrapper script, into one that we source to set the
environment aka LD_PRELOAD.

Thus a developer can, use/test/debug the tests without using meson.
Namely:
 - source scripts/sanitizer-env.sh
 - build/testsuite/test-depmod

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/172
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-18 13:22:11 -05:00
Emil Velikov
e16d92b429 Swap rsync for cp --archive for module sources copying
As Tobias reported, rsync is a bit of heavyweight dependency. We
introduced it, as a replacement for the rm/cp -r previously used.

The rsync was inspired since, unlike make, meson will build all the test
binaries/artefacts even without calling "meson test".

We can go back to cp with --archive (--preserve=timestamps at least),
which will ensure we don't get stale files. To ensure the second run
doesn't copy the source folder as _subfolder_ of the dest we need to
wildcard the copy... Plus we need a proper destination folder in the
first place.

With this, we get a no-op second+ builds - be that with meson or make.
Since the explicit always-dirty state is by design, drop the meson TODO
and document the output variable.

Confirmed by comparing both the `make --debug` output and the execution
times.

Reported-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/192
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-17 16:57:43 -05:00
Emil Velikov
b07527e85f testsuite: preserve the existing LD_PRELOAD
In order for the sanitisers to work correctly, we need to LD_PRELOAD the
sanitizer shared library.

So drop the explicit unset(LD_PRELOAD) and instead prepend the existing
value to the LD_PRELOAD path that we construct.

Const annotate the other LD_PRELOAD instance, while we're here.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/179
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-17 08:35:10 -05:00
Emil Velikov
5798e18844 Move sanitizer details into a test wrapper
We want the meson test target to be self contained and having an
essential variables defined in the GitHub CI is heading the opposite
direction.

Create a wrapper that does this for us.

v2:
 - add the script to the autotools tarball/EXTRA_DIST

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/179
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-17 08:35:10 -05:00
Emil Velikov
7eba0cd2cb shared: introduce umul{32,64}_overflow() helpers
We'll use them to implement the size_t variant.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/169
[ Fixup commit message for renamed functions ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-15 12:42:56 -05:00
Emil Velikov
8808f0eeaa shared: introduce uadd32_overflow() helper
We'll use it in the upcoming size_t variant.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/169
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-15 12:35:38 -05:00
Emil Velikov
b9019723bd shared: s/addu64_overflow/uadd64_overflow/g
Rename the helper closer to the actual built-in.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/169
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-15 12:35:38 -05:00
Emil Velikov
097b2c6413 testsuite/test-strbuf: use const char * for strbuf_str()
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/174
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-15 09:30:59 -05:00
Tobias Stoeckmann
7805c95fbe shared: Fix EOF handling in freadline_wrapped
If a file ends with a backslash without a newline, freadline_wrapped
adds EOF to the actual string.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/159
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-27 23:17:38 -05:00
Tobias Stoeckmann
82062d275d testsuite: Fix test-weakdep with autoconf defaults
If ./configure is run without any further options, then /usr/etc
is used as SYSCONFDIR, which breaks test-weakdep, because the
/etc path is hardcoded in it.

Use SYSCONFDIR to reflect the actual rootfs setup.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/157
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-27 23:14:04 -05:00
Tobias Stoeckmann
884454eae5 testsuite: Adjust README
The populate-modules.sh does no longer exist. Also mention that the
script setup-rootfs.sh is in use for test suite setups.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/157
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-27 23:14:04 -05:00
Emil Velikov
4c760f7edd testsuite: mass convert with clang-format
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/118
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-24 09:59:20 -05:00
Tobias Stoeckmann
fb2205805d testsuite: add builtin test for modinfo
The modinfo command can show information about builtin modules. Make
sure that it functions correctly.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/136
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-23 08:29:30 -05:00
Emil Velikov
a49a96bdf0 testsuite: sort modnames only, if available
In some tests we expect zero modules to be loaded. In those cases, skip
the sorting - qsort is annotated as non-null(1,2) so we shouldn't
provide null as expected/loaded modules.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/144
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-22 17:35:37 -05:00
Emil Velikov
3091dc72bc testsuite/list: resolve memory leaks
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/143
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-21 11:06:24 -05:00
Tobias Stoeckmann
6eef551997 testsuite: Fix init_module
Apply same logic as in delete_module.c, i.e. pass a reference to a
pointer instead of the pointer value, otherwise we cannot update
the linked list and added entries are lost.

Spotted with ASAN while running testsuite.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/141
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-21 10:51:01 -05:00
Emil Velikov
0766f54192 build: check for __xstat declarations
Currently we check the function is resolved at link time. Although what
we really care is if the headers are silently transposing any of our stat
calls to __xstat{,64}. If so, we'd want to wrap the latter functions.

As the now-removed comment says, glibc 2.33 was the first release to no
longer have static inline wrappers that do the transposition. See the
glibc commit 8ed005daf0ab ("Remove stat wrapper functions, move them to
exported symbols") for more details.

So change the checking to check_decl/has_header_symbol and keep them for
distributions with older glibc.

NOTE: to summarise/contrast this wrt the previous open64, etc
 - here: we had inline wrappers and declarations (as below)
 - others: no inline wrappers and optionally declarations

glibc 2.32
extern ... __xstat(); extern inline stat(...) { return __xstat(...); }

glibc 2.33
extern stat(...);

Note we group the 64 variant as well, since the codepath has been
identical (wrt core logic) to the normal __xstat().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-16 22:01:35 -05:00
Emil Velikov
7c810bc191 build: check properly for __stat64_time64
Having learned from prior LFS64 experience the glibc developers have
implemented stat in (albeit varying but) neater way:

 - declaration with asm linkage to __stat64_time64
 - or, `#define stat __stat64_time64`
 - or, `#define stat stat64; #define stat64 __stat64_time64`

In all cases __stat64_time64 lacks an explicit declaration, unlike
open64, stat64, fopen64 mentioned earlier.

Since we lack declaration, we have no other option but to check if a
program with reference to __stat64_time64 can link, so we use the
check/has function.

For more details glibc commit aa03f722f3 ("linux: Add {f}stat{at} y2038
support") added internal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-16 22:01:34 -05:00
Emil Velikov
62c97004f6 testsuite/path: s/__stat64_t64/void/
The exact struct varies across the build-options, but in practise is
never __stat64_t64 - this is the internal name used within glibc.

When the fstat declaration with __fstat64_time64 asm linkage is used, we
have "struct stat". Whenever the `#define stat __stat64_time64` kicks
in, both function and struct get redefined/renamed.

Since we don't care about it (apart from the pointer part) just use void.

For more details glibc commit aa03f722f3 ("linux: Add {f}stat{at} y2038
support") added internal.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-16 22:01:34 -05:00
Emil Velikov
33771fb453 build: check for open64, stat64 and fopen64
... and use behind the respective ifdef HAVE_FOO guards instead of the
HAVE_DECL___GLIBC__ currently.

Since day one, glibc has declarations for the functions, which was
forwarding the normal functions to them, via asm linkage, et al.
Aka `extern int open(....) asm_linkage("open64").

In addition, a lot of libraries have grown to depend on the declarations
being available and functions being statically exposed via libc.so.

Whereas musl pre 1.2.4 (circa 2023) have exposed the symbols
statically, without a declaration for well over a decade. Newer musl,
no longer expose the symbol in their runtime but have retained the
define trick, stating it will be removed in the future.

Looking at the bionic front things are somewhat similar. Newer bionic
(circa 2019) have a declaration and an inline wrapper open64 function
forwarding to open. Throughout 2019, open64 did forward to misc other
internal functions thought.

Older pre 2019 bionic had a declaration alongside plug exposing the
symbol statically in their C runtime.... since 2014. Not sure what they
did prior to 2014, it's a target out of scope for us.

Considering the above, the most robust approach is to do a check/has
function checking.

With that, we no longer need the __GLIBC__ guard for the respective
functions.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-16 22:01:34 -05:00
Emil Velikov
4928a9e61e testsuite: remove access() sub-test
Our test does access + stat, where stat is sufficient. In addition, the
kmod codebase never used access (afaict), so we're safe to remove the
access() part.

Alongside it we can drop the LD_PRELOAD wrapper.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-16 22:01:34 -05:00
Emil Velikov
d6b85d82d7 testsuite: remove *lstat* wrappers
The majority of these were initially introduced with commit 123e827
("testsuite preload: Factorize into macros, add more stat and open
variants").

The commit itself was meant to refactor existing wrappers and add new
_xstat (aka stat) variants. The lstat variants were never used in kmod
directly nor indirectly via header macros.

The rest were added to mimic the original, without much testing it
seems.

They are all dead code - remove them.

In theory one could have a macro/helper that calls `lstat` for `stat`
itself, although that isn't a practical solution for a few reasons.

The functionality across the two varies, where if the path provided is
a symlink `stat` follows it, while `lstat` gets the details for the link
itself. To fix this, the wrapper would need second syscall to resolve
the symlink, which will cause notable performance regression wrt using
using the `stat`/`stat64` syscall alone.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/131
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-16 22:01:34 -05:00
Lucas De Marchi
aa9f6d89e7 build: Fix KDIR again
KDIR is not related to the what we configure in kmod's build. It's only
used in kmod to locate where the distro's kernel source/headers is,
which may be different from what we are configuring the (under
development) kmod with.

Remove the setting from meson/autotools and figure it out inside the
module-playground Makefile what should be used. For advanced use cases,
KDIR= can be passed to override the location.

For our own tests, which includes testing with a different module_directory,
scripts/setup-rootfs.sh will copy the module to the desired location
according to the map defined in the script.

Fixes: 27ff727326 ("testsuite: correct the default KDIR")
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/125
2024-09-11 14:39:10 -05:00
Lucas De Marchi
aa7130edaf testsuite: Test depmod's -m flag
Link: https://github.com/kmod-project/kmod/pull/100
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-10 13:25:46 -05:00
Lucas De Marchi
f6cffbbc26 meson: Move symlinks up
Currently it's only possible to test the tools by using the symlink.
However, differently from autotools, the symlink is created inside the
testsuite dir, and only if build-tests=true. Move it to the same
directory that kmod is so it's possible to test without the testsuite.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/120
2024-09-09 08:53:48 -05:00
Emil Velikov
ed8de70742 testsuite: use size_t with strbuf
We recently updated the API, but forgot to update the tests.

Fixes: 38943b2 ("shared: use size_t for strbuf")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/115
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-08 23:50:08 -05:00