[2/3] Fix nptl/tst-sem4: always start with a fresh semaphore.
Commit Message
This just makes sure that if this test fails, new runs of the test will
start from a fresh state.
Comments
On Fri, Dec 05, 2014 at 08:03:42PM +0100, Torvald Riegel wrote:
> This just makes sure that if this test fails, new runs of the test will
> start from a fresh state.
Looks ok.
commit 1ba62510cc2f1459147ec31dda28d45c2ee96abf
Author: Torvald Riegel <triegel@redhat.com>
Date: Tue Jul 29 21:44:58 2014 +0200
Fix nptl/tst-sem4: always start with a fresh semaphore.
@@ -39,6 +39,12 @@ do_test (void)
pid_t pid;
int val;
+ /* Start with a clean slate and register a clean-up action. No need to
+ act if sem_unlink fails because well catch the same problem during the
+ sem_open below. */
+ sem_unlink ("/glibc-tst-sem4");
+ on_exit (remove_sem, (void *) "/glibc-tst-sem4");
+
s = sem_open ("/glibc-tst-sem4", O_CREAT, 0600, 1);
if (s == SEM_FAILED)
{
@@ -59,8 +65,6 @@ do_test (void)
return 1;
}
- on_exit (remove_sem, (void *) "/glibc-tst-sem4");
-
/* We have the semaphore object. Now try again with O_EXCL, this
should fail. */
s2 = sem_open ("/glibc-tst-sem4", O_CREAT | O_EXCL, 0600, 1);