blob: 267d72cf03a04ba8dee59eca40e5ed9d0b7624ed [file] [log] [blame]
Petri Latvala18c1e752018-08-08 14:07:00 +03001#ifndef RUNNER_SETTINGS_H
2#define RUNNER_SETTINGS_H
3
4#include <stdbool.h>
5#include <stddef.h>
6#include <sys/types.h>
7#include <regex.h>
8
9enum {
10 LOG_LEVEL_NORMAL = 0,
11 LOG_LEVEL_QUIET = -1,
12 LOG_LEVEL_VERBOSE = 1,
13};
14
Petri Latvala111593c2018-11-09 13:13:03 +020015#define ABORT_TAINT (1 << 0)
16#define ABORT_LOCKDEP (1 << 1)
17#define ABORT_ALL (ABORT_TAINT | ABORT_LOCKDEP)
18
19_Static_assert(ABORT_ALL == (ABORT_TAINT | ABORT_LOCKDEP), "ABORT_ALL must be all conditions bitwise or'd");
20
Petri Latvala18c1e752018-08-08 14:07:00 +030021struct regex_list {
22 char **regex_strings;
23 regex_t** regexes;
24 size_t size;
25};
26
27struct settings {
Petri Latvala111593c2018-11-09 13:13:03 +020028 int abort_mask;
Petri Latvala18c1e752018-08-08 14:07:00 +030029 char *test_list;
30 char *name;
31 bool dry_run;
32 struct regex_list include_regexes;
33 struct regex_list exclude_regexes;
34 bool sync;
35 int log_level;
36 bool overwrite;
37 bool multiple_mode;
38 int inactivity_timeout;
Petri Latvala78619fd2018-10-10 13:41:00 +030039 int overall_timeout;
Petri Latvala18c1e752018-08-08 14:07:00 +030040 bool use_watchdog;
41 char *test_root;
42 char *results_path;
Petri Latvalac7a0b452018-08-30 15:51:39 +030043 bool piglit_style_dmesg;
Petri Latvala18c1e752018-08-08 14:07:00 +030044};
45
46/**
47 * init_settings:
48 *
49 * Initializes a settings object to an empty state (all values NULL, 0
50 * or false).
51 *
52 * @settings: Object to initialize. Storage for it must exist.
53 */
54void init_settings(struct settings *settings);
55
56/**
57 * free_settings:
58 *
59 * Releases all allocated resources for a settings object and
60 * initializes it to an empty state (see #init_settings).
61 *
62 * @settings: Object to release and initialize.
63 */
64void free_settings(struct settings *settings);
65
66/**
67 * parse_options:
68 *
69 * Parses command line options and sets the settings object to
70 * designated values.
71 *
72 * The function can be called again on the same settings object. The
73 * old values will be properly released and cleared. On a parse
74 * failure, the settings object will be in an empty state (see
75 * #init_settings) and usage instructions will be printed with an
76 * error message.
77 *
78 * @argc: Argument count
79 * @argv: Argument array. First element is the program name.
80 * @settings: Settings object to fill with values. Must have proper
81 * storage.
82 *
83 * Returns: True on successful parse, false on error.
84 */
85bool parse_options(int argc, char **argv,
86 struct settings *settings);
87
88/**
89 * validate_settings:
90 *
91 * Checks the settings object against the system to see if executing
92 * on it can be done. Checks pathnames for existence and access
93 * rights. Note that this function will not check that the designated
94 * job listing (through a test-list file or the -t/-x flags) yields a
95 * non-zero amount of testing to be done. On errors, usage
96 * instructions will be printed with an error message.
97 *
98 * @settings: Settings object to check.
99 *
100 * Returns: True on valid settings, false on any error.
101 */
102bool validate_settings(struct settings *settings);
103
104/* TODO: Better place for this */
105char *absolute_path(char *path);
106
107/**
108 * serialize_settings:
109 *
110 * Serializes the settings object to a file in the results_path
111 * directory.
112 *
113 * @settings: Settings object to serialize.
114 */
115bool serialize_settings(struct settings *settings);
116
117bool read_settings(struct settings *settings, int dirfd);
118
119#endif