Hi ! Here is patch fixing a concurrency issue in semctl07.c. This test was using a key hard coded in the source code, leading to conflicts with other instances of the same test. This patch also add a cleanup of the semid in case of failure during the test.
R. -- Renaud Lottiaux Kerlabs Bâtiment Germanium 80, avenue des buttes de Coësmes 35700 Rennes - France Phone : (+33|0)6 80 89 19 34 Fax : (+33|0)2 99 84 71 71 Email : [EMAIL PROTECTED] Web : http://www.kerlabs.com/
Index: cvs/testcases/kernel/syscalls/ipc/semctl/semctl07.c
===================================================================
--- cvs.orig/testcases/kernel/syscalls/ipc/semctl/semctl07.c 2008-03-10 14:34:07.000000000 +0100
+++ cvs/testcases/kernel/syscalls/ipc/semctl/semctl07.c 2008-03-10 14:49:00.000000000 +0100
@@ -32,6 +32,10 @@
*
* RESTRICTIONS
*
+ * HISTORY
+ * 10/03/2008 Renaud Lottiaux ([EMAIL PROTECTED])
+ * - Fix concurrency issue. A statically defined key was used. Leading
+ * to conflict with other instances of the same test.
*/
@@ -62,6 +66,8 @@
int exp_enos[]={0}; /* List must end with 0 */
+key_t key;
+int semid = -1, nsems;
/*--------------------------------------------------------------*/
@@ -70,8 +76,7 @@
int argc;
char *argv[];
{
- key_t key;
- int semid, nsems, status;
+ int status;
struct semid_ds buf_ds;
union semun {
@@ -84,11 +89,7 @@
setup(); /* temp file is now open */
/*--------------------------------------------------------------*/
- key = nsems = 1;
- if ((semid = semget(key, nsems, SEM_RA|IPC_CREAT)) == -1) {
- tst_resm(TFAIL, "semget() failed errno = %d", errno);
- tst_exit();
- }
+
arg.buf = &buf_ds;
if ((status = semctl(semid, 0, IPC_STAT, arg)) == -1) {
tst_resm(TFAIL, "semctl() failed errno = %d", errno);
@@ -163,12 +164,6 @@
tst_resm(TFAIL, "error: unexpected semzcnt %d", status);
tst_exit();
}
-
- semctl(semid, 0, IPC_RMID, arg);
- if ((status = semctl(semid, 0, GETPID, arg)) != -1) {
- tst_resm(TFAIL, "semctl(IPC_RMID) failed");
- tst_exit();
- }
tst_resm(TPASS, "semctl07 ran successfully!");
/*--------------------------------------------------------------*/
@@ -198,6 +193,22 @@
* before you create your temporary directory.
*/
TEST_PAUSE;
+
+ /*
+ * Create a temporary directory and cd into it.
+ * This helps to ensure that a unique msgkey is created.
+ * See ../lib/libipc.c for more information.
+ */
+ tst_tmpdir();
+
+ /* get an IPC resource key */
+ key = getipckey();
+ nsems = 1;
+
+ if ((semid = semget(key, nsems, SEM_RA|IPC_CREAT)) == -1) {
+ tst_resm(TFAIL, "semget() failed errno = %d", errno);
+ tst_exit();
+ }
}
@@ -208,6 +219,12 @@
void
cleanup()
{
+ /* if it exists, remove the semaphore resouce */
+ rm_sema(semid);
+
+ /* Remove the temporary directory */
+ tst_rmdir();
+
/*
* print timing stats if that option was specified.
* print errno log if that option was specified.
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
