Commit Graph

20 Commits

Author SHA1 Message Date
Emil Velikov 6661e5970a testsuite: add function declarations for __xstat family
As the inline comment says - the declarations have been dropped with
glibc 2.32.9000, as a result the build throws a set of lovely warnings.

Inspired by umockdev, which bears the same license as this project.
f1b4164004

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-09 07:16:06 -08:00
Gustavo Sousa e54f74c4f7 testsuite: Wrap chdir()
One of the tests in an upcoming patch will need to change into a
specific directory to test loading a module from a relative path.

Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-01-13 16:48:02 -08:00
Julien Cristau b4d281f962 testsuite: fix override of `stat` on 32-bit architectures
When _FILE_OFFSET_BITS is 64, glibc headers turn `stat` calls into
`stat64`, and our `stat` override into a `stat64` function.  However,
because we use dlsym to get the address of libc's `stat`, we end up
calling into the "real" `stat` function, which deals with 32-bit off_t,
and we treat its result as if it were returned from stat64.  On most
architectures this seems to have been harmless, but on 32-bit mips,
st_mode's offset in struct stat and struct stat64 are different, so we
read garbage.

To fix this, explicitly unset _FILE_OFFSET_BITS in path.c, to turn off
the redirect magic in glibc headers, and override both the 32-bit and
64-bit functions so each call ends up wrapping the right libc function.

Fixes #16 (https://github.com/kmod-project/kmod/issues/16)
2022-09-05 13:35:09 -07:00
Lucas De Marchi 8ff7f008cd testsuite: do not overrid paths inside build
If we are accessing a file inside the build directory we should really
not trap the path. Right now this isn't important because we never do
such accesses. However it will be needed when gcov is integrated because
it dumps files to the same place where the binaries are located.
2015-01-07 19:14:20 -02:00
Lucas De Marchi dea2dfee9b Remove FSF mailing address
It has changed in the past, and these days, anyone can get a copy of the
LGPL via the web rather than by post.

Like 657a122 (Remove FSF mailing address) in libabc by Josh Tripplet,
but let the FSF website in which the license can be found.
2014-12-25 23:41:34 -02:00
Lucas De Marchi c2e4286bb9 Reorder and reorganize header files
Let the includes in the following order:

< system headers >
< libkmod >
< tool >
< local headers >
2014-10-03 01:43:15 -03:00
Lucas De Marchi e6b0e49b4e Update copyright notices 2013-01-16 11:27:45 -02:00
Lucas De Marchi d642341777 testsuite: Fix double definition of 64-bits variant
If _FILE_OFFSET_BITS is defined we should not be wrapping these 64
variants, since they are macros in libc.
2012-09-07 15:12:12 -03:00
Martin Pitt 123e8278ed testsuite preload: Factorize into macros, add more stat and open variants
Instead of replicating the same code several times, define and use macros for
the various types of wrapped functions in the testsuite's path.c LD_PRELOAD
wrapper.

Add various __xstat() variants and open64(), which are being used when enabling
large file support.
2012-08-01 20:44:27 -03:00
Lucas De Marchi e1b1ab24ab testsuite: re-license under LGPL 2012-07-10 10:31:57 -03:00
Martin Pitt 4281cee076 testsuite: path wrapper: Fix open() with 3 arguments
Properly return the original libc return value in the case that open() is
called with 3 arguments.
2012-07-10 10:31:40 -03:00
Lucas De Marchi 113d0084d4 testsuite: trap calls to mkdir 2012-06-05 00:54:47 -03:00
Wouter van Kesteren f6301b65bd Fix path.c's function pointer defenitions.
int isn't big enough to hold a FILE* / DIR* on some systems, this causes
segfaults in calls that try to use the resulting FILE* / DIR*:

  TESTSUITE: ERR: 'testsuite_rootfs_fopen' [1176160] terminated by signal 11 (Segmentation fault)
  TESTSUITE: ERR: FAILED: testsuite_rootfs_fopen
  FAIL: testsuite/test-testsuite
  ...
  TESTSUITE: ERR: 'loaded_1' [1176166] terminated by signal 11 (Segmentation fault)
  TESTSUITE: ERR: FAILED: loaded_1
  FAIL: testsuite/test-loaded
  ...
  TESTSUITE: ERR: 'from_alias' [1176181] terminated by signal 11 (Segmentation fault)
  TESTSUITE: ERR: FAILED: from_alias
  FAIL: testsuite/test-new-module

For reference on my system:

  sizeof(int) = 4
  sizeof(long) = 8
  sizeof(FILE*) = 8
  sizeof(DIR*) = 8
2012-02-16 14:37:32 -02:00
Lucas De Marchi d005aeb752 Check if libc has __xstat
uClibc doesn't use __xstat. Check if it exists, otherwise don't export
the override function.
2012-02-08 20:29:52 -02:00
Lucas De Marchi 81e8b8042a testsuite: let stat.h take care of stat64
This fixes testsuite build in 32 bits machines.
2012-01-30 13:51:58 -02:00
Lucas De Marchi e701e381fa testsuite: add GPL license 2012-01-26 17:02:05 -02:00
Lucas De Marchi 4e36cb18e1 testsuite: add trap to opendir() including tests 2012-01-26 16:05:04 -02:00
Lucas De Marchi 1426a613fa testsuite: add trap to stat() and friends including tests
Add trap to stat(): we need to trap other functions too, depending on
stat.h, the function from glibc that is actually called may be stat64 or
__xstat() too.
2012-01-26 16:05:04 -02:00
Lucas De Marchi 7fa8c2d2df testsuite: add trap to open() including tests 2012-01-26 16:05:04 -02:00
Lucas De Marchi 6afc9cd616 testsuite: add trap to fopen() including tests 2012-01-26 16:05:04 -02:00