History log of /external/ltp/lib/tst_test.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
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