History log of /external/ltp/lib/tst_test.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
fecdd885eb4b93d433732adec00327c7ecd59562 17-Jan-2018 Cyril Hrubis <chrubis@suse.cz> tst_test: Fix exit value on tst_brk(TCONF, ...)

We decided not to propagate TCONF into the test exit value in a case
that the test had at least one TPASS in:

commit 5390d6ea36578c1fac8adc416b6f91aa4a330a08
Author: Cyril Hrubis <chrubis@suse.cz>
Date: Thu Sep 7 15:47:22 2017 +0200

lib/tst_test: Report 0 if test has both TPASS and TCONF

However this commit missed a case when TCONF is passed directly to the
do_exit() function. This may happen in two cases actually, one of the is
tst_brk(TCONF, ...) called from a test and second one is more subtle and
happens when the last result in the run_tcases_per_fs() produces TCONF
which is then propagated to the do_exit() function.

This commit simply masks the TCONF from the exit value in this cases if
we happen to have non-zero success counter.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
cecbd0cb36d604e487e26348de7e91bdf87385ce 07-Nov-2017 Veronika Kabatova <vkabatov@redhat.com> Fix buffer overflow in print_result() function

From man page: "The functions snprintf() and vsnprintf() do not write
more than size bytes (including the terminating null byte ('\0')). If
the output was truncated due to this limit, then the return value is the
number of characters (excluding the terminating null byte) which would
have been written to the final string if enough space had been
available. Thus, a return value of `size` or more means that the output
was truncated."

The return value is not checked and blindly subtracted from available
space in the buffer which may cause negative values (which are then
converted to unsigned type size_t) in case the variables to print don't
fit into buffer. The pointer to buffer is also moved forward the same
amount, and writing into memory that is not allocated causes unexpected
failures of tests with segfaults.

This was discovered during rewriting of mtest06/mmap1 testcase to new
library where verbose output tried to print out memory contents longer
than space available in the buffer. The framework should be robust
enough to handle these situations.

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
35b8a1325ef3c5548cd8c354074c429359f57305 01-Sep-2017 Cyril Hrubis <chrubis@suse.cz> lib/tst_test: Add .all_filesystems flag

This commit adds a support for re-runing a test on all available
filesystems simply by turning on .all_filesystems flag in the tst_test
structure.

The .all_filesystems flag implies .needs_device, the .format_filesystem and
.mount_filesystem works as usuall but the device is formatted and mounted for
each filesystem before we run the test function. The .setup and .cleanup
functions are executed for each filesystem. The currently tested filesystem
type is stored in the tst_device->fs_type.

This allows us to easily run a test that tests filesystem specific
syscall for all supported filesystems without a need to hardcode all fs
types into a runtest file and with a minimal changes to the test code.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
b5d620aa9ece866cd264c5f05dbd8f19fc6fa8e8 01-Nov-2017 Li Wang <liwang@redhat.com> lib: keep the test id hidden in LTP library

To avoid introducing wrong tid's typos radically, this patch keep the tid
hidden in library by moving out '.tid' variable from the test struct.

Meanwhile, adding a newly string '.scall' to support LTP can get the correct
syscall name for timer management library.

Signed-off-by: Li Wang <liwang@redhat.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
f885348aa95974934220e9bda436d80fa83fa539 31-Oct-2017 Petr Vorel <pvorel@suse.cz> Fix spelling s/exitted/exited/

Signed-off-by: Petr Vorel <pvorel@suse.cz>
/external/ltp/lib/tst_test.c
2113eef151913224a7d41e54bb9db49b70a4d4e2 04-Oct-2017 Jan Stancek <jstancek@redhat.com> lib: allow checkpoints to be used by any uid

Allow unprivileged child to synchronize with privileged parent.
Use chmod after open, because effective permissions set by open()
are modified by the process's umask: (mode & ~umask).

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
d97168b0a7e99d0da25f8ba073dd36244449ce04 10-Oct-2017 Jan Stancek <jstancek@redhat.com> lib: drop tst_ipc_envp

