[2/3] Fix nptl/tst-sem4: always start with a fresh semaphore.
diff mbox

Message ID 1417806222.25868.6.camel@triegel.csb
State New
Headers show

Commit Message

Torvald Riegel Dec. 5, 2014, 7:03 p.m. UTC
This just makes sure that if this test fails, new runs of the test will
start from a fresh state.

Comments

Ondřej Bílka Dec. 6, 2014, 1:54 p.m. UTC | #1
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.

Patch
diff mbox

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.

diff --git a/nptl/tst-sem4.c b/nptl/tst-sem4.c
index 72ed97d..5e17d03 100644
--- a/nptl/tst-sem4.c
+++ b/nptl/tst-sem4.c
@@ -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);