X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Ftest%2Ftest-namespace.c;h=2397db5fffe40afaa1afe142763c72b90101b0b5;hb=b6e676ce41508e2aeea22202fc8f234126177f52;hp=6454a1bd6e374fc1668fb3295c50a335c82ea8cc;hpb=613b411c947635136637f8cdd66b94512f761eab;p=elogind.git diff --git a/src/test/test-namespace.c b/src/test/test-namespace.c index 6454a1bd6..2397db5ff 100644 --- a/src/test/test-namespace.c +++ b/src/test/test-namespace.c @@ -19,7 +19,6 @@ along with systemd; If not, see . ***/ -#include #include #include "namespace.h" @@ -43,8 +42,8 @@ static void test_tmpdir(const char *id, const char *A, const char *B) { assert_se((x.st_mode & 01777) == 0700); assert_se((y.st_mode & 01777) == 0700); - c = strappenda(a, "/tmp"); - d = strappenda(b, "/tmp"); + c = strjoina(a, "/tmp"); + d = strjoina(b, "/tmp"); assert_se(stat(c, &x) >= 0); assert_se(stat(d, &y) >= 0); @@ -63,7 +62,7 @@ static void test_tmpdir(const char *id, const char *A, const char *B) { } static void test_netns(void) { - _cleanup_close_pipe_ int s[2] = { -1, -1 }; + _cleanup_close_pair_ int s[2] = { -1, -1 }; pid_t pid1, pid2, pid3; int r, n = 0; siginfo_t si; @@ -119,13 +118,25 @@ static void test_netns(void) { } int main(int argc, char *argv[]) { - test_tmpdir("abcd.service", - "/tmp/systemd-abcd.service-", - "/var/tmp/systemd-abcd.service-"); + sd_id128_t bid; + char boot_id[SD_ID128_STRING_MAX]; + _cleanup_free_ char *x = NULL, *y = NULL, *z = NULL, *zz = NULL; - test_tmpdir("sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device", - "/tmp/systemd-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-", - "/var/tmp/systemd-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-"); + assert_se(sd_id128_get_boot(&bid) >= 0); + sd_id128_to_string(bid, boot_id); + + x = strjoin("/tmp/systemd-private-", boot_id, "-abcd.service-", NULL); + y = strjoin("/var/tmp/systemd-private-", boot_id, "-abcd.service-", NULL); + assert_se(x && y); + + test_tmpdir("abcd.service", x, y); + + z = strjoin("/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-", NULL); + zz = strjoin("/var/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-", NULL); + + assert_se(z && zz); + + test_tmpdir("sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device", z, zz); test_netns();