summaryrefslogtreecommitdiff
path: root/src/test/test-namespace.c
diff options
context:
space:
mode:
authorXℹ Ruoyao <xry111@mengyan1223.wang>2021-02-16 20:49:15 +0800
committerXℹ Ruoyao <xry111@mengyan1223.wang>2021-03-04 00:04:36 +0800
commit54c2459d560283f556e331246f64776cebd6eba6 (patch)
treeb41f23fbd485e474afdc6c5b12f380c5829a42bd /src/test/test-namespace.c
parenta959cd2812ec73298ed56116f50e564ac859e467 (diff)
downloadsystemd-54c2459d560283f556e331246f64776cebd6eba6.tar.gz
Refactor network namespace specific functions in generic helpers
Diffstat (limited to 'src/test/test-namespace.c')
-rw-r--r--src/test/test-namespace.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/test/test-namespace.c b/src/test/test-namespace.c
index b162928482..bf4b87e8a6 100644
--- a/src/test/test-namespace.c
+++ b/src/test/test-namespace.c
@@ -63,7 +63,7 @@ static void test_tmpdir(const char *id, const char *A, const char *B) {
}
}
-static void test_netns(void) {
+static void test_shareable_ns(unsigned long nsflag) {
_cleanup_close_pair_ int s[2] = { -1, -1 };
pid_t pid1, pid2, pid3;
int r, n = 0;
@@ -80,7 +80,7 @@ static void test_netns(void) {
assert_se(pid1 >= 0);
if (pid1 == 0) {
- r = setup_netns(s);
+ r = setup_shareable_ns(s, nsflag);
assert_se(r >= 0);
_exit(r);
}
@@ -89,7 +89,7 @@ static void test_netns(void) {
assert_se(pid2 >= 0);
if (pid2 == 0) {
- r = setup_netns(s);
+ r = setup_shareable_ns(s, nsflag);
assert_se(r >= 0);
exit(r);
}
@@ -98,7 +98,7 @@ static void test_netns(void) {
assert_se(pid3 >= 0);
if (pid3 == 0) {
- r = setup_netns(s);
+ r = setup_shareable_ns(s, nsflag);
assert_se(r >= 0);
exit(r);
}
@@ -121,6 +121,14 @@ static void test_netns(void) {
assert_se(n == 1);
}
+static void test_netns(void) {
+ test_shareable_ns(CLONE_NEWNET);
+}
+
+static void test_ipcns(void) {
+ test_shareable_ns(CLONE_NEWIPC);
+}
+
static void test_protect_kernel_logs(void) {
int r;
pid_t pid;
@@ -224,6 +232,7 @@ int main(int argc, char *argv[]) {
test_tmpdir("sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device", z, zz);
test_netns();
+ test_ipcns();
test_protect_kernel_logs();
return EXIT_SUCCESS;