[sanitizer] Fix the test on Solaris

On Solaris sem_open on the same name returns the same pointer, and
then sem_close fails the call.
This commit is contained in:
Vitaly Buka 2021-08-12 15:37:07 -07:00
parent b714f73def
commit bf6000dc98
1 changed files with 4 additions and 10 deletions

View File

@ -11,16 +11,10 @@
int main() {
char name[1024];
sprintf(name, "/sem_open_test_%d", getpid());
sem_t *s1 = sem_open(name, O_CREAT, 0644, 123);
assert(s1 != SEM_FAILED);
sem_t *s2 = sem_open(name, O_CREAT, 0644, 123);
assert(s2 != SEM_FAILED);
assert(sem_close(s1) == 0);
assert(sem_close(s2) == 0);
sprintf(name, "/sem_open_test_%zu", (size_t)getpid());
sem_t *s = sem_open(name, O_CREAT, 0644, 123);
assert(s != SEM_FAILED);
assert(sem_close(s) == 0);
assert(sem_unlink(name) == 0);
}