tests: make mq test executable reenterable

* 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.
This commit is contained in:
Дмитрий Левин 2017-04-14 16:25:05 +00:00
parent 106f57d11e
commit e49d055b5d
2 changed files with 9 additions and 7 deletions

View 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

View File

@ -37,17 +37,19 @@
# 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;