e20fafc72a
Resolves: RHEL-44417, RHEL-71409, RHEL-72798
62 lines
3.9 KiB
Diff
62 lines
3.9 KiB
Diff
From ab99950f1a0ab9401b44357d226a5880b5f262a7 Mon Sep 17 00:00:00 2001
|
|
From: Daan De Meyer <daan.j.demeyer@gmail.com>
|
|
Date: Wed, 11 Dec 2024 12:44:26 +0000
|
|
Subject: [PATCH] test-bpf-restrict-fs: Migrate to new assertion macros
|
|
|
|
(cherry picked from commit 1c658c639db1c902266735754f2e2883fe67d1d9)
|
|
---
|
|
src/test/test-bpf-restrict-fs.c | 18 +++++++++---------
|
|
1 file changed, 9 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/src/test/test-bpf-restrict-fs.c b/src/test/test-bpf-restrict-fs.c
|
|
index 11e97bf922..349c5a6894 100644
|
|
--- a/src/test/test-bpf-restrict-fs.c
|
|
+++ b/src/test/test-bpf-restrict-fs.c
|
|
@@ -18,9 +18,9 @@ static int test_restrict_filesystems(Manager *m, const char *unit_name, const ch
|
|
ExecContext *ec = NULL;
|
|
int cld_code, r;
|
|
|
|
- assert_se(u = unit_new(m, sizeof(Service)));
|
|
- assert_se(unit_add_name(u, unit_name) == 0);
|
|
- assert_se(ec = unit_get_exec_context(u));
|
|
+ ASSERT_NOT_NULL(u = unit_new(m, sizeof(Service)));
|
|
+ ASSERT_OK_ZERO(unit_add_name(u, unit_name));
|
|
+ ASSERT_NOT_NULL(ec = unit_get_exec_context(u));
|
|
|
|
STRV_FOREACH(allow_filesystem, allowed_filesystems) {
|
|
r = config_parse_restrict_filesystems(
|
|
@@ -30,7 +30,7 @@ static int test_restrict_filesystems(Manager *m, const char *unit_name, const ch
|
|
return log_unit_error_errno(u, r, "Failed to parse RestrictFileSystems: %m");
|
|
}
|
|
|
|
- assert_se(exec_start = strjoin("cat ", file_path));
|
|
+ ASSERT_NOT_NULL(exec_start = strjoin("cat ", file_path));
|
|
r = config_parse_exec(u->id, "filename", 1, "Service", 1, "ExecStart",
|
|
SERVICE_EXEC_START, exec_start, SERVICE(u)->exec_command, u);
|
|
if (r < 0)
|
|
@@ -84,19 +84,19 @@ int main(int argc, char *argv[]) {
|
|
|
|
ASSERT_OK(get_testdata_dir("units", &unit_dir));
|
|
ASSERT_OK(setenv_unit_path(unit_dir));
|
|
- assert_se(runtime_dir = setup_fake_runtime_dir());
|
|
+ ASSERT_NOT_NULL(runtime_dir = setup_fake_runtime_dir());
|
|
|
|
ASSERT_OK(manager_new(RUNTIME_SCOPE_SYSTEM, MANAGER_TEST_RUN_BASIC, &m));
|
|
ASSERT_OK(manager_startup(m, NULL, NULL, NULL));
|
|
|
|
/* We need to enable access to the filesystem where the binary is so we
|
|
* add @common-block and @application */
|
|
- ASSERT_LT(test_restrict_filesystems(m, "restrict_filesystems_test.service", "/sys/kernel/tracing/printk_formats", STRV_MAKE("@common-block", "@application")), 0);
|
|
+ ASSERT_FAIL(test_restrict_filesystems(m, "restrict_filesystems_test.service", "/sys/kernel/tracing/printk_formats", STRV_MAKE("@common-block", "@application")));
|
|
ASSERT_OK(test_restrict_filesystems(m, "restrict_filesystems_test.service", "/sys/kernel/tracing/printk_formats", STRV_MAKE("tracefs", "@common-block", "@application")));
|
|
- ASSERT_LT(test_restrict_filesystems(m, "restrict_filesystems_test.service", "/sys/kernel/tracing/printk_formats", STRV_MAKE("tracefs", "@common-block", "@application", "~tracefs")), 0);
|
|
- ASSERT_LT(test_restrict_filesystems(m, "restrict_filesystems_test.service", "/sys/kernel/debug/sleep_time", STRV_MAKE("@common-block", "@application")), 0);
|
|
+ ASSERT_FAIL(test_restrict_filesystems(m, "restrict_filesystems_test.service", "/sys/kernel/tracing/printk_formats", STRV_MAKE("tracefs", "@common-block", "@application", "~tracefs")));
|
|
+ ASSERT_FAIL(test_restrict_filesystems(m, "restrict_filesystems_test.service", "/sys/kernel/debug/sleep_time", STRV_MAKE("@common-block", "@application")));
|
|
ASSERT_OK(test_restrict_filesystems(m, "restrict_filesystems_test.service", "/sys/kernel/debug/sleep_time", STRV_MAKE("debugfs", "@common-block", "@application")));
|
|
- ASSERT_LT(test_restrict_filesystems(m, "restrict_filesystems_test.service", "/sys/kernel/debug/sleep_time", STRV_MAKE("~debugfs")), 0);
|
|
+ ASSERT_FAIL(test_restrict_filesystems(m, "restrict_filesystems_test.service", "/sys/kernel/debug/sleep_time", STRV_MAKE("~debugfs")));
|
|
|
|
return 0;
|
|
}
|