summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-03-14 11:16:15 +0100
committerGitHub <noreply@github.com>2023-03-14 11:16:15 +0100
commit3a36d19938c1dcc10bb11ff5d2f3e2e7eec26997 (patch)
treebca1a776d69b37f6e242b7960876429ba795832d /src/test
parenta5c0ad9a9a2964079a19a1db42f79570a3582bee (diff)
parent600ed5c24251367f5cfeaa5df22792c9c90e5cd6 (diff)
downloadsystemd-3a36d19938c1dcc10bb11ff5d2f3e2e7eec26997.tar.gz
Merge pull request #26662 from yuwata/test-execute-network-namespace-path
test-execute: add tests for NetworkNamespacePath=
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-execute.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
index a91cbb2c67..0c96f28aa9 100644
--- a/src/test/test-execute.c
+++ b/src/test/test-execute.c
@@ -1065,6 +1065,19 @@ static void test_exec_privatenetwork(Manager *m) {
test(m, "exec-privatenetwork-yes-privatemounts-yes.service", status, CLD_EXITED);
}
+static void test_exec_networknamespacepath(Manager *m) {
+ int r;
+
+ r = find_executable("ip", NULL);
+ if (r < 0) {
+ log_notice_errno(r, "Skipping %s, could not find ip binary: %m", __func__);
+ return;
+ }
+
+ test(m, "exec-networknamespacepath-privatemounts-no.service", MANAGER_IS_SYSTEM(m) ? EXIT_SUCCESS : EXIT_FAILURE, CLD_EXITED);
+ test(m, "exec-networknamespacepath-privatemounts-yes.service", can_unshare ? EXIT_SUCCESS : EXIT_FAILURE, CLD_EXITED);
+}
+
static void test_exec_oomscoreadjust(Manager *m) {
test(m, "exec-oomscoreadjust-positive.service", 0, CLD_EXITED);
@@ -1168,6 +1181,7 @@ static void run_tests(RuntimeScope scope, char **patterns) {
entry(test_exec_inaccessiblepaths),
entry(test_exec_ioschedulingclass),
entry(test_exec_mount_apivfs),
+ entry(test_exec_networknamespacepath),
entry(test_exec_noexecpaths),
entry(test_exec_oomscoreadjust),
entry(test_exec_passenvironment),
@@ -1378,11 +1392,16 @@ static int intro(void) {
/* Create dummy network interface for testing PrivateNetwork=yes */
(void) system("ip link add dummy-test-exec type dummy");
+ /* Create a network namespace and a dummy interface in it for NetworkNamespacePath= */
+ (void) system("ip netns add test-execute-netns");
+ (void) system("ip netns exec test-execute-netns ip link add dummy-test-ns type dummy");
+
return EXIT_SUCCESS;
}
static int outro(void) {
(void) system("ip link del dummy-test-exec");
+ (void) system("ip netns del test-execute-netns");
(void) rmdir(PRIVATE_UNIT_DIR);
return EXIT_SUCCESS;