summaryrefslogtreecommitdiff
path: root/src/test/test-namespace.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-13 02:05:04 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-13 04:06:43 +0100
commit6b46ea73e3b1d8a1e65f58ac04772821bd4a72fb (patch)
tree5fe6a91a2bbb8e87528d68e7aeb2c58086d53d42 /src/test/test-namespace.c
parent6203e07a83214a55bb1f88508fcda2005c601dea (diff)
namespace: include boot id in private tmp directories
This way it is easy to only exclude directories from the current boot from automatic clean up in /var/tmp. Also, pick a longer name for the directories so that are globs in tmp.conf can be simpler yet equally accurate.
Diffstat (limited to 'src/test/test-namespace.c')
-rw-r--r--src/test/test-namespace.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/test/test-namespace.c b/src/test/test-namespace.c
index 6454a1bd6e..5b76b9e73f 100644
--- a/src/test/test-namespace.c
+++ b/src/test/test-namespace.c
@@ -119,13 +119,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();