summaryrefslogtreecommitdiffstats
path: root/tools/regression
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-02-01 08:33:00 -0200
committerRenato Botelho <renato@netgate.com>2016-02-01 08:33:00 -0200
commit79f27b5150f7b79a6f1bcd30e9233f1abb9c3e36 (patch)
tree4aacd7410a3c5961c66492d9c6cb2441e5180961 /tools/regression
parent00da2a1c8c0008725cae2d87abfe17736bf0318a (diff)
parent42ee9ca9933fb815ce7d9098f10bad6fe38c69b4 (diff)
downloadFreeBSD-src-79f27b5150f7b79a6f1bcd30e9233f1abb9c3e36.zip
FreeBSD-src-79f27b5150f7b79a6f1bcd30e9233f1abb9c3e36.tar.gz
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'tools/regression')
-rw-r--r--tools/regression/posixsem2/semtest.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/regression/posixsem2/semtest.c b/tools/regression/posixsem2/semtest.c
index b1255db..0879ff9 100644
--- a/tools/regression/posixsem2/semtest.c
+++ b/tools/regression/posixsem2/semtest.c
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
@@ -14,6 +15,7 @@
int test_unnamed(void);
int test_named(void);
+int test_named2(void);
int
test_unnamed(void)
@@ -94,9 +96,42 @@ test_named(void)
}
int
+test_named2(void)
+{
+ sem_t *s, *s2, *s3;
+
+ printf("testing named process-shared semaphore, O_EXCL cases\n");
+ sem_unlink(SEM_NAME);
+ s = sem_open(SEM_NAME, O_CREAT | O_EXCL, 0777, 0);
+ if (s == SEM_FAILED)
+ err(1, "sem_open failed");
+ s2 = sem_open(SEM_NAME, O_CREAT | O_EXCL, 0777, 0);
+ if (s2 != SEM_FAILED)
+ errx(2, "second sem_open call wrongly succeeded");
+ if (errno != EEXIST)
+ err(3, "second sem_open call failed with wrong errno");
+
+ s3 = sem_open(SEM_NAME, 0);
+ if (s3 == SEM_FAILED)
+ err(4, "third sem_open call failed");
+ if (s != s3)
+ errx(5,
+"two sem_open calls for same semaphore do not return same address");
+ if (sem_close(s3))
+ err(6, "sem_close failed");
+
+ if (sem_close(s))
+ err(7, "sem_close failed");
+
+ printf("OK.\n");
+ return (0);
+}
+
+int
main(void)
{
test_unnamed();
test_named();
+ test_named2();
return (0);
}
OpenPOWER on IntegriCloud