[CRIU] [PATCH] test: sockets_dgram -- Don't use /tmp
Cyrill Gorcunov
gorcunov at gmail.com
Thu Apr 18 13:07:15 MSK 2019
Initially when we didn't support relative names
in unix sockets we faced a problem that absolute
paths might be too long for testing environments.
Lets switch to automatically generated directory
name because on some distros /tmp get cleaned
by a system's init scripts and may cause problems.
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
test/zdtm/static/Makefile | 2 +-
test/zdtm/static/sockets_dgram.c | 18 ++++++++----------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 8e3f39276a7d..7d896aef42d0 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -264,7 +264,6 @@ TST_FILE = \
fdt_shared \
sockets00 \
sockets03 \
- sockets_dgram \
file_lease00 \
file_lease01 \
file_lease02 \
@@ -352,6 +351,7 @@ TST_DIR_FILE = \
chroot \
chroot-file \
binfmt_misc \
+ sockets_dgram \
TST = \
$(TST_NOFILE) \
diff --git a/test/zdtm/static/sockets_dgram.c b/test/zdtm/static/sockets_dgram.c
index f135a3bbf224..75b4fce25f49 100644
--- a/test/zdtm/static/sockets_dgram.c
+++ b/test/zdtm/static/sockets_dgram.c
@@ -20,6 +20,9 @@ const char *test_author = "Cyrill Gorcunov <gorcunov at openvz.org";
#define SK_DATA_CONN "data-packet-conn"
#define SK_DATA_BOUND_CONN "data-packet-bound-conn"
+char *dirname;
+TEST_OPTION(dirname, string, "directory name", 1);
+
char *filename;
TEST_OPTION(filename, string, "socket file name", 1);
@@ -37,21 +40,16 @@ int main(int argc, char *argv[])
char path[PATH_MAX];
char buf[64];
- /*
- * The original code makes dir to be current working
- * directory. But it may be too long in google environment
- * for path to be fit into struct sockaddr_un.
- * One alternate way to resolve it is to use relative path
- * for sockaddr_un, but criu has not supported relative
- * bind path yet.
- * We change it to "/tmp" to ensure its short length.
- */
- char *dirname = "/tmp";
int ret;
test_init(argc, argv);
+ if (mkdir(dirname, 0700)) {
+ pr_perror("Can't create %s", dirname);
+ return 1;
+ }
+
snprintf(path, sizeof(path), "%s/%s", dirname, filename);
unlink(path);
--
2.20.1
More information about the CRIU
mailing list