Commit Graph

45 Commits

Author SHA1 Message Date
Emil Velikov efc2e4b467 treewide: add some static const notations
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-09 07:15:56 -08:00
Lucas De Marchi 5622f1dae1 util: Add time-related functions from testsuite
This will be useful in future not only to testsuite, but also to tools
and library.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2022-06-26 23:23:46 -07:00
Marius Bakke b5683f45d9 testsuite: Add facility to skip tests.
The Makefile helpfully warns that some tests will fail when
--sysconfdir != /etc, but there are no provisions to easily disable
those.  This commit provides an escape hatch.

[ Lucas: add comment detailing the purpose of the field ]
2021-01-07 19:44:20 -08:00
Yauheni Kaliuta ea37a74246 testsuite: factor out fd related parameters to a structure
This is a more abstract implementation of "file descriptor
comparation". With the current implementation the code is full of
conditions based on the descriptor type. It makes sense to
initialize the parameters once based on the descriptor type.

stdout and stderr are handled in almost the same way, but for
monitor descriptor branch, based on the type check is necessary in
some cases.

Since epoll's context now contains pointers to the structures, so no
direct manipulations there.

Most of the patch is just replacing direct buffer manipulations with
the structures' ones.

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
2019-01-04 14:39:39 -08:00
Yauheni Kaliuta b7cd0fdab0 testsuite: track number of descriptors instead of their state
use the number of tracked descriptors to determine the end of the
loop.

This is a preparation for more abstract descriptor comparation
implementation where checking of the descriptor state may be more
expensive than just checking of the local variables.

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
2019-01-04 14:39:39 -08:00
Lucas De Marchi c0937526b2 testsuite: add support for testing output against regex
Allow to test outputs when they don't match exactly, but should follow
some regex patterns. This can be used when the info we are printing is
randomized or depends on kernel configuration.
2019-01-03 12:43:18 -08:00
Lucas De Marchi a5cc3521d8 testsuite: split out function to compare outputs exactly
Move functionality to compare the exact output to a separate function
and allocate one buffer per output/match pair. This will allow us to
extend this to allow other types of comparisons. Since now we are using
heap-allocated buffer, keep the buffer allocation to the caller, so we
don't have to allocate and free it on every invocation. It also avoids
the different comparison functions to have to deal with it.
2019-01-03 12:03:27 -08:00
Lucas De Marchi f6dc239ed2 testsuite: add option to copy output from test
This is helpful while debugging the tests: copy the output from test
(both stdout and stderr) to the stdout of the parent process.
2015-02-21 13:39:36 -02:00
Lucas De Marchi 03a5079f62 testsuite: fix exiting with success on no output activity
If we were expecting output on stdout or stderr but the test didn't
produce any, we were incorrectly assuming the test was successful.
Now test on exit if there was activity on the monitored fd. If there
was, check also if the file size to check for output is > 0 for the
cases in which we want to assert there was no activity on certain fd.
2015-02-21 13:15:38 -02:00
Lucas De Marchi 5c42c5fced testsuite: prefer the use of streq() 2015-01-14 14:32:09 -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 c5798fea93 testsuite: use a section to put tests in instead of array
Intead of having to declare an array of tests, tweak the definition of
DEFINE_TEST and TESTSUITE_MAIN so they know the tests are put in a
particular section of the ELF file.

This avoids the mistake of adding a test and forgetting to add it to the
array. Now once a test is defined, it's ready to run, so one less step
to define new tests.

The removal of the arrays is left for another patch so not to clutter
the diff on this one.
2014-10-09 14:17:24 -03:00
Lucas De Marchi f4e8c16291 Move remaining functions from libkmod-util to shared 2014-10-09 01:26:39 -03: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 96573a0220 Move generic util functions to shared directory 2014-10-03 00:33:25 -03:00
Lucas De Marchi f988e25c68 testsuite: separate testcases on log 2014-06-05 17:54:41 -03:00
Lucas De Marchi d7293a1628 testsuite: Fix expected_fail parsing
If a test has expected_fail=true, it means the return code must be
different from 0 *and* the outputs must match. This way it's possible to
check if the error messages are printed as they should.
2014-05-30 10:23:05 -03:00
Lucas De Marchi f429113a47 testsuite: Add braces 2014-05-30 10:20:19 -03:00
Michal Marek 88ac40840f testsuite: Check the list of loaded modules after a test
Add a ->modules_loaded member to struct test, which is a comma-separated
list of modules that should be present after the test finishes. Both
missing and excess modules cause an error.
2014-03-05 12:22:37 -03:00
John Spencer bd4e7340bc testsuite: fix usage of reserved names
stdout and stderr are names reserved for the implementation
and musl uses them rightfully as macro - and the expansion
causes (of course) unexpected results.

rename the struct members stdout to out and stderr
to err, to be 1) compliant 2) cause compilation to
succeed.

