Top |
int | igt_hook_create () |
void | igt_hook_free () |
void | igt_hook_event_notify () |
const char * | igt_hook_error_str () |
void | igt_hook_print_help () |
IGT provides support for running a hook script when executing tests. This
support is provided to users via CLI option --hook
available in test
binaries. Users should use --help-hook
for detailed usaged description of
the feature.
The sole user of the exposed API is igt_core
, which calls
when initializing a test case, then calls igt_hook_create()
for each
event that occurs during that test's execution and finally calls
igt_hook_event_notify()
to clean up at the end.igt_hook_free()
int igt_hook_create (const char **hook_strs
,size_t n
,struct igt_hook **igt_hook_ptr
);
Allocate and initialize an igt_hook structure.
This function parses the hook descriptors in hook_strs
and initializes the
struct. The pointer to the allocated structure is stored in igt_hook_ptr
.
Each hook descriptor comes from the argument to --hook
of the test
executable being run.
If an error happens, the returned error number can be passed to
to get a human-readable error message.igt_hook_error_str()
void
igt_hook_free (struct igt_hook *igt_hook
);
De-initialize an igt_hook struct returned by
.igt_hook_create()
This is a no-op if igt_hook
is NULL.
void igt_hook_event_notify (struct igt_hook *igt_hook
,struct igt_hook_evt *evt
);
Push a new igt_hook event.
The argument to igt_hook
can be NULL, which is equivalent to a no-op.
This function must be used to notify on a new igt_hook event. Calling it will
cause execution of the hook script if the event type matches the filters
provided during initialization of igt_hook
.
const char *
igt_hook_error_str (int error
);
Return a human-readable string containing a description of an error number
generated by one of the igt_hook_*
functions.
The string will be the result of strerror()
for errors from the C standard
library or a custom description specific to igt_hook.
Events tracked by igt_hook. Those events occur at specific points during the execution of a test.
Occurs before a test case (executable) starts the test code. |
||
Occurs before the execution of a subtest. |
||
Occurs before the execution of a dynamic subtest. |
||
Occurs after the execution of a dynamic subtest. |
||
Occurs after the execution of a subtest.. |
||
Occurs after a test case (executable) is finished with the test code. |
||
This is not really an event and represents the number of possible events tracked by igt_hook. |
struct igt_hook_evt { enum igt_hook_evt_type evt_type; const char *target_name; const char *result; };
An event tracked by igt_hook, which is done with @
.
This must be zero initialized and fields relevant to the event type must be
set before passing its reference to igt_hook_event_notify()
.igt_hook_event_notify()
enum igt_hook_evt_type |
Type of event. |
|
A string pointing to the name of the test, subtest or dynamic
subtest, depending on |
||
A string containing the result of the test, subtest or dynamic subtest. This is only applicable for the `IGT_HOOK_POST_*' event types; other types must initialize this to NULL. |