GLib.test_init (original) (raw)
Function
GLibtest_init
since: 2.16
Declaration [src]
void
g_test_init (
int* argc,
char*** argv,
...
)
Description [src]
Initializes the GLib testing framework.
This includes seeding the test random number generator, setting the program name, and parsing test-related commandline args.
This should be called before calling any other g_test_*()
functions.
The following arguments are understood:
-l
: List test cases available in a test executable.--seed=SEED
: Provide a random seed to reproduce test runs using random numbers.--verbose
: Run tests verbosely.-q
,--quiet
: Run tests quietly.-p PATH
: Execute all tests matching the given path.-s PATH
: Skip all tests matching the given path. This can also be used to force a test to run that would otherwise be skipped (ie, a test whose name contains “/subprocess”).-m {perf|slow|thorough|quick|undefined|no-undefined}
: Execute tests according to these test modes:
perf
: Performance tests, may take long and report results (off by default).
slow
, thorough
: Slow and thorough tests, may take quite long and maximize coverage (off by default).
quick
: Quick tests, should run really quickly and give good coverage (the default).
undefined
: Tests for undefined behaviour, may provoke programming errors under g_test_trap_subprocess() or g_test_expect_message() to check that appropriate assertions or warnings are given (the default).
no-undefined
: Avoid tests for undefined behaviour.
--debug-log
: Debug test logging output.
Any parsed arguments are removed from argv
, and argc
is adjust accordingly.
The following options are supported:
G_TEST_OPTION_NO_PRGNAME
: Causesg_test_init()
to not callg_set_prgname(). Since. 2.84G_TEST_OPTION_ISOLATE_DIRS
: Creates a unique temporary directory for each unit test and sets XDG directories to point there for the duration of the unit test. See G_TEST_OPTION_ISOLATE_DIRS.G_TEST_OPTION_NONFATAL_ASSERTIONS
: This has the same effect asg_test_set_nonfatal_assertions(). Since 2.84
Since 2.58, if tests are compiled with G_DISABLE_ASSERT
defined, g_test_init()
will print an error and exit. This is to prevent no-op tests from being executed, as g_assert() is commonly (erroneously) used in unit tests, and is a no-op when compiled with G_DISABLE_ASSERT
. Ensure your tests are compiled withoutG_DISABLE_ASSERT
defined.
Available since: 2.16
This function is not directly available to language bindings.
Parameters
argc
Type: int*
Address of the argc
parameter of main()
.
The data is owned by the caller of the function.
argv
Type: char***
Address of the argv
parameter of main()
.
The data is owned by the caller of the function. |
---|
The value is a NUL terminated UTF-8 string. |
...
Type: ``
NULL
-terminated list of special options.