fixes build with musl libc.
2013-08-29 01:22:20 -03:00
Lucas De Marchi 2ad09ccf0f testsuite: errno is a positive number 2013-04-12 01:24:30 -03:00
Lucas De Marchi 489c04ddec testsuite: Exit with success on signal if test has expected_fail=true 2013-03-21 02:22:15 -03:00
Lucas De Marchi e6b0e49b4e Update copyright notices 2013-01-16 11:27:45 -02:00
Lucas De Marchi 3e451bfefb testsuite: allow to check generated files
This gives the test cases the ability to supply files that must be
checked after the test is run, rather than just checking stdout/stderr.

This is intended to be used with tools that generate files, like depmod.
It includes a poor's man implementation of a "check for differences in
files". Not really optimized, but it's simple enough and does what it
proposes to.
2012-10-04 01:04:52 -03:00
Lucas De Marchi e1b1ab24ab testsuite: re-license under LGPL 2012-07-10 10:31:57 -03:00
Lucas De Marchi 34db3f2d3e testsuite: allow to export custom env vars 2012-06-06 01:45:30 -03:00
Lucas De Marchi b8e344a6d2 testsuite: add timeout for each test
Each test must run under 2 seconds. Ideally they should run in much less
than this; just give an arbitrary number so we don't wait forever in
case we reached an infinite loop somewhere.
2012-06-06 01:45:30 -03:00
Lucas De Marchi ed8e93fd92 testsuite: create additional pipe to monitor child 2012-06-06 01:45:30 -03:00
Lucas De Marchi 0de690c96c testsuite: check if rootfs dir is dirty before running
Keep around a stamp-rootfs file that is generated together with the
rootfs. testsuite checks each test directory if its mtime is greater
than stamp's mtime, deciding if rootfs should be re-generated.
2012-06-05 00:54:47 -03:00
Lucas De Marchi 050db08c57 Add missing newlines
Checked with following semantic patch for the library:

// smpl
@a@
identifier virtual.func;
expression E1;
expression fmt;
position p1;
@@

func(E1, fmt@p1, ...)

@script:python b@
fmt << a.fmt;
p1 << a.p1;
@@

s = str(fmt)
if s.find("\\n") < 0:
	print p1[0].file + ":" + p1[0].line

// smpl

For tools, just remove E1
2012-02-18 03:56:21 -02:00
Lucas De Marchi 658e0471b3 testsuite: fix color of unexpected failure 2012-02-16 21:18:00 -02:00
Dave Reisner f31d49c8b3 testsuite: add .path member to test struct
This allows us to prepend an arbitrary item to the PATH environment
variable, meaning we can favor the binaries we just built, rather than
relying on those in the filesystem.
2012-02-16 16:52:38 -02:00
Dave Reisner fa0046ba83 testsuite: allow for expected failure of tests
Adds a bool to the test struct called 'expected_fail' which can be set
to flip the logic used to determine success and failure. Messaging is
also changed to reflect an unexpected pass or expected fail. This can be
used to write tests which may represent functionality desirable for a
future release.
2012-01-31 14:08:57 -02:00
Lucas De Marchi e701e381fa testsuite: add GPL license 2012-01-26 17:02:05 -02:00
Lucas De Marchi f6ef5d6b5f testsuite: trap calls to delete_module() including simple test 2012-01-26 16:14:18 -02:00
Lucas De Marchi d2c2b8b500 build-sys: autotoolify build of check libraries
Many thanks to Iván Briano (sachieru@gmail.com) for pointing out this
thread in libtool mailing list:
	http://www.mail-archive.com/libtool@gnu.org/msg09627.html

Passing '-rpath /nowhere' in LDFLAGS we are able to create shared libs
that are not installed.
2012-01-26 16:05:05 -02:00
Lucas De Marchi 53646fc56f testsuite: add trap to init_module() including simple test 2012-01-26 16:05:05 -02:00
Lucas De Marchi 9e3b9d2e8c testsuite: remind users to build tools 2012-01-26 16:05:05 -02:00
Lucas De Marchi 51b1d1ab28 testsuite: add colors to test output 2012-01-26 16:05:05 -02:00
Lucas De Marchi 3dbb8dea5f testsuite: match outputs of test with a known correct one
Tests may put the correct output in a file and tell testsuite to check
if it matches the output from the test running.

Testsuite compares the outputs while running the test: it creates a pipe
between parent and child; parent reads both stdout and stderr from child
and compares with the correct output.
2012-01-26 16:05:05 -02:00
Lucas De Marchi 45481ee28c testsuite: separate child from parent 2012-01-26 16:05:04 -02:00
Lucas De Marchi 6b88ef3e97 testsuite: allow to run tests outside of top_buildir
In order to locate where the shared libs to be preloaded are we need to
reference them using abs_top_buildir. Otherwise we are limited to
running tests from there.
2012-01-26 16:05:04 -02:00
Lucas De Marchi 395478cbbb testsuite: export environment with flags and LD_PRELOAD
A certain config can add flags and each flag may be associated with a
lib to LD_PRELOAD. It's now done for uname(2), which requires uname.so
in order to trap the calls.

Other trap will be added in later commits.
2012-01-26 16:05:04 -02:00
Lucas De Marchi ed2df4e984 testsuite: move oneshot to inside the test struct 2012-01-26 16:05:04 -02:00
Lucas De Marchi 80f9e02382 testsuite: add skeleton 2012-01-26 16:05:04 -02:00