summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Moore <paul@paul-moore.com>2021-08-03 22:40:25 -0400
committerPaul Moore <paul@paul-moore.com>2021-08-12 12:30:25 -0400
commitcc8d19b69aaadff2172b04fa37d4995ae63e895a (patch)
treea291995022e29d4bcd060025b081b3e862799ac1 /tests
parenta415ef0938c2fc8139d45f89a722d132367077cc (diff)
downloadlibseccomp-cc8d19b69aaadff2172b04fa37d4995ae63e895a.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>
Diffstat (limited to 'tests')
-rw-r--r--tests/util.c40
-rw-r--r--tests/util.h2
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);