There are no users left.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
b95b1994866067d37121e5e3fa8d314148bc1f52 10-Oct-2017 Jan Stancek <jstancek@redhat.com> lib: extend PATH as part of test setup

This patch adds "." and "startdir" to $PATH during setup, so that exec*p()
correctly finds child processes. And it also make it convenient to run some
tests directly from git tree.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
03fc5376a6f816dbd35d7042868bdfd293c41ce2 10-Oct-2017 Jan Stancek <jstancek@redhat.com> lib: add LTP_IPC_PATH to env. variables by default

Child started by exec() that needs to do tst_reinit() in order
to use checkpoints will inherit LTP_IPC_PATH by default.
Parent can choose to override/omit it in envp array when calling
exec[lvp]e().

Also fix couple places to use LTP_IPC_PATH define.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
9dc07e077975c7afc929dfdc3c56b400ccc7bc29 02-Oct-2017 Cyril Hrubis <chrubis@suse.cz> lib/tst_test: Do TBROK on unexpected arguments.

The argument parsing code in the test library ignored positional arguments and
that lead to:

commit 8501feeb89e8a47e7feacd80179d852c3810249c
Author: Sandeep Patil <sspatil@google.com>
Date: Fri Sep 22 15:59:41 2017 -0700

mm: mmapstress04: Remove arguments passed to the test.

Which removed leftover arguments from the testcase much later after the test
was rewritten. The correct behavior for the library is to issue TBROK on
unexpected command line parameters.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Petr Vorel <pvorel@suse.cz>
/external/ltp/lib/tst_test.c
c9a7def80792f94889f02aa263da50e76cff7abe 19-Sep-2017 Sandeep Patil <sspatil@google.com> libltp: add support to mount tmpfs for EROFS testing

Some tests go through losetup, create, format and mount filesystems only
to test for 'EROFS' return value from system calls. The tests end up
being flaky depending on the tools available on the platform. e.g.
mkfs.<filesystem> tool is required for mounting a device with
filesystem.

If the test is only to check for EROFS, this can be achieved by simply
mounting read-only tmpfs. We also get quite nice speed up (saves a few
seconds per testcases) as a side effect.

Example of tests that can benefit from this are:
access04, mkdirat02, mknodat02, acct01, fchown04, mknod07 etc.

This also allows for these tests to successfully run on Android.

Signed-off-by: Sandeep Patil <sspatil@google.com>
Tested-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
c20831d221fe7b4d9109fae4010a6c8a6d77f962 20-Sep-2017 Steve Muckle <smuckle.linux@gmail.com> lib/tst_test: avoid cleanup by cloned test threads

Some versions of glibc and bionic report the same PID for parent and
child when clone() is called with CLONE_VM but not CLONE_THREAD. This
can cause cleanup to be incorrectly run by the child.

Avoid this by using a direct syscall for getpid when running the
cleanup.

Signed-off-by: Steve Muckle <smuckle.linux@gmail.com>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
5390d6ea36578c1fac8adc416b6f91aa4a330a08 07-Sep-2017 Cyril Hrubis <chrubis@suse.cz> lib/tst_test: Report 0 if test has both TPASS and TCONF

It's probably a bit more logical to report a succes if only part of the
test was skipped and the rest was sucessful. That way we can distinguish
tests that were compiled-out completely or where the kernel does not
support the particular syscall at all. The difference is about 15
testcases that report TPASS instead of TCONF after this change.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
f706a2f7d2b191b362eceb16bd19909d8dc4788b 01-Aug-2017 Cyril Hrubis <chrubis@suse.cz> lib/tst_test: Ignore unknown options for TCONF tests

The problem is that with TST_TEST_TCONF() the optional test options are
not propagated in the tst_test structure. As a matter of fact the test
library had no idea that the test was compiled out, which had to be
changed as well.

So this commit adds a string pointer to the tst_test structure, that if
set, causes the test library to ignore unknown options and exits the
test, as fast as possible, with a TCONF.

