2004-04-13 10:15:43 +08:00
|
|
|
/* Test message queue passing.
|
2023-01-07 05:08:04 +08:00
|
|
|
Copyright (C) 2004-2023 Free Software Foundation, Inc.
|
2004-04-13 10:15:43 +08:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-10 07:18:22 +08:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 13:40:42 +08:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2004-04-13 10:15:43 +08:00
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <mqueue.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
2014-12-20 06:00:59 +08:00
|
|
|
#include <stdint.h>
|
2022-01-15 22:52:41 +08:00
|
|
|
#include <support/check.h>
|
2004-04-13 10:15:43 +08:00
|
|
|
#include "tst-mqueue.h"
|
|
|
|
|
|
|
|
static int
|
|
|
|
intcmp (const void *a, const void *b)
|
|
|
|
{
|
|
|
|
if (*(unsigned char *)a < *(unsigned char *)b)
|
|
|
|
return 1;
|
|
|
|
if (*(unsigned char *)a > *(unsigned char *)b)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
check_attrs (struct mq_attr *attr, int nonblock, long cnt)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
if (attr->mq_maxmsg != 10 || attr->mq_msgsize != 1)
|
|
|
|
{
|
|
|
|
printf ("attributes don't match those passed to mq_open\n"
|
2014-12-20 06:00:59 +08:00
|
|
|
"mq_maxmsg %jd, mq_msgsize %jd\n",
|
|
|
|
(intmax_t) attr->mq_maxmsg, (intmax_t) attr->mq_msgsize);
|
2004-04-13 10:15:43 +08:00
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((attr->mq_flags & O_NONBLOCK) != nonblock)
|
|
|
|
{
|
2014-12-20 06:00:59 +08:00
|
|
|
printf ("mq_flags %jx != %x\n",
|
|
|
|
(intmax_t) (attr->mq_flags & O_NONBLOCK), nonblock);
|
2004-04-13 10:15:43 +08:00
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attr->mq_curmsgs != cnt)
|
|
|
|
{
|
2014-12-20 06:00:59 +08:00
|
|
|
printf ("mq_curmsgs %jd != %ld\n", (intmax_t) attr->mq_curmsgs, cnt);
|
2004-04-13 10:15:43 +08:00
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
do_one_test (mqd_t q, const char *name, int nonblock)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
unsigned char v []
|
|
|
|
= { 0x32, 0x62, 0x22, 0x31, 0x11, 0x73, 0x61, 0x21, 0x72, 0x71, 0x81 };
|
|
|
|
|
|
|
|
struct mq_attr attr;
|
|
|
|
memset (&attr, 0xaa, sizeof (attr));
|
|
|
|
if (mq_getattr (q, &attr) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_getattr failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
Update.
2004-04-16 Jakub Jelinek <jakub@redhat.com>
* misc/syslog.c (vsyslog): Avoid freeing failbuf.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-timer4.
* rt/tst-timer4.c: New test.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/tst-mqueue5.c (rtmin_code): New variable.
(rtmin_handler): Set it.
(thr, do_child, do_test): Also check rtmin_code.
2004-04-14 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue7.
(tst-mqueue7-ARGS): Set.
* rt/tst-mqueue7.c: New test.
2004-04-13 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue5 and tst-mqueue6.
* rt/tst-mqueue1.c (do_one_test): Bitwise or check_attrs () into
result instead of replacing it. Use TEMP_FAILURE_RETRY around
waitpid, kill child if waitpid failed.
(do_test): Bitwise or check_attrs () into result instead of replacing
it. Change temp mq name.
* rt/tst-mqueue5.c: New test.
* rt/tst-mqueue6.c: New test.
* rt/tst-mqueue.h: Include stdio.h, unistd.h, sys/uio.h.
(temp_mq_list, delete_temp_mqs): Remove.
(temp_mq_fd): New variable.
(do_cleanup, do_prepare): New functions.
(add_temp_mq): Rewritten to use a temp file.
(PREPARE): Define.
(CLEANUP_HANDLER): Change to do_cleanup ().
* rt/tst-timer3.c: Don't fail if _POSIX_THREADS is not available.
2004-04-13 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/s390/ffs.c: Include limits.h
2004-04-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SUBSTITUTE_ARGS_1,
SUBSTITUTE_ARGS_2, SUBSTITUTE_ARGS_3, SUBSTITUTE_ARGS_4,
SUBSTITUTE_ARGS_5, SUBSTITUTE_ARGS_6, SUBSTITUTE_ARGS_7): Load
argument values into temporary variables.
2004-04-17 04:44:32 +08:00
|
|
|
result |= check_attrs (&attr, nonblock, 0);
|
2004-04-13 10:15:43 +08:00
|
|
|
|
2007-07-29 04:36:21 +08:00
|
|
|
if (mq_receive (q, (char *) &v[0], 1, NULL) != -1)
|
2004-04-13 10:15:43 +08:00
|
|
|
{
|
|
|
|
puts ("mq_receive on O_WRONLY mqd_t unexpectedly succeeded");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (errno != EBADF)
|
|
|
|
{
|
|
|
|
printf ("mq_receive on O_WRONLY mqd_t did not fail with EBADF: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct timespec ts;
|
|
|
|
if (clock_gettime (CLOCK_REALTIME, &ts) == 0)
|
|
|
|
--ts.tv_sec;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ts.tv_sec = time (NULL) - 1;
|
|
|
|
ts.tv_nsec = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
for (int i = 0; i < 10; ++i)
|
|
|
|
{
|
|
|
|
if (i & 1)
|
2007-07-29 04:36:21 +08:00
|
|
|
ret = mq_send (q, (char *) &v[i], 1, v[i] >> 4);
|
2004-04-13 10:15:43 +08:00
|
|
|
else
|
2007-07-29 04:36:21 +08:00
|
|
|
ret = mq_timedsend (q, (char *) &v[i], 1, v[i] >> 4, &ts);
|
2004-04-13 10:15:43 +08:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
printf ("mq_%ssend failed: %m\n", (i & 1) ? "" : "timed");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-29 04:36:21 +08:00
|
|
|
ret = mq_timedsend (q, (char *) &v[10], 1, 8, &ts);
|
2004-04-13 10:15:43 +08:00
|
|
|
if (ret != -1)
|
|
|
|
{
|
|
|
|
puts ("mq_timedsend on full queue did not fail");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (errno != (nonblock ? EAGAIN : ETIMEDOUT))
|
|
|
|
{
|
|
|
|
printf ("mq_timedsend on full queue did not fail with %s: %m\n",
|
|
|
|
nonblock ? "EAGAIN" : "ETIMEDOUT");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nonblock)
|
|
|
|
{
|
2007-07-29 04:36:21 +08:00
|
|
|
ret = mq_send (q, (char *) &v[10], 1, 8);
|
2004-04-13 10:15:43 +08:00
|
|
|
if (ret != -1)
|
|
|
|
{
|
|
|
|
puts ("mq_send on full non-blocking queue did not fail");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (errno != EAGAIN)
|
|
|
|
{
|
|
|
|
printf ("mq_send on full non-blocking queue did not fail"
|
|
|
|
"with EAGAIN: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset (&attr, 0xaa, sizeof (attr));
|
|
|
|
if (mq_getattr (q, &attr) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_getattr failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
Update.
2004-04-16 Jakub Jelinek <jakub@redhat.com>
* misc/syslog.c (vsyslog): Avoid freeing failbuf.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-timer4.
* rt/tst-timer4.c: New test.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/tst-mqueue5.c (rtmin_code): New variable.
(rtmin_handler): Set it.
(thr, do_child, do_test): Also check rtmin_code.
2004-04-14 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue7.
(tst-mqueue7-ARGS): Set.
* rt/tst-mqueue7.c: New test.
2004-04-13 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue5 and tst-mqueue6.
* rt/tst-mqueue1.c (do_one_test): Bitwise or check_attrs () into
result instead of replacing it. Use TEMP_FAILURE_RETRY around
waitpid, kill child if waitpid failed.
(do_test): Bitwise or check_attrs () into result instead of replacing
it. Change temp mq name.
* rt/tst-mqueue5.c: New test.
* rt/tst-mqueue6.c: New test.
* rt/tst-mqueue.h: Include stdio.h, unistd.h, sys/uio.h.
(temp_mq_list, delete_temp_mqs): Remove.
(temp_mq_fd): New variable.
(do_cleanup, do_prepare): New functions.
(add_temp_mq): Rewritten to use a temp file.
(PREPARE): Define.
(CLEANUP_HANDLER): Change to do_cleanup ().
* rt/tst-timer3.c: Don't fail if _POSIX_THREADS is not available.
2004-04-13 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/s390/ffs.c: Include limits.h
2004-04-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SUBSTITUTE_ARGS_1,
SUBSTITUTE_ARGS_2, SUBSTITUTE_ARGS_3, SUBSTITUTE_ARGS_4,
SUBSTITUTE_ARGS_5, SUBSTITUTE_ARGS_6, SUBSTITUTE_ARGS_7): Load
argument values into temporary variables.
2004-04-17 04:44:32 +08:00
|
|
|
result |= check_attrs (&attr, nonblock, 10);
|
2004-04-13 10:15:43 +08:00
|
|
|
|
|
|
|
pid_t pid = fork ();
|
|
|
|
if (pid == -1)
|
|
|
|
{
|
|
|
|
printf ("fork failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (pid == 0)
|
|
|
|
{
|
|
|
|
result = 0;
|
|
|
|
|
|
|
|
if (mq_close (q) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_close in child failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
q = mq_open (name, O_RDONLY | nonblock);
|
|
|
|
if (q == (mqd_t) -1)
|
|
|
|
{
|
|
|
|
printf ("mq_open in child failed: %m\n");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset (&attr, 0xaa, sizeof (attr));
|
|
|
|
if (mq_getattr (q, &attr) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_getattr failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
Update.
2004-04-16 Jakub Jelinek <jakub@redhat.com>
* misc/syslog.c (vsyslog): Avoid freeing failbuf.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-timer4.
* rt/tst-timer4.c: New test.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/tst-mqueue5.c (rtmin_code): New variable.
(rtmin_handler): Set it.
(thr, do_child, do_test): Also check rtmin_code.
2004-04-14 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue7.
(tst-mqueue7-ARGS): Set.
* rt/tst-mqueue7.c: New test.
2004-04-13 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue5 and tst-mqueue6.
* rt/tst-mqueue1.c (do_one_test): Bitwise or check_attrs () into
result instead of replacing it. Use TEMP_FAILURE_RETRY around
waitpid, kill child if waitpid failed.
(do_test): Bitwise or check_attrs () into result instead of replacing
it. Change temp mq name.
* rt/tst-mqueue5.c: New test.
* rt/tst-mqueue6.c: New test.
* rt/tst-mqueue.h: Include stdio.h, unistd.h, sys/uio.h.
(temp_mq_list, delete_temp_mqs): Remove.
(temp_mq_fd): New variable.
(do_cleanup, do_prepare): New functions.
(add_temp_mq): Rewritten to use a temp file.
(PREPARE): Define.
(CLEANUP_HANDLER): Change to do_cleanup ().
* rt/tst-timer3.c: Don't fail if _POSIX_THREADS is not available.
2004-04-13 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/s390/ffs.c: Include limits.h
2004-04-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SUBSTITUTE_ARGS_1,
SUBSTITUTE_ARGS_2, SUBSTITUTE_ARGS_3, SUBSTITUTE_ARGS_4,
SUBSTITUTE_ARGS_5, SUBSTITUTE_ARGS_6, SUBSTITUTE_ARGS_7): Load
argument values into temporary variables.
2004-04-17 04:44:32 +08:00
|
|
|
result |= check_attrs (&attr, nonblock, 10);
|
2004-04-13 10:15:43 +08:00
|
|
|
|
|
|
|
unsigned char vr[11] = { };
|
|
|
|
unsigned int prio;
|
|
|
|
ssize_t rets;
|
|
|
|
|
2007-07-29 04:36:21 +08:00
|
|
|
if (mq_send (q, (char *) &v[0], 1, 1) != -1)
|
2004-04-13 10:15:43 +08:00
|
|
|
{
|
|
|
|
puts ("mq_send on O_RDONLY mqd_t unexpectedly succeeded");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (errno != EBADF)
|
|
|
|
{
|
|
|
|
printf ("mq_send on O_WRONLY mqd_t did not fail with EBADF: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; ++i)
|
|
|
|
{
|
|
|
|
if (i & 1)
|
2007-07-29 04:36:21 +08:00
|
|
|
rets = mq_receive (q, (char *) &vr[i], 1, &prio);
|
2004-04-13 10:15:43 +08:00
|
|
|
else
|
2007-07-29 04:36:21 +08:00
|
|
|
rets = mq_timedreceive (q, (char *) &vr[i], 1, &prio, &ts);
|
2004-04-13 10:15:43 +08:00
|
|
|
|
|
|
|
if (rets != 1)
|
|
|
|
{
|
|
|
|
if (rets == -1)
|
|
|
|
printf ("mq_%sreceive failed: %m\n", (i & 1) ? "" : "timed");
|
|
|
|
else
|
|
|
|
printf ("mq_%sreceive returned %zd != 1\n",
|
|
|
|
(i & 1) ? "" : "timed", rets);
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (prio != (unsigned int) vr[i] >> 4)
|
|
|
|
{
|
|
|
|
printf ("unexpected priority %x for value %02x\n", prio,
|
|
|
|
vr[i]);
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort (v, 10, 1, intcmp);
|
|
|
|
if (memcmp (v, vr, 10) != 0)
|
|
|
|
{
|
|
|
|
puts ("messages not received in expected order");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
2007-07-29 04:36:21 +08:00
|
|
|
rets = mq_timedreceive (q, (char *) &vr[10], 1, &prio, &ts);
|
2004-04-13 10:15:43 +08:00
|
|
|
if (rets != -1)
|
|
|
|
{
|
|
|
|
puts ("mq_timedreceive on empty queue did not fail");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (errno != (nonblock ? EAGAIN : ETIMEDOUT))
|
|
|
|
{
|
|
|
|
printf ("mq_timedreceive on empty queue did not fail with %s: %m\n",
|
|
|
|
nonblock ? "EAGAIN" : "ETIMEDOUT");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nonblock)
|
|
|
|
{
|
2007-07-29 04:36:21 +08:00
|
|
|
ret = mq_receive (q, (char *) &vr[10], 1, &prio);
|
2004-04-13 10:15:43 +08:00
|
|
|
if (ret != -1)
|
|
|
|
{
|
|
|
|
puts ("mq_receive on empty non-blocking queue did not fail");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (errno != EAGAIN)
|
|
|
|
{
|
|
|
|
printf ("mq_receive on empty non-blocking queue did not fail"
|
|
|
|
"with EAGAIN: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset (&attr, 0xaa, sizeof (attr));
|
|
|
|
if (mq_getattr (q, &attr) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_getattr failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
Update.
2004-04-16 Jakub Jelinek <jakub@redhat.com>
* misc/syslog.c (vsyslog): Avoid freeing failbuf.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-timer4.
* rt/tst-timer4.c: New test.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/tst-mqueue5.c (rtmin_code): New variable.
(rtmin_handler): Set it.
(thr, do_child, do_test): Also check rtmin_code.
2004-04-14 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue7.
(tst-mqueue7-ARGS): Set.
* rt/tst-mqueue7.c: New test.
2004-04-13 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue5 and tst-mqueue6.
* rt/tst-mqueue1.c (do_one_test): Bitwise or check_attrs () into
result instead of replacing it. Use TEMP_FAILURE_RETRY around
waitpid, kill child if waitpid failed.
(do_test): Bitwise or check_attrs () into result instead of replacing
it. Change temp mq name.
* rt/tst-mqueue5.c: New test.
* rt/tst-mqueue6.c: New test.
* rt/tst-mqueue.h: Include stdio.h, unistd.h, sys/uio.h.
(temp_mq_list, delete_temp_mqs): Remove.
(temp_mq_fd): New variable.
(do_cleanup, do_prepare): New functions.
(add_temp_mq): Rewritten to use a temp file.
(PREPARE): Define.
(CLEANUP_HANDLER): Change to do_cleanup ().
* rt/tst-timer3.c: Don't fail if _POSIX_THREADS is not available.
2004-04-13 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/s390/ffs.c: Include limits.h
2004-04-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SUBSTITUTE_ARGS_1,
SUBSTITUTE_ARGS_2, SUBSTITUTE_ARGS_3, SUBSTITUTE_ARGS_4,
SUBSTITUTE_ARGS_5, SUBSTITUTE_ARGS_6, SUBSTITUTE_ARGS_7): Load
argument values into temporary variables.
2004-04-17 04:44:32 +08:00
|
|
|
result |= check_attrs (&attr, nonblock, 0);
|
2004-04-13 10:15:43 +08:00
|
|
|
|
|
|
|
if (mq_close (q) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_close in child failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
int status;
|
Update.
2004-04-16 Jakub Jelinek <jakub@redhat.com>
* misc/syslog.c (vsyslog): Avoid freeing failbuf.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-timer4.
* rt/tst-timer4.c: New test.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/tst-mqueue5.c (rtmin_code): New variable.
(rtmin_handler): Set it.
(thr, do_child, do_test): Also check rtmin_code.
2004-04-14 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue7.
(tst-mqueue7-ARGS): Set.
* rt/tst-mqueue7.c: New test.
2004-04-13 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue5 and tst-mqueue6.
* rt/tst-mqueue1.c (do_one_test): Bitwise or check_attrs () into
result instead of replacing it. Use TEMP_FAILURE_RETRY around
waitpid, kill child if waitpid failed.
(do_test): Bitwise or check_attrs () into result instead of replacing
it. Change temp mq name.
* rt/tst-mqueue5.c: New test.
* rt/tst-mqueue6.c: New test.
* rt/tst-mqueue.h: Include stdio.h, unistd.h, sys/uio.h.
(temp_mq_list, delete_temp_mqs): Remove.
(temp_mq_fd): New variable.
(do_cleanup, do_prepare): New functions.
(add_temp_mq): Rewritten to use a temp file.
(PREPARE): Define.
(CLEANUP_HANDLER): Change to do_cleanup ().
* rt/tst-timer3.c: Don't fail if _POSIX_THREADS is not available.
2004-04-13 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/s390/ffs.c: Include limits.h
2004-04-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SUBSTITUTE_ARGS_1,
SUBSTITUTE_ARGS_2, SUBSTITUTE_ARGS_3, SUBSTITUTE_ARGS_4,
SUBSTITUTE_ARGS_5, SUBSTITUTE_ARGS_6, SUBSTITUTE_ARGS_7): Load
argument values into temporary variables.
2004-04-17 04:44:32 +08:00
|
|
|
if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
|
2004-04-13 10:15:43 +08:00
|
|
|
{
|
|
|
|
printf ("waitpid failed: %m\n");
|
Update.
2004-04-16 Jakub Jelinek <jakub@redhat.com>
* misc/syslog.c (vsyslog): Avoid freeing failbuf.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-timer4.
* rt/tst-timer4.c: New test.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/tst-mqueue5.c (rtmin_code): New variable.
(rtmin_handler): Set it.
(thr, do_child, do_test): Also check rtmin_code.
2004-04-14 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue7.
(tst-mqueue7-ARGS): Set.
* rt/tst-mqueue7.c: New test.
2004-04-13 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue5 and tst-mqueue6.
* rt/tst-mqueue1.c (do_one_test): Bitwise or check_attrs () into
result instead of replacing it. Use TEMP_FAILURE_RETRY around
waitpid, kill child if waitpid failed.
(do_test): Bitwise or check_attrs () into result instead of replacing
it. Change temp mq name.
* rt/tst-mqueue5.c: New test.
* rt/tst-mqueue6.c: New test.
* rt/tst-mqueue.h: Include stdio.h, unistd.h, sys/uio.h.
(temp_mq_list, delete_temp_mqs): Remove.
(temp_mq_fd): New variable.
(do_cleanup, do_prepare): New functions.
(add_temp_mq): Rewritten to use a temp file.
(PREPARE): Define.
(CLEANUP_HANDLER): Change to do_cleanup ().
* rt/tst-timer3.c: Don't fail if _POSIX_THREADS is not available.
2004-04-13 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/s390/ffs.c: Include limits.h
2004-04-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SUBSTITUTE_ARGS_1,
SUBSTITUTE_ARGS_2, SUBSTITUTE_ARGS_3, SUBSTITUTE_ARGS_4,
SUBSTITUTE_ARGS_5, SUBSTITUTE_ARGS_6, SUBSTITUTE_ARGS_7): Load
argument values into temporary variables.
2004-04-17 04:44:32 +08:00
|
|
|
kill (pid, SIGKILL);
|
2004-04-13 10:15:43 +08:00
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (!WIFEXITED (status) || WEXITSTATUS (status))
|
|
|
|
{
|
|
|
|
printf ("child failed: %d\n", status);
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset (&attr, 0xaa, sizeof (attr));
|
|
|
|
if (mq_getattr (q, &attr) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_getattr failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
Update.
2004-04-16 Jakub Jelinek <jakub@redhat.com>
* misc/syslog.c (vsyslog): Avoid freeing failbuf.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-timer4.
* rt/tst-timer4.c: New test.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/tst-mqueue5.c (rtmin_code): New variable.
(rtmin_handler): Set it.
(thr, do_child, do_test): Also check rtmin_code.
2004-04-14 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue7.
(tst-mqueue7-ARGS): Set.
* rt/tst-mqueue7.c: New test.
2004-04-13 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue5 and tst-mqueue6.
* rt/tst-mqueue1.c (do_one_test): Bitwise or check_attrs () into
result instead of replacing it. Use TEMP_FAILURE_RETRY around
waitpid, kill child if waitpid failed.
(do_test): Bitwise or check_attrs () into result instead of replacing
it. Change temp mq name.
* rt/tst-mqueue5.c: New test.
* rt/tst-mqueue6.c: New test.
* rt/tst-mqueue.h: Include stdio.h, unistd.h, sys/uio.h.
(temp_mq_list, delete_temp_mqs): Remove.
(temp_mq_fd): New variable.
(do_cleanup, do_prepare): New functions.
(add_temp_mq): Rewritten to use a temp file.
(PREPARE): Define.
(CLEANUP_HANDLER): Change to do_cleanup ().
* rt/tst-timer3.c: Don't fail if _POSIX_THREADS is not available.
2004-04-13 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/s390/ffs.c: Include limits.h
2004-04-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SUBSTITUTE_ARGS_1,
SUBSTITUTE_ARGS_2, SUBSTITUTE_ARGS_3, SUBSTITUTE_ARGS_4,
SUBSTITUTE_ARGS_5, SUBSTITUTE_ARGS_6, SUBSTITUTE_ARGS_7): Load
argument values into temporary variables.
2004-04-17 04:44:32 +08:00
|
|
|
result |= check_attrs (&attr, nonblock, 0);
|
2004-04-13 10:15:43 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TEST_FUNCTION do_test ()
|
|
|
|
static int
|
|
|
|
do_test (void)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
|
Update.
2004-04-16 Jakub Jelinek <jakub@redhat.com>
* misc/syslog.c (vsyslog): Avoid freeing failbuf.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-timer4.
* rt/tst-timer4.c: New test.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/tst-mqueue5.c (rtmin_code): New variable.
(rtmin_handler): Set it.
(thr, do_child, do_test): Also check rtmin_code.
2004-04-14 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue7.
(tst-mqueue7-ARGS): Set.
* rt/tst-mqueue7.c: New test.
2004-04-13 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue5 and tst-mqueue6.
* rt/tst-mqueue1.c (do_one_test): Bitwise or check_attrs () into
result instead of replacing it. Use TEMP_FAILURE_RETRY around
waitpid, kill child if waitpid failed.
(do_test): Bitwise or check_attrs () into result instead of replacing
it. Change temp mq name.
* rt/tst-mqueue5.c: New test.
* rt/tst-mqueue6.c: New test.
* rt/tst-mqueue.h: Include stdio.h, unistd.h, sys/uio.h.
(temp_mq_list, delete_temp_mqs): Remove.
(temp_mq_fd): New variable.
(do_cleanup, do_prepare): New functions.
(add_temp_mq): Rewritten to use a temp file.
(PREPARE): Define.
(CLEANUP_HANDLER): Change to do_cleanup ().
* rt/tst-timer3.c: Don't fail if _POSIX_THREADS is not available.
2004-04-13 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/s390/ffs.c: Include limits.h
2004-04-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SUBSTITUTE_ARGS_1,
SUBSTITUTE_ARGS_2, SUBSTITUTE_ARGS_3, SUBSTITUTE_ARGS_4,
SUBSTITUTE_ARGS_5, SUBSTITUTE_ARGS_6, SUBSTITUTE_ARGS_7): Load
argument values into temporary variables.
2004-04-17 04:44:32 +08:00
|
|
|
char name[sizeof "/tst-mqueue1-" + sizeof (pid_t) * 3];
|
|
|
|
snprintf (name, sizeof (name), "/tst-mqueue1-%u", getpid ());
|
2004-04-13 10:15:43 +08:00
|
|
|
|
|
|
|
struct mq_attr attr = { .mq_maxmsg = 10, .mq_msgsize = 1 };
|
|
|
|
mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_WRONLY, 0600, &attr);
|
|
|
|
|
|
|
|
if (q == (mqd_t) -1)
|
|
|
|
{
|
2022-01-15 22:52:41 +08:00
|
|
|
if (errno == ENOSYS)
|
|
|
|
FAIL_UNSUPPORTED ("mq_open not supported");
|
|
|
|
|
2004-04-13 10:15:43 +08:00
|
|
|
printf ("mq_open failed with: %m\n");
|
2022-01-15 22:52:41 +08:00
|
|
|
return 1;
|
2004-04-13 10:15:43 +08:00
|
|
|
}
|
2022-01-15 22:52:41 +08:00
|
|
|
|
|
|
|
add_temp_mq (name);
|
2004-04-13 10:15:43 +08:00
|
|
|
|
Update.
2004-04-16 Jakub Jelinek <jakub@redhat.com>
* misc/syslog.c (vsyslog): Avoid freeing failbuf.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-timer4.
* rt/tst-timer4.c: New test.
2004-04-15 Jakub Jelinek <jakub@redhat.com>
* rt/tst-mqueue5.c (rtmin_code): New variable.
(rtmin_handler): Set it.
(thr, do_child, do_test): Also check rtmin_code.
2004-04-14 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue7.
(tst-mqueue7-ARGS): Set.
* rt/tst-mqueue7.c: New test.
2004-04-13 Jakub Jelinek <jakub@redhat.com>
* rt/Makefile (tests): Add tst-mqueue5 and tst-mqueue6.
* rt/tst-mqueue1.c (do_one_test): Bitwise or check_attrs () into
result instead of replacing it. Use TEMP_FAILURE_RETRY around
waitpid, kill child if waitpid failed.
(do_test): Bitwise or check_attrs () into result instead of replacing
it. Change temp mq name.
* rt/tst-mqueue5.c: New test.
* rt/tst-mqueue6.c: New test.
* rt/tst-mqueue.h: Include stdio.h, unistd.h, sys/uio.h.
(temp_mq_list, delete_temp_mqs): Remove.
(temp_mq_fd): New variable.
(do_cleanup, do_prepare): New functions.
(add_temp_mq): Rewritten to use a temp file.
(PREPARE): Define.
(CLEANUP_HANDLER): Change to do_cleanup ().
* rt/tst-timer3.c: Don't fail if _POSIX_THREADS is not available.
2004-04-13 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/s390/ffs.c: Include limits.h
2004-04-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/sysdep.h (SUBSTITUTE_ARGS_1,
SUBSTITUTE_ARGS_2, SUBSTITUTE_ARGS_3, SUBSTITUTE_ARGS_4,
SUBSTITUTE_ARGS_5, SUBSTITUTE_ARGS_6, SUBSTITUTE_ARGS_7): Load
argument values into temporary variables.
2004-04-17 04:44:32 +08:00
|
|
|
result |= do_one_test (q, name, 0);
|
2004-04-13 10:15:43 +08:00
|
|
|
|
|
|
|
mqd_t q2 = mq_open (name, O_WRONLY | O_NONBLOCK);
|
|
|
|
if (q2 == (mqd_t) -1)
|
|
|
|
{
|
|
|
|
printf ("mq_open failed with: %m\n");
|
|
|
|
q2 = q;
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (mq_close (q) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_close in parent failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
q = q2;
|
|
|
|
result |= do_one_test (q, name, O_NONBLOCK);
|
|
|
|
|
|
|
|
if (mq_getattr (q, &attr) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_getattr failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
attr.mq_flags ^= O_NONBLOCK;
|
|
|
|
|
|
|
|
struct mq_attr attr2;
|
|
|
|
memset (&attr2, 0x55, sizeof (attr2));
|
|
|
|
if (mq_setattr (q, &attr, &attr2) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_setattr failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (attr.mq_flags != (attr2.mq_flags ^ O_NONBLOCK)
|
|
|
|
|| attr.mq_maxmsg != attr2.mq_maxmsg
|
|
|
|
|| attr.mq_msgsize != attr2.mq_msgsize
|
|
|
|
|| attr.mq_curmsgs != 0
|
|
|
|
|| attr2.mq_curmsgs != 0)
|
|
|
|
{
|
|
|
|
puts ("mq_setattr returned unexpected values in *omqstat");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result |= do_one_test (q, name, 0);
|
|
|
|
|
|
|
|
if (mq_setattr (q, &attr2, NULL) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_setattr failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result |= do_one_test (q, name, O_NONBLOCK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mq_unlink (name) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_unlink failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mq_close (q) != 0)
|
|
|
|
{
|
|
|
|
printf ("mq_close in parent failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mq_close (q) != -1)
|
|
|
|
{
|
|
|
|
puts ("second mq_close did not fail");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
else if (errno != EBADF)
|
|
|
|
{
|
|
|
|
printf ("second mq_close did not fail with EBADF: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "../test-skeleton.c"
|