]> granicus.if.org Git - strace/commitdiff
tests: make mq test executable reenterable
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 14 Apr 2017 16:25:05 +0000 (16:25 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 14 Apr 2017 16:25:05 +0000 (16:25 +0000)
* tests/mq.c (NAME): Remove.
(main): Replace the fixed message queue name with a dynamically
made name containing the pid of process.
* tests/gen_tests.in (mq): Update -a option.

tests/gen_tests.in
tests/mq.c

index 9f91fddd8ef389a4f447f54cb5b20c0438d77251..6936dd8d7f5ccd275d3633688f515b31e00fe017 100644 (file)
@@ -170,7 +170,7 @@ mmsg_name   -a25 -e trace=sendmmsg,recvmmsg
 mmsg_name-v    -v -a25 -e trace=sendmmsg,recvmmsg
 mount
 move_pages     -s3
-mq     -a28 -e trace=mq_getsetattr,mq_open,mq_unlink
+mq     -a32 -e trace=mq_getsetattr,mq_open,mq_unlink
 mq_sendrecv    -a14 -e trace=mq_open,mq_notify,mq_timedsend,mq_timedreceive,mq_unlink
 mq_sendrecv-read       -eread=0 -a14 -e trace=mq_open,mq_notify,mq_timedsend,mq_timedreceive,mq_unlink
 mq_sendrecv-write      -ewrite=0 -a14 -e trace=mq_open,mq_notify,mq_timedsend,mq_timedreceive,mq_unlink
index 9c2ffc8ed4afcb426f4fbcb575d80623ca02ff33..12539453f44a27ed6dfdd494a413b447fa87a8c6 100644 (file)
 # include <unistd.h>
 # include <sys/stat.h>
 
-# define NAME "strace-mq.test"
-
 int
 main (void)
 {
        struct mq_attr attr;
        (void) close(0);
 
-       if (mq_open("/" NAME, O_CREAT, 0700, NULL))
+       char *name;
+       if (asprintf(&name, "/strace-mq-%u.sample", getpid()) < 0)
+               perror_msg_and_fail("asprintf");
+
+       if (mq_open(name, O_CREAT, 0700, NULL))
                perror_msg_and_skip("mq_open");
-       printf("mq_open(\"%s\", O_RDONLY|O_CREAT, 0700, NULL) = 0\n", NAME);
+       printf("mq_open(\"%s\", O_RDONLY|O_CREAT, 0700, NULL) = 0\n", name + 1);
 
        if (mq_getattr(0, &attr))
                perror_msg_and_skip("mq_getattr");
@@ -63,9 +65,9 @@ main (void)
               (long long) attr.mq_maxmsg,
               (long long) attr.mq_msgsize);
 
-       if (mq_unlink("/" NAME))
+       if (mq_unlink(name))
                perror_msg_and_skip("mq_unlink");
-       printf("mq_unlink(\"%s\") = 0\n", NAME);
+       printf("mq_unlink(\"%s\") = 0\n", name + 1);
 
        puts("+++ exited with 0 +++");
        return 0;