Call sem_unlink on semaphores before attempting to create them

Due to the lack of uniqueness in the semaphore name, and the fact that the
tests don't have cleanup routines, an interrupted test can leave a semaphore
"laying around", causing all subsequent attempts to run the test to fail

I will file a NetBSD PR for this issue soon
This commit is contained in:
Enji Cooper 2014-11-16 06:59:58 +00:00
parent 3eee258dfb
commit e2b4fa14f9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=274579

View File

@ -86,6 +86,9 @@ ATF_TC_BODY(basic, tc)
if (sysconf(_SC_SEMAPHORES) == -1)
atf_tc_skip("POSIX semaphores not supported");
#ifdef __FreeBSD__
sem_unlink("/sem_b");
#endif
sem_b = sem_open("/sem_b", O_CREAT | O_EXCL, 0644, 0);
ATF_REQUIRE(sem_b != SEM_FAILED);
@ -127,6 +130,9 @@ ATF_TC_BODY(child, tc)
if (sysconf(_SC_SEMAPHORES) == -1)
atf_tc_skip("POSIX semaphores not supported");
#ifdef __FreeBSD__
sem_unlink("/sem_a");
#endif
sem_a = sem_open("/sem_a", O_CREAT | O_EXCL, 0644, 0);
ATF_REQUIRE(sem_a != SEM_FAILED);