This fixes cases where a test was compiled out but the runtest file
passes some tests specific options which previously failed the test with
TBROK.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
94823cfac241653aeed02efa660fe349b47671bc 18-Jul-2017 Li Wang <liwang@redhat.com> mem/oom: disable timeouts for testcase in demand

OOM testcases runtime depends heavily on amount of RAM+Swap and kernel
version, it's hard to figure out cap on a runtime.

Hence this patch changes the test library API so that setting timeout to
-1 disables it.

Signed-off-by: Li Wang <liwang@redhat.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
9726b909d79ba9477c07608bd7f0b93684e07aab 27-Jul-2017 Cyril Hrubis <chrubis@suse.cz> lib/tst_test.c: Do not cleanup_ipc() if uninitialized

We do attempt to cleanup the IPC even if the setup_ipc() function was
not called. That happens if the tst_test structure has missing test
function, if the test needs root and is executed as an user, etc.

We wrongly call msync() and munmap() on a NULL pointer in this case,
while this is mostly harmless it's also wrong, so this commit fixes the
cleanup functions to check if the shm_path and the shm pointer were
initialized before we attempt to remove them.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
88c220d0928e8810b23e3892975266449a9a87f3 27-Jul-2017 Cyril Hrubis <chrubis@suse.cz> lib/tst_test.c: Move parse_opts() up

Move parse_opts() before check for root, minimal kernel version, etc. So
that -h works regardless of the restrictions for test execution.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
c459654db64cd29177a382ab178fdd5ad59664e4 20-Jun-2017 Cyril Hrubis <chrubis@suse.cz> syscalls: Add timer measurement library

This commit adds a timer measurement library, mostly based on changes
done to the pselect01.c test and changes all tests that measure timer
precision to use it.

The timer testcases that measure timeouts now just define sampling function and
optional setup and cleanup. The rest of the functionality is implemented in the
lib/tst_timer_test.c library. This change not only removes fair amount of
duplicated code but also allows us to tune thresholds and define testcases in a
single place for all testcases.

The timer measurement library also supports for passing sleep time and
number of iterations as a command-line parameters, can print nifty
frequency plot into the terminal, as well as save test measurements into
a text file.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
a5bf5254ca94e0164af76d409224ea0764632d22 14-Mar-2017 Cyril Hrubis <chrubis@suse.cz> tst_test.c: set the test id automatically

Use the argv[0] to set the tst_test->tid automatically since we fail to
update it commonly and we end up with wrong tid due to copy&paste.

Now it's initialized in the test setup based on argv[0]. If argv[0] is a
path we take last element in it.

This patch is based on v1 by Li Wang but I've omitted moving the
parse_opts() up in the setup() since the setup() function expects
that tst_test sturcture is non-NULL and may segfault if that is not
true.

Signed-off-by: Li Wang <liwang@redhat.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Petr Vorel <pvorel@suse.cz>
/external/ltp/lib/tst_test.c
791631757b3af40d2522aad53b653e7036fe28ef 18-May-2017 Cyril Hrubis <chrubis@suse.cz> tst_test: Be more verbose on timeout

I've recently stumbled upon a test that caused deadlock in the kernel
and the test processes could not be killed because of that. This was
while testing fanotify07 testcase on unpatched kernel.

In that case the test library just slept in the waitpid() call forever without
producing any output. That was since the alarm handler that sends the SIGKILL
to the test processes has fired but the processes stayed alive due to the
kernel bug.

This patch makes this situation more verbose we:

* Print a message that we are about to kill the test process once it has
timeouted so that the user knows that something unexpected is
happening

* We retry 10 times with 5 second delay between tries

* And finally if we are out of retries and if the test processes are
stil alive we congratulate user on hitting a kernel bug and exit
uncleanly with TFAIL

Example test output:

$ ./fanotify07
tst_test.c:862: INFO: Timeout per run is 0h 05m 00s
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Test timeouted, sending SIGKILL!
Cannot kill test processes!
Congratulation, likely test hit a kernel bug.
Exitting uncleanly...
$ echo $?
1

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
3a0ef86ac1449ba6fd938c44e28e6e48bbda408c 01-Mar-2017 Petr Vorel <pvorel@suse.cz> color: Rename file

Use singular (to be consistent with shell).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
874326dbb2bc575fea16a4ece86ddf1bca826bf2 14-Feb-2017 Cyril Hrubis <chrubis@suse.cz> tst_test: Handle device mkfs/mount int the library

This commit adds functionality to format and then mount the test device
to the test library which:

* Saves a few setup steps in most of the testcases that use test device

* The device is umounted in the test library process now -> it will be
umounted even if the test process has segfaulted.

+ docs

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
6440c5d0d1509a28c8d48b5ab3fd9d707f3ec36f 09-Feb-2017 Cyril Hrubis <chrubis@suse.cz> newlib: Allow SAFE_MACROS to be called from cleanup

Which is done by:

* Dropping attribute ((noreturn)) from all tst_brk_() definitions so
that the function could actually return in case it's called from
cleanup. This patch also fixes a few warnings caused by the change.

* Adding brk handler to tst_test.c so that we can temporarily replace
the tst_brk_() function with function that maps TBROK to TWARN and
calls tst_vres_().

+ updated test-writing-guidelines

+ testcase

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
160ffcc944eb08ac03a5e05e6549362c103f3b95 14-Feb-2017 Cyril Hrubis <chrubis@suse.cz> tst_test: Fix unused variable warnings

I've forgotten to remove file and line parameters passed to
update_results() in:

commit d97debf386c327285a09fb4794f313d330d823cc
Author: Cyril Hrubis <chrubis@suse.cz>
Date: Mon Feb 13 12:37:39 2017 +0100

tst_test: Allow using tst_res and tst_brk without initialized IPC

Sorry everyone.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
d97debf386c327285a09fb4794f313d330d823cc 13-Feb-2017 Cyril Hrubis <chrubis@suse.cz> tst_test: Allow using tst_res and tst_brk without initialized IPC

If we try to print TINFO messages while the shared memory to store
results is not initialized we stop the test execution with TBROK.

But currently there is no way the results not to be allocated when test
code is executed since it's initialized before we call any of the test
functions.

The motivation for this change is that test library code that prints
messages (tst_device.c for instance) cannot be used without doing full
test initialization, which is unfortunate since I wanted to reuse the
code to create a helper binary for shell testcases.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
047c72769fb51db35c55b45d06ef214cfd9f9167 13-Feb-2017 Cyril Hrubis <chrubis@suse.cz> lib: tst_ansi_colors: Fix output is terminal check

The newlib prints to stderr, hence we have to pass which file descriptor
we would use to the tst_color_enabled() function.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
9f41dcf6207624b45fd1587f8ee32b807ae69937 21-Dec-2016 Steven Jackson <sj@oscode.net> tst_test: simplify tmpdir creation and support memory mapped file ipc

Android doesn't support shm and a memory mapped file is simpler than
ashmem.

Signed-off-by: Steven Jackson <sj@oscode.net>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
a7f6133726a55fe8a094b8a14a8cb80101d0ff81 24-Jan-2017 Petr Vorel <pvorel@suse.cz> Colorize test type in the output

By default colorize unless using pipe or redirect to file.

It's possible to force behaviour with LTP_COLORIZE_OUTPUT environment
variable:
y or 1: allways colorize
n or 0: never colorize

Signed-off-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
dd90c00b91140008c3a545c22dab04044f5abd66 17-Dec-2016 Alexey Kodanev <alexey.kodanev@oracle.com> tst_test: add tst_parse_long()

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
4dcfd2865dd42f62d52f3930ea4abfcef41fbaf5 01-Nov-2016 Cyril Hrubis <chrubis@suse.cz> lib: Add new tst_kvcmp for shell

Add tst_kvcmp inspired by the shell test syntax.

Now we can write the kernel version checks as:

if tst_kvcmp -ge 3.8.0 -a -le 4.3.2; then
tst_brk TCONF "Needs kernel older than 3.8.0 or newer than 4.3.2"
fi

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
d47bb550b43412273898edc1090a152762608865 27-Sep-2016 Li Wang <liwang@redhat.com> lib: Add optional minimal size for test device

This patch allows testcases to request minimal size for the test block
device. Which could be done either by setting the
tst_test->device_min_size or by passing optional parameter to the shell
tst_acquire_device() function. In both cases the requested size is in
megabytes.

+ adds tst_device.c tests, and updates test-writing-guidelines.txt.

Signed-off-by: Li Wang <liwang@redhat.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
a41e994c2b143cd801e20b27ccb05aff58ffc791 04-Aug-2016 Cyril Hrubis <chrubis@suse.cz> tst_test: Propagate SIGINT to test process

Since the test runs in separate process and separate process group
pressing Ctrl+C only sends SIGINT to the library process.

This commit adds SIGINT handler for the library process that kills the
whole test process group. The upside is that system resources allocated
in the library are cleaned up even in this case.

We also reset signal handlers in the test process after the fork now.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
6b56aa7d32e2914679c73767c875289ea48873aa 04-Aug-2016 Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com> tst_test: make reap_children() part of the test API

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
f5f208bc067add80da32f6e3fd9a564d3c0ded0b 04-Aug-2016 Cyril Hrubis <chrubis@suse.cz> tst_test: Complain on NULL test->tid

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
1e92d8aae4630566fb5ed00ac8ac55ba7d3d4206 03-Aug-2016 Cyril Hrubis <chrubis@suse.cz> tst_test: Add option parsing helpers.

Add two helpers for parsing integers and floats, these are intended to
be used in the test setup to parse options from struct tst_option.

static char *str_threads;
static int threads;
...

static struct tst_option options[] = {
{"t:", &str_threads, "Number of threads"},
...
{NULL, NULL, NULL}
};

static void setup(void)
{
if (tst_parse_int(str_threads, &threads, 1, INT_MAX))
tst_brk(TBROK, "Invalid number of threads '%s'", str_threads);

...
}

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
2ad59b7c06ca7650e7a2a6e30fb51eef4eb73c01 03-Aug-2016 Cyril Hrubis <chrubis@suse.cz> tst_test: Allow to set timeout from test setup()

There are testcases that take runtime as a parameter. These needs to be
able to set the timeout dynamically in the test setup().

This commit places the timeout value into the struct results stored in
shared memory so that it can be changed from the test setup() that runs
in the child process.

We also add tst_set_timeout() helper function that stores the value and
also sends heartbeat (SIGUSR1) so that the new value is used
immediately.

+ Added a few lines about test timeouts into the documentation.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
b819c224678869e1e1e1559e019dc042adf92d95 03-Aug-2016 Cyril Hrubis <chrubis@suse.cz> tst_test: Small changes in option help formatting

* Print newline after user option help

* Padd the library options a bit more

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
c07d36c5be2548bd04ef43dd0dda41139cf924fa 01-Aug-2016 Jan Stancek <jstancek@redhat.com> lib/test_test: fix parsing for options that don't need argument

Docs say: "The 'arg' is where 'optarg' is stored upon match.
If option has no parameter it's set to non-'NULL' value if
option was present." but at the moment we always return NULL
in "tst_option.arg". This patch fixes that.

Reported-by: Han Pingtian <hanpt@linux.vnet.ibm.com>
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
11dfc324633849af0bf2d14c636dca5ebbc7332f 16-Jun-2016 Xiao Yang <yangx.jy@cn.fujitsu.com> lib/tst_test.c: fix case of hitting tst_vbrk_ before setup_ipc

