This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


This just makes sure that if this test fails, new runs of the test will
start from a fresh state.
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);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]