### Function

# GLib test_init

since: 2.16

#### Declaration

    void
    g_test_init (
      int* argc,
      char*** argv,
      ...
    )

#### Description

Initialize the GLib testing framework, e.g. by seeding the test random number generator, the name for `g_get_prgname()` and parsing test related command line args.

This should be called before calling any other `g_test_*()` functions.

So far, 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.

Options which can be passed to @… are:

- `"no_g_set_prgname"`: Causes `g_test_init()` to not call g_set_prgname().
- `G_TEST_OPTION_ISOLATE_DIRS`: Creates a unique temporary directory for each unit test and uses `g_set_user_dirs()` to set XDG directories to point into that temporary directory for the duration of the unit test. See the documentation for `G_TEST_OPTION_ISOLATE_DIRS`.

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 without `G_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 the `main()` function. Changed if any arguments were handled.

  The data is owned by the caller of the function.

`argv`

  Type: `char***`

  Address of the `argv` parameter of main(). Any parameters understood by `g_test_init()` stripped before return.

  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, documented below.