We can hit TBROK/TCONF before call to setup_ipc(), for example
a TCONF in kernel version check, in which case do_exit() tries
to use NULL pointer 'results'.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
db036388740bfae13138ffa9fbf9d1bcb0b13505 09-Jun-2016 Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com> Include tst_kvercmp.h in tst_test.h

tst_kvercmp.h is included in test.h, but is not included
in tst_test.sh.

Fixed this and removed all explicit includes of tst_kvercmp.h
in tests.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
/external/ltp/lib/tst_test.c
332540e5c42eb601de350c401cd89def1d30aa78 08-Jun-2016 Jan Stancek <jstancek@redhat.com> lib/tst_test.c: do all cleanup in do_exit

Since previous patch, library process can exit only by calling
do_exit(). This patch moves all cleanup to do_cleanup(),
which is called only from a single place at do_exit().

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
fa495176ab2cdec819046bb813af0066435ca88c 08-Jun-2016 Cyril Hrubis <chrubis@suse.cz> lib/tst_test.c: propagate TBROK retcode in library process

Previous patch caused, that 0 would be returned as ret code
if library process hit a TBROK. It also missed that there are
other places where library can exit by calling exit().

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
e0bfa7d612e4500b944a52a12d1d57d14d2dc1ba 08-Jun-2016 Jan Stancek <jstancek@redhat.com> lib/tst_test.c: call do_exit on TBROK from library process

What was previously main_pid has been split into the library
process and main test process. If we'd get a TBROK while
running in library process, we would just call exit()
skipping some potential cleanup.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
0f053c893a474aa46ff36254941d346b41dd295c 07-Jun-2016 Cyril Hrubis <chrubis@suse.cz> lib/tst_test.c: Kill all children on timeout

* Run actuall test in a separate process group

* Deliver SIGKILL to all children on timeout

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
4aebb6cc110fd871926aa3e692891a5236ca7c1f 07-Jun-2016 Cyril Hrubis <chrubis@suse.cz> lib/tst_test.c: Run test in child process

This commit moves the actuall test to a child process. The parent process now
serves two purposes. It sets up an alarm timer that kills the test on a timeout
and also does the library setup and cleanup which means that the test temporary
directory is removed even if the test crashed in one of the functions exported
in tst_test structure.

The timeout is defined per test run, which is either one execution of
test_all() function or single loop over the test() function. The timeout is
reset after each test run by the test library by sending SIGUSR1 to the parent.

The default timeout is set to 300 seconds and can be overriden by setting
tst_test->timeout variable.

There is also LTP_TIMEOUT_MUL env variable that, if set to float > 1, is used
to multiply the timeout before the start of a test. This is especially intended
for slow machines where the default timeout may not be enough.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Jan Stancek <jstancek@redhat.com>
/external/ltp/lib/tst_test.c
c54ca05163601b5aad8a3d671444a4364de107ef 13-Apr-2016 Jan Stancek <jstancek@redhat.com> tst_atomic: make tst_atomic_inc take a signed integer

This is a preparation for upcoming patches, which add atomic_add_return(),
based on kernel function of same name. Kernel's atomic_t is int based,
so let's match that.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c
bbdb9f78378c7e038f463efa39d2470e1c51ad54 16-Mar-2016 Cyril Hrubis <chrubis@suse.cz> lib: Add new test library API

The main features are:

o The cleanup callback is not passed directly to various library functions but
is set once globally in the structure that describes a test

- this makes the test API easier to use

- also fixes a few common mistakes such as passing cleanup callback
to functions executed from a cleanup

o Most of the boilerplate code is moved to library

- no more copying standard looping code around :)

o Various resources are initialized and freed automatically when requested

- this means much less race conditions and ordering problems in cleanups

o The result reporting functions now use shared memory to propagate
test results from child processes

- writing tests in child processes is now easier than ever

+ The test-writing-guidelines.txt were updated

Many thanks to Jan who reviewed numerous respins of this patches and
provided valuable suggestions and also to Alexey who pointed out some
stupid mistakes of mine.

Reviewed-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
/external/ltp/lib/tst_test.c