Module Name:src
Committed By: wiz
Date: Tue Dec 14 16:25:11 UTC 2021
Modified Files:
src/tests/lib/librt: t_sem.c
Log Message:
Add expected-fail test for kern/56549
consecutive sem_open() calls do not return the same address
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/librt/t_sem.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/librt/t_sem.c
diff -u src/tests/lib/librt/t_sem.c:1.5 src/tests/lib/librt/t_sem.c:1.6
--- src/tests/lib/librt/t_sem.c:1.5 Thu May 14 08:34:19 2020
+++ src/tests/lib/librt/t_sem.c Tue Dec 14 16:25:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sem.c,v 1.5 2020/05/14 08:34:19 msaitoh Exp $ */
+/* $NetBSD: t_sem.c,v 1.6 2021/12/14 16:25:11 wiz Exp $ */
/*
* Copyright (c) 2008, 2010, 2019 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
#include
__COPYRIGHT("@(#) Copyright (c) 2008, 2010, 2019\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sem.c,v 1.5 2020/05/14 08:34:19 msaitoh Exp $");
+__RCSID("$NetBSD: t_sem.c,v 1.6 2021/12/14 16:25:11 wiz Exp $");
#include
#include
@@ -313,6 +313,32 @@ ATF_TC_CLEANUP(invalid_ops, tc)
(void)sem_unlink("/sem_c");
}
+ATF_TC_WITH_CLEANUP(sem_open_address);
+ATF_TC_HEAD(sem_open_address, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Validate that multiple sem_open calls "
+ "return the same address");
+}
+ATF_TC_BODY(sem_open_address, tc)
+{
+ sem_t *sem, *sem2, *sem3;
+ atf_tc_expect_fail("kern/56549: consecutive sem_open() do not return the same address");
+ sem = sem_open("/sem_d", O_CREAT | O_EXCL, 0777, 0);
+ ATF_REQUIRE(sem != SEM_FAILED);
+ sem2 = sem_open("/sem_d", O_CREAT | O_EXCL, 0777, 0);
+ ATF_REQUIRE(sem2 == SEM_FAILED && errno == EEXIST);
+ sem3 = sem_open("/sem_d", 0);
+ ATF_REQUIRE(sem3 != SEM_FAILED);
+ ATF_REQUIRE(sem == sem3);
+ ATF_REQUIRE_EQ(sem_close(sem3), 0);
+ ATF_REQUIRE_EQ(sem_close(sem), 0);
+ ATF_REQUIRE_EQ(sem_unlink("/sem_d"), 0);
+}
+ATF_TC_CLEANUP(sem_open_address, tc)
+{
+ (void)sem_unlink("/sem_d");
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -320,6 +346,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, child);
ATF_TP_ADD_TC(tp, pshared);
ATF_TP_ADD_TC(tp, invalid_ops);
+ ATF_TP_ADD_TC(tp, sem_open_address);
return atf_no_error();
}