diff options
author | Paul Moore <paul@paul-moore.com> | 2021-08-03 22:40:25 -0400 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2021-08-12 12:38:12 -0400 |
commit | d716d75cf7e105028855ae39da568d60a6a9bf34 (patch) | |
tree | 060cb7c9f0851f1a3353ac4506c932a7522fb596 | |
parent | f8786326782010fac9fc71dc8509db76cdaa1e55 (diff) | |
download | libseccomp-d716d75cf7e105028855ae39da568d60a6a9bf34.tar.gz |
tests: add a util_gcov_rules() utility function
As documented in the function header:
"This function is to make it easier for developers to temporarily
add support for gcov/lcov to a test program; it likely should not
be used in the normal regression tests. Further, this should only
be necessary for the "live" tests."
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
(imported from commit cc8d19b69aaadff2172b04fa37d4995ae63e895a)
-rw-r--r-- | tests/util.c | 40 | ||||
-rw-r--r-- | tests/util.h | 2 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/util.c b/tests/util.c index d212c04..f978e8a 100644 --- a/tests/util.c +++ b/tests/util.c @@ -48,6 +48,46 @@ static void _trap_handler(int signal, siginfo_t *info, void *ctx) } /** + * Add rules for gcov/lcov + * @param ctx the filter context + * @param action the action for the rules + * + * This function is to make it easier for developers to temporarily add support + * for gcov/lcov to a test program; it likely should not be used in the normal + * regression tests. Further, this should only be necessary for the "live" + * tests. + * + */ +int util_gcov_rules(const scmp_filter_ctx ctx, int action) +{ + int rc; + + rc = seccomp_rule_add(ctx, action, SCMP_SYS(open), 0); + if (rc != 0) + return rc; + rc = seccomp_rule_add(ctx, action, SCMP_SYS(openat), 0); + if (rc != 0) + return rc; + rc = seccomp_rule_add(ctx, action, SCMP_SYS(fcntl), 0); + if (rc != 0) + return rc; + rc = seccomp_rule_add(ctx, action, SCMP_SYS(lseek), 0); + if (rc != 0) + return rc; + rc = seccomp_rule_add(ctx, action, SCMP_SYS(read), 0); + if (rc != 0) + return rc; + rc = seccomp_rule_add(ctx, action, SCMP_SYS(write), 0); + if (rc != 0) + return rc; + rc = seccomp_rule_add(ctx, action, SCMP_SYS(getpid), 0); + if (rc != 0) + return rc; + + return 0; +} + +/** * Parse the arguments passed to main * @param argc the argument count * @param argv the argument pointer diff --git a/tests/util.h b/tests/util.h index b3c5a29..909bef5 100644 --- a/tests/util.h +++ b/tests/util.h @@ -28,6 +28,8 @@ struct util_options { int util_getopt(int argc, char *argv[], struct util_options *opts); +int util_gcov_rules(const scmp_filter_ctx ctx, int action); + int util_filter_output(const struct util_options *opts, const scmp_filter_ctx ctx); |