Top |
#define | sigev_notify_thread_id |
struct | _igt_sigiter |
enum | igt_suspend_state |
enum | igt_suspend_test |
#define | CHECK_RAM |
#define | CHECK_SWAP |
struct | igt_mean |
This library provides various auxiliary helper functions that don't really fit into any other topic.
void
igt_fork_signal_helper (void
);
Fork a child process using igt_fork_helper to interrupt the parent process with a SIGCONT signal at regular quick intervals. The corresponding dummy signal handler is installed in the parent process.
This is useful to exercise ioctl error paths, at least where those can be exercises by interrupting blocking waits, like stalling for the gpu. This helper can also be used from children spawned with igt_fork.
In tests with subtests this function can be called outside of failure catching code blocks like igt_fixture or igt_subtest.
Note that this just spews signals at the current process unconditionally and hence incurs quite a bit of overhead. For a more focused approach, with less overhead, look at the igt_while_interruptible code block macro.
void
igt_stop_signal_helper (void
);
Stops the child process spawned with igt_fork_signal_helper()
again.
In tests with subtests this function can be called outside of failure catching code blocks like igt_fixture or igt_subtest.
void
igt_suspend_signal_helper (void
);
Suspends the child process spawned with igt_fork_signal_helper()
. This
should be called before a critical section of code that has difficulty to
make progress if interrupted frequently, like the clone()
syscall called
from a largish executable. igt_resume_signal_helper()
must be called after
the critical section to restart interruptions for the test.
void
igt_resume_signal_helper (void
);
Resumes the child process spawned with igt_fork_signal_helper()
.
This should be paired with igt_suspend_signal_helper()
and called after the
problematic code sensitive to signals.
void
igt_fork_shrink_helper (int fd
);
Fork a child process using igt_fork_helper to force all available objects
to be paged out (via i915_gem_shrink()
).
This is useful to exercise swapping paths, without requiring us to hit swap.
This should only be used from an igt_fixture.
void
igt_stop_shrink_helper (void
);
Stops the child process spawned with igt_fork_shrink_helper()
.
#define igt_while_interruptible(enable)
Provides control flow such that all drmIoctl()
(strictly igt_ioctl()
)
within the loop are forcibly injected with signals (SIGRTMIN).
This is useful to exercise ioctl error paths, at least where those can be exercises by interrupting blocking waits, like stalling for the gpu.
The code block attached to this macro is run in a loop with doubling the interrupt timeout on each ioctl for every run, until no ioctl gets interrupted any more. The starting timeout is taken to be the signal delivery latency, measured at runtime. This way the any ioctls called from this code block should be exhaustively tested for all signal interruption paths.
Note that since this overloads the igt_ioctl()
, this method is not useful
for widespread signal injection, for example providing coverage of
pagefaults. To interrupt everything, see igt_fork_signal_helper()
.
#define igt_until_timeout(timeout)
Convenience macro loop to run the provided code block in a loop until the timeout has expired. Of course when an individual execution takes too long, the actual execution time could be a lot longer.
The code block will be executed at least once.
#define igt_for_milliseconds(t)
Convenience macro loop to run the provided code block in a loop until the target interval has expired. Of course when an individual execution takes too long, the actual execution time could be a lot longer.
The code block will be executed at least once.
void igt_exchange_int (void *array
,unsigned i
,unsigned j
);
Exchanges the two values at array indices i
and j
. Useful as an exchange
function for igt_permute_array()
.
void igt_exchange_int64 (void *array
,unsigned i
,unsigned j
);
Exchanges the two values at array indices i
and j
. Useful as an exchange
function for igt_permute_array()
.
void igt_permute_array (void *array
,unsigned size
,void (*exchange_func) (void *array, unsigned i, unsigned j)
);
This function randomly permutes the array using random()
as the PRNG source.
The exchange_func
function is called to exchange two elements in the array
when needed.
void igt_progress (const char *header
,uint64_t i
,uint64_t total
);
This function draws a progress indicator, which is useful for running long-winded tests manually on the console. To avoid spamming log files in automated runs the progress indicator is suppressed when not running on a terminal.
void
igt_print_activity (void
);
Print a '.' to indicate activity. This is printed without a newline and only if output is to a terminal.
bool igt_check_boolean_env_var (const char *env_var
,bool default_value
);
This function should be used to parse boolean environment variable options.
void igt_system_suspend_autoresume (enum igt_suspend_state state
,enum igt_suspend_test test
);
Execute a system suspend cycle targeting the given state
optionally
completing the cycle at the given test
point and automaically wake up
again. Waking up is either achieved using the RTC wake-up alarm for a full
suspend cycle or a kernel timer for a suspend test cycle. The kernel timer
delay for a test cycle can be configured by the suspend.pm_test_delay
kernel parameter (5 sec by default).
SUSPEND_TEST_NONE specifies a full suspend cycle. The SUSPEND_TEST_FREEZER..SUSPEND_TEST_CORE test points can make it possible to collect error logs in case a full suspend cycle would prevent this by hanging the machine, or they can provide an idea of the faulty component by comparing fail/no-fail results at different test points.
This is very handy for implementing any kind of suspend/resume test.
state |
an igt_suspend_state, the target suspend state |
|
test |
an igt_suspend_test, test point at which to complete the suspend cycle |
void
igt_set_autoresume_delay (int delay_secs
);
Sets how long we wait to resume the system after suspending it, using the suspend.pm_test_delay variable. On exit, the original delay value is restored.
int
igt_get_autoresume_delay (enum igt_suspend_state state
);
Retrieves how long we wait to resume the system after suspending it. This can either be set through igt_set_autoresume_delay or be a default value that depends on the suspend state.
void
igt_drop_root (void
);
Drop root privileges and make sure it actually worked. Useful for tests which need to check security constraints. Note that this should only be called from manually forked processes, since the lack of root privileges will wreak havoc with the automatic cleanup handlers.
void
igt_debug_wait_for_keypress (const char *var
);
Waits for a key press when run interactively and when the corresponding debug var is set in the --interactive-debug=$var variable. Multiple keys can be specified as a comma-separated list or alternatively "all" if a wait should happen for all cases.
When not connected to a terminal interactive_debug is ignored and execution immediately continues.
This is useful for display tests where under certain situation manual inspection of the display is useful. Or when running a testcase in the background.
void igt_debug_manual_check (const char *var
,const char *expected
);
Waits for a key press when run interactively and when the corresponding debug var is set in the --interactive-debug=$var variable. Multiple vars can be specified as a comma-separated list or alternatively "all" if a wait should happen for all cases.
This is useful for display tests where under certain situation manual inspection of the display is useful. Or when running a testcase in the background.
When not connected to a terminal interactive_debug is ignored and execution immediately continues. For this reason by default this function returns true. It returns false only when N/n is pressed indicating the user isn't seeing what was expected.
Force test fail when N/n is pressed.
void *
intel_get_total_pinnable_mem (size_t *pinned
);
Compute the amount of memory that we're able to safely lock. Note that in order to achieve this, we're attempting to repeatedly lock more and more memory, which is a time consuming process.
void intel_require_memory (uint64_t count
,uint64_t size
,unsigned mode
);
Computes the total amount of memory required to allocate count
surfaces,
each of size
bytes, and includes an estimate for kernel overhead. It then
queries the kernel for the available amount of memory on the system (either
RAM and/or SWAP depending upon mode
) and determines whether there is
sufficient to run the test.
Most tests should check that there is enough RAM to hold their working set. The rare swap thrashing tests should check that there is enough RAM + SWAP for their tests. oom-killer tests should only run if this reports that there is not enough RAM + SWAP!
If there is not enough RAM this function calls igt_skip with an appropriate message. It only ever returns if the requirement is fulfilled. This function also causes the test to be skipped automatically on simulation under the assumption that any test that needs to check for memory requirements is a thrashing test unsuitable for slow simulated systems.
void
intel_require_files (uint64_t count
);
Does the system support enough file descriptors for the test?
void
igt_lock_mem (size_t size
);
Allocate size
MB of memory and lock it into RAM. This releases any
previously locked memory.
Use igt_unlock_mem to release the currently locked memory.
#define igt_wait(COND, timeout_ms, interval_ms)
Waits until COND evaluates to true or the timeout passes.
It is safe to call this macro if the signal helper is active. The only
problem is that the usleep()
calls will return early, making us evaluate COND
too often, possibly eating valuable CPU cycles.
void igt_set_module_param (const char *name
,const char *val
);
This function sets the desired value for the given i915.ko parameter. It also takes care of saving and restoring the values that were already set before the test was run.
Please consider using igt_set_module_param_int()
for the integer and bool
parameters.
void igt_set_module_param_int (const char *name
,int val
);
This is a wrapper for igt_set_module_param()
that takes an integer instead of
a string. Please see igt_set_module_param()
.
int igt_terminate_process (int sig
,const char *comm
);
Target suspend states used with igt_system_suspend_autoresume()
.
See /sys/power/state for the available states on a given machine.
Test points used with igt_system_suspend_autoresume()
. Specifies if and where
the suspend sequence is to be terminated.
no testing, perform a full suspend/resume cycle |
||
complete cycle after freezing all freezable threads |
||
complete cycle after the above step and suspending devices (before calling the drivers' suspend late and no_irq hooks). Platform and system devices are not suspended here, see SUSPEND_TEST_CORE. |
||
complete cycle after all the above steps and calling the ACPI platform global control methods (applies only with /sys/power/disk set to platform) |
||
complete cycle after all the above steps and disabling non-boot CPUs |
||
complete cycle after all the above steps and suspending platform and system devices |
struct igt_mean { };
Structure to compute running statistical numbers. Needs to be initialized
with igt_mean_init()
. Read out data using igt_mean_get()
and
igt_mean_get_variance()
.