public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: ltp-list@lists.sourceforge.net
Subject: [LTP] [PATCH] Fix rt_sigtimedwait ordering test
Date: Mon,  7 Feb 2011 14:28:46 +0000	[thread overview]
Message-ID: <1297088926-21505-1-git-send-email-will.deacon@arm.com> (raw)

The rt_sigtimedwait test invokes test_masked_matching_rt, which
spawns two children who send consecutive RT signals to the parent.
The test then checks (via sigwaitinfo) that the RT signals are
delivered in the correct order: namely that the lower signal is taken
first.

This test can fail due to a race condition where the parent issues
the sigwaitinfo syscall before the first child has signalled the
parent but after the second child has (due to context switching).
This results in the signals being received in the reverse order.

This patch inserts waitpid syscalls to the parent thread so that the
sigwaitinfo call is only issued after the children have exited.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c    |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
index c0e0241..439dfb3 100644
--- a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
+++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
@@ -232,6 +232,7 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
 	sigset_t sigs, oldmask;
 	siginfo_t si;
 	pid_t child[2];
+	int status;
 
 	signo = SIGRTMIN+1;
 
@@ -250,6 +251,10 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
 	child[0]=create_sig_proc(0, signo, 1);
 	child[1]=create_sig_proc(0, signo+1, 1);
 
+	/* Ensure that the signals have been sent */
+	waitpid(child[0], &status, 0);
+	waitpid(child[1], &status, 0);
+
 	TEST(sigwaitinfo(&sigs, &si, NULL));
 	REPORT_SUCCESS_COND(signo, 0, si.si_pid==child[0] && si.si_code==SI_USER && si.si_signo==signo, "Struct siginfo mismatch");
 
@@ -434,4 +439,4 @@ int main(int argc, char** argv)
 
 	cleanup();
 	tst_exit();
-}
\ No newline at end of file
+}
-- 
1.7.0.4



------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

             reply	other threads:[~2011-02-07 14:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07 14:28 Will Deacon [this message]
2011-02-16 16:43 ` [LTP] [PATCH] Fix rt_sigtimedwait ordering test Will Deacon
     [not found] ` <9151393516569896904@unknownmsgid>
2011-02-23  8:02   ` Garrett Cooper
2011-02-25 10:53     ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1297088926-21505-1-git-send-email-will.deacon@arm.com \
    --to=will.deacon@arm.com \
    --cc=ltp-list@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox