diff options
author | Mauro Carvalho Chehab <mchehab@kernel.org> | 2022-03-16 15:59:54 +0100 |
---|---|---|
committer | Petri Latvala <petri.latvala@intel.com> | 2022-03-21 18:34:59 +0200 |
commit | 4b88a9253443ecd910a5f4c7bfe624a5f29d35b9 (patch) | |
tree | efdfe7c20f075e1758043c6a823f045e0e87d5e1 /runner/settings.c | |
parent | 0fcd59ad25b2960c0b654f90dfe4dd9e7c7b874d (diff) |
runner: check if it has root permissions
Without root permissions, most IGT tests won't actually run, but they
would be displayed at the runner's output as if everything went fine.
In order to avoid that, check if one attempts to run IGT without root
permission. Such check can be disbled with a new command line option:
--allow-non-root
As runner_tests runs as non-root, most unit tests need to pass
--allow-non-root in order for them to not return an error.
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'runner/settings.c')
-rw-r--r-- | runner/settings.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/runner/settings.c b/runner/settings.c index 200f1ce5..ac090b08 100644 --- a/runner/settings.c +++ b/runner/settings.c @@ -24,6 +24,7 @@ enum { OPT_DMESG_WARN_LEVEL, OPT_OVERALL_TIMEOUT, OPT_PER_TEST_TIMEOUT, + OPT_ALLOW_NON_ROOT, OPT_VERSION, OPT_HELP = 'h', OPT_NAME = 'n', @@ -199,6 +200,7 @@ static const char *usage_str = " --ignore-missing Ignored but accepted, for piglit compatibility\n" "\n" " Incompatible options:\n" + " --allow-non-root Allow running tests without being the root user.\n" " -m, --multiple-mode Run multiple subtests in the same binary execution.\n" " If a testlist file is given, consecutive subtests are\n" " run in the same execution if they are from the same\n" @@ -381,6 +383,7 @@ bool parse_options(int argc, char **argv, {"help", no_argument, NULL, OPT_HELP}, {"name", required_argument, NULL, OPT_NAME}, {"dry-run", no_argument, NULL, OPT_DRY_RUN}, + {"allow-non-root", no_argument, NULL, OPT_ALLOW_NON_ROOT}, {"include-tests", required_argument, NULL, OPT_INCLUDE}, {"exclude-tests", required_argument, NULL, OPT_EXCLUDE}, {"abort-on-monitored-error", optional_argument, NULL, OPT_ABORT_ON_ERROR}, @@ -423,6 +426,9 @@ bool parse_options(int argc, char **argv, case OPT_DRY_RUN: settings->dry_run = true; break; + case OPT_ALLOW_NON_ROOT: + settings->allow_non_root = true; + break; case OPT_INCLUDE: if (!add_regex(&settings->include_regexes, strdup(optarg))) goto error; @@ -693,6 +699,7 @@ bool serialize_settings(struct settings *settings) if (settings->name) SERIALIZE_LINE(f, settings, name, "%s"); SERIALIZE_LINE(f, settings, dry_run, "%d"); + SERIALIZE_LINE(f, settings, allow_non_root, "%d"); SERIALIZE_LINE(f, settings, sync, "%d"); SERIALIZE_LINE(f, settings, log_level, "%d"); SERIALIZE_LINE(f, settings, overwrite, "%d"); @@ -740,6 +747,7 @@ bool read_settings_from_file(struct settings *settings, FILE *f) PARSE_LINE(settings, name, val, test_list, val ? strdup(val) : NULL); PARSE_LINE(settings, name, val, name, val ? strdup(val) : NULL); PARSE_LINE(settings, name, val, dry_run, numval); + PARSE_LINE(settings, name, val, allow_non_root, numval); PARSE_LINE(settings, name, val, sync, numval); PARSE_LINE(settings, name, val, log_level, numval); PARSE_LINE(settings, name, val, overwrite, numval); |