All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP]  [PATCH 1/2] shmctl/shmctl01.c: cleanup
@ 2013-05-23  8:35 DAN LI
  2013-05-23  8:39 ` [LTP] [PATCH 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK DAN LI
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: DAN LI @ 2013-05-23  8:35 UTC (permalink / raw)
  To: LTP list


1. Remove useless comments

2. Revise code to follow ltp-code-style

Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
 testcases/kernel/syscalls/ipc/shmctl/shmctl01.c | 224 +++++++++---------------
 1 file changed, 80 insertions(+), 144 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
index 4a1b064..34ff30c 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
@@ -1,20 +1,19 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
  *
- *   Copyright (c) International Business Machines  Corp., 2001
+ * This program is free software;  you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- *   This program is free software;  you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY;  without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+ * the GNU General Public License for more details.
  *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
- *   the GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program;  if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program;  if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */

 /*
@@ -35,31 +34,13 @@
  *	otherwise,
  *	  if doing functionality testing
  *		call the correct test function
- *	  	if the conditions are correct,
+ *		if the conditions are correct,
  *			issue a PASS message
  *		otherwise
  *			issue a FAIL message
  *	  otherwise
  *	    issue a PASS message
  *	call cleanup
- *
- * USAGE:  <for command-line>
- *  shmctl01 [-c n] [-f] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -f   : Turn off functionality Testing.
- *	       -i n : Execute test n times.
- *	       -I x : Execute test for x seconds.
- *	       -P x : Pause for x seconds between iterations.
- *	       -t   : Turn on syscall timing.
- *
- * HISTORY
- *	03/2001 - Written by Wayne Boyer
- *      02/04/2008 Renaud Lottiaux (Renaud.Lottiaux@kerlabs.com)
- *      - Fix concurrency issue. Replace the sleep used for synchronization
- *        with the new pipe based synchronization functions.
- *
- * RESTRICTIONS
- *	none
  */

 #include "ipcshm.h"
@@ -67,59 +48,53 @@

 char *TCID = "shmctl01";

-int shm_id_1 = -1;
-struct shmid_ds buf;
-long save_time;
+static int shm_id_1 = -1;
+static struct shmid_ds buf;
+static long save_time;

 #define FIRST	0
 #define SECOND	1
-int stat_time;			/* set to either FIRST or SECOND for IPC_STAT tests */
+static int stat_time;

-void *set_shared;
+static void *set_shared;

 #define N_ATTACH	4

-pid_t pid_arr[N_ATTACH];
-int sync_pipes[2];
-
-/*
- * These are the various setup and check functions for the commands
- * that we are checking.
- */
+static pid_t pid_arr[N_ATTACH];
+static int sync_pipes[2];

 /* Setup, cleanup and check routines for IPC_STAT */
-void stat_setup(void), func_stat(void);
-void stat_cleanup(void);
+static void stat_setup(void), func_stat(void);
+static void stat_cleanup(void);

 /* Setup and check routines for IPC_SET */
-void set_setup(void), func_set(void);
+static void set_setup(void), func_set(void);

 /* Check routine for IPC_RMID */
-void func_rmid(void);
+static void func_rmid(void);

 /* Child function */
-void do_child(void);
+static void do_child(void);

-struct test_case_t {
-	int cmd;		/* the command to test */
-	void (*func_test) ();	/* the test function */
-	void (*func_setup) ();	/* the setup function if necessary */
+static struct test_case_t {
+	int cmd;
+	void (*func_test) ();
+	void (*func_setup) ();
 } TC[] = {
-
-	{
-	IPC_STAT, func_stat, stat_setup},
+	{IPC_STAT, func_stat, stat_setup},
 #ifndef UCLINUX
-	    /* The second test is not applicable to uClinux; shared memory segments
-	       are detached on exec(), so cannot be passed to uClinux children. */
-	{
-	IPC_STAT, func_stat, stat_setup},
+	    /*
+	     * The second test is not applicable to uClinux;
+	     * shared memory segments are detached on exec(),
+	     * so cannot be passed to uClinux children.
+	     */
+	{IPC_STAT, func_stat, stat_setup},
 #endif
-	{
-	IPC_SET, func_set, set_setup}, {
-	IPC_RMID, func_rmid, NULL}
+	{IPC_SET, func_set, set_setup},
+	{IPC_RMID, func_rmid, NULL},
 };

-int TST_TOTAL = (sizeof(TC) / sizeof(*TC));
+static int TST_TOTAL = ARRAY_SIZE(TC);

 #define NEWMODE	0066

@@ -128,31 +103,27 @@ int TST_TOTAL = (sizeof(TC) / sizeof(*TC));
 static char *argv0;
 #endif

-static int stat_i;		/* Shared between do_child and stat_setup */
+static int stat_i;

-int main(int ac, char **av)
+int main(int argc, char *argv[])
 {
 	int lc;
 	char *msg;
 	int i;
-	void check_functionality(void);

-	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
+	msg = parse_opts(argc, argv, NULL, NULL);
+	if (msg != NULL)
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 #ifdef UCLINUX
-	argv0 = av[0];
+	argv0 = argv[0];
 	maybe_run_child(do_child, "ddd", &stat_i, &stat_time, &shm_id_1);
 #endif

-	setup();		/* global setup */
-
-	/* The following loop checks looping state if -i option given */
+	setup();

 	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
 		tst_count = 0;

-		/* initialize stat_time */
 		stat_time = FIRST;

 		/*
@@ -160,26 +131,20 @@ int main(int ac, char **av)
 		 * permissions.  Do this here instead of in setup()
 		 * so that looping (-i) will work correctly.
 		 */
-		if ((shm_id_1 = shmget(shmkey, SHM_SIZE, IPC_CREAT | IPC_EXCL |
-				       SHM_RW)) == -1) {
+		shm_id_1 = shmget(shmkey, SHM_SIZE,
+				  IPC_CREAT | IPC_EXCL | SHM_RW);
+		if (shm_id_1 == -1)
 			tst_brkm(TBROK, cleanup, "couldn't create the shared"
 				 " memory segment");
-		}

-		/* loop through the test cases */
 		for (i = 0; i < TST_TOTAL; i++) {

 			/*
 			 * if needed, set up any required conditions by
 			 * calling the appropriate setup function
 			 */
-			if (TC[i].func_setup != NULL) {
+			if (TC[i].func_setup != NULL)
 				(*TC[i].func_setup) ();
-			}
-
-			/*
-			 * Use TEST macro to make the call
-			 */

 			TEST(shmctl(shm_id_1, TC[i].cmd, &buf));

@@ -217,7 +182,7 @@ int main(int ac, char **av)
  *		 this seperate routine to avoid code duplication in
  *		 stat_setup() below.
  */
-void *set_shmat()
+void *set_shmat(void)
 {
 	void *rval;

@@ -241,7 +206,7 @@ void *set_shmat()
  *		  Make things interesting by forking some children
  *		  that will either attach or inherit the shared memory.
  */
-void stat_setup()
+void stat_setup(void)
 {
 	void *set_shmat();
 	pid_t pid;
@@ -252,34 +217,32 @@ void stat_setup()
 	 * the children inherit the memory.
 	 */

-	if (stat_time == SECOND) {
+	if (stat_time == SECOND)
 		/*
 		 * use the global "set_shared" variable here so that
 		 * it can be removed in the stat_func() routine.
 		 */
 		set_shared = set_shmat();
-	}

 	tst_flush();
 	for (stat_i = 0; stat_i < N_ATTACH; stat_i++) {
 		if (sync_pipe_create(sync_pipes, PIPE_NAME) == -1)
 			tst_brkm(TBROK, cleanup, "sync_pipe_create failed");

-		if ((pid = FORK_OR_VFORK()) == -1) {
+		pid = FORK_OR_VFORK();
+		if (pid == -1)
 			tst_brkm(TBROK, cleanup, "could not fork");
-		}

-		if (pid == 0) {	/* child */
+		if (pid == 0) {
 #ifdef UCLINUX
 			if (self_exec(argv0, "ddd", stat_i, stat_time,
-				      shm_id_1) < 0) {
+				      shm_id_1) < 0)
 				tst_brkm(TBROK, cleanup, "could not self_exec");
-			}
 #else
 			do_child();
 #endif

-		} else {	/* parent */
+		} else {
 			/* save the child's pid for cleanup later */
 			pid_arr[stat_i] = pid;
 			if (sync_pipe_wait(sync_pipes) == -1)
@@ -295,12 +258,8 @@ void stat_setup()
 	sleep(1);
 }

-/*
- * do_child
- */
-void do_child()
+void do_child(void)
 {
-	int rval;
 	void *test;

 #ifdef UCLINUX
@@ -308,11 +267,10 @@ void do_child()
 		tst_brkm(TBROK, cleanup, "sync_pipe_create failed");
 #endif

-	if (stat_time == FIRST) {
+	if (stat_time == FIRST)
 		test = set_shmat();
-	} else {
+	else
 		test = set_shared;
-	}

 	if (sync_pipe_notify(sync_pipes) == -1)
 		tst_brkm(TBROK, cleanup, "sync_pipe_notify failed");
@@ -323,16 +281,15 @@ void do_child()
 #endif
 		tst_brkm(TBROK, cleanup, "sync_pipe_close failed");

-	/* do an assignement for fun */
 	memcpy(test, &stat_i, sizeof(stat_i));

 	/* pause until we get a signal from stat_cleanup() */
-	rval = pause();
+	pause();

 	/* now we're back - detach the memory and exit */
-	if (shmdt(test) == -1) {
+	if (shmdt(test) == -1)
 		tst_resm(TBROK, "shmdt() failed - %d", errno);
-	}
+
 	tst_exit();
 }

@@ -341,7 +298,7 @@ void do_child()
  *		 by looking at the pid of the creator, the segement size,
  *		 the number of attaches and the mode.
  */
-void func_stat()
+void func_stat(void)
 {
 	int fail = 0;
 	pid_t pid;
@@ -373,7 +330,8 @@ void func_stat()
 	}

 	/* use MODE_MASK to make sure we are comparing the last 9 bits */
-	if (!fail && (buf.shm_perm.mode & MODE_MASK) != ((SHM_RW) & MODE_MASK)) {
+	if (!fail && (buf.shm_perm.mode & MODE_MASK) !=
+			((SHM_RW) & MODE_MASK)) {
 		tst_resm(TFAIL, "segment mode is incorrect");
 		fail = 1;
 	}
@@ -383,9 +341,8 @@ void func_stat()
 	/* save the change time for use in the next test */
 	save_time = buf.shm_ctime;

-	if (fail) {
+	if (fail)
 		return;
-	}

 	tst_resm(TPASS, "pid, size, # of attaches and mode are correct "
 		 "- pass #%d", stat_time);
@@ -396,22 +353,20 @@ void func_stat()
  *		    have the parent make dessert, er, um, make that remove
  *		    the shared memory that is no longer needed.
  */
-void stat_cleanup()
+void stat_cleanup(void)
 {
 	int i;

 	/* wake up the childern so they can detach the memory and exit */
 	for (i = 0; i < N_ATTACH; i++) {
-		if (kill(pid_arr[i], SIGUSR1) == -1) {
+		if (kill(pid_arr[i], SIGUSR1) == -1)
 			tst_brkm(TBROK, cleanup, "kill failed");
-		}
 	}

 	/* remove the parent's shared memory the second time through */
 	if (stat_time == SECOND) {
-		if (shmdt(set_shared) == -1) {
+		if (shmdt(set_shared) == -1)
 			tst_resm(TINFO, "shmdt() failed");
-		}
 	}

 	for (i = 0; i < N_ATTACH; i++) {
@@ -425,7 +380,7 @@ void stat_cleanup()
 /*
  * set_setup() - set up for the IPC_SET command with shmctl()
  */
-void set_setup()
+void set_setup(void)
 {
 	/* set up a new mode for the shared memory segment */
 	buf.shm_perm.mode = SHM_RW | NEWMODE;
@@ -437,7 +392,7 @@ void set_setup()
 /*
  * func_set() - check the functionality of the IPC_SET command with shmctl()
  */
-void func_set()
+void func_set(void)
 {
 	int fail = 0;

@@ -447,7 +402,8 @@ void func_set()
 		return;
 	}

-	if ((buf.shm_perm.mode & MODE_MASK) != ((SHM_RW | NEWMODE) & MODE_MASK)) {
+	if ((buf.shm_perm.mode & MODE_MASK) !=
+			((SHM_RW | NEWMODE) & MODE_MASK)) {
 		tst_resm(TFAIL, "new mode is incorrect");
 		fail = 1;
 	}
@@ -457,9 +413,8 @@ void func_set()
 		fail = 1;
 	}

-	if (fail) {
+	if (fail)
 		return;
-	}

 	tst_resm(TPASS, "new mode and change time are correct");
 }
@@ -467,18 +422,16 @@ void func_set()
 /*
  * func_rmid() - check the functionality of the IPC_RMID command with shmctl()
  */
-void func_rmid()
+void func_rmid(void)
 {
 	/* Do another shmctl() - we should get EINVAL */
-	if (shmctl(shm_id_1, IPC_STAT, &buf) != -1) {
+	if (shmctl(shm_id_1, IPC_STAT, &buf) != -1)
 		tst_brkm(TBROK, cleanup, "shmctl succeeded on expected fail");
-	}

-	if (errno != EINVAL) {
+	if (errno != EINVAL)
 		tst_resm(TFAIL, "returned unexpected errno %d", errno);
-	} else {
+	else
 		tst_resm(TPASS, "shared memory appears to be removed");
-	}

 	shm_id_1 = -1;
 }
@@ -486,7 +439,7 @@ void func_rmid()
 /*
  * sighandler() - handle signals, in this case SIGUSR1 is the only one expected
  */
-void sighandler(sig)
+void sighandler(int sig)
 {
 	if (sig != SIGUSR1)
 		tst_resm(TBROK, "received unexpected signal %d", sig);
@@ -494,37 +447,20 @@ void sighandler(sig)

 void setup(void)
 {
-
 	tst_sig(FORK, sighandler, cleanup);

 	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 */
 	shmkey = getipckey();
 }

-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
 void cleanup(void)
 {
-	/* if it exists, remove the shared memory segment */
 	rm_shm(shm_id_1);

 	tst_rmdir();

-	/*
-	 * print timing stats if that option was specified.
-	 * print errno log if that option was specified.
-	 */
 	TEST_CLEANUP;
-
 }
-- 
1.8.1

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [LTP]  [PATCH 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
  2013-05-23  8:35 [LTP] [PATCH 1/2] shmctl/shmctl01.c: cleanup DAN LI
@ 2013-05-23  8:39 ` DAN LI
  2013-05-23 13:01   ` Jan Stancek
  2013-05-24  5:23 ` [LTP] [PATCH V2 " DAN LI
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: DAN LI @ 2013-05-23  8:39 UTC (permalink / raw)
  To: LTP list


Additional tests for features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.


Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
 testcases/kernel/syscalls/ipc/shmctl/shmctl01.c | 83 ++++++++++++++++++++++---
 1 file changed, 75 insertions(+), 8 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
index 34ff30c..c0f2c81 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
@@ -43,13 +43,18 @@
  *	call cleanup
  */

+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 #include "ipcshm.h"
 #include "libtestsuite.h"

 char *TCID = "shmctl01";

 static int shm_id_1 = -1;
+static int shm_index;
 static struct shmid_ds buf;
+static struct shminfo info;
 static long save_time;

 #define FIRST	0
@@ -64,12 +69,24 @@ static pid_t pid_arr[N_ATTACH];
 static int sync_pipes[2];

 /* Setup, cleanup and check routines for IPC_STAT */
-static void stat_setup(void), func_stat(void);
+static void stat_setup(void), func_istat(void);
 static void stat_cleanup(void);

 /* Setup and check routines for IPC_SET */
 static void set_setup(void), func_set(void);

+/* Check routine for IPC_INFO */
+static void func_info(void);
+
+/* Check routine for SHM_STAT */
+static void func_sstat(void);
+
+/* Check routine for SHM_LOCK */
+static void func_lock(void);
+
+/* Check routine for SHM_UNLOCK */
+static void func_unlock(void);
+
 /* Check routine for IPC_RMID */
 static void func_rmid(void);

@@ -77,21 +94,27 @@ static void func_rmid(void);
 static void do_child(void);

 static struct test_case_t {
+	int *shmid;
 	int cmd;
+	struct shmid_ds *arg;
 	void (*func_test) ();
 	void (*func_setup) ();
 } TC[] = {
-	{IPC_STAT, func_stat, stat_setup},
+	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
 #ifndef UCLINUX
 	    /*
 	     * The second test is not applicable to uClinux;
 	     * shared memory segments are detached on exec(),
 	     * so cannot be passed to uClinux children.
 	     */
-	{IPC_STAT, func_stat, stat_setup},
+	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
 #endif
-	{IPC_SET, func_set, set_setup},
-	{IPC_RMID, func_rmid, NULL},
+	{&shm_id_1, IPC_SET, &buf, func_set, set_setup},
+	{&shm_id_1, IPC_INFO, (struct shmid_ds *) &info, func_info, NULL},
+	{&shm_index, SHM_STAT, &buf, func_sstat, NULL},
+	{&shm_id_1, SHM_LOCK, &buf, func_lock, NULL},
+	{&shm_id_1, SHM_UNLOCK, &buf, func_unlock, NULL},
+	{&shm_id_1, IPC_RMID, &buf, func_rmid, NULL},
 };

 static int TST_TOTAL = ARRAY_SIZE(TC);
@@ -146,7 +169,7 @@ int main(int argc, char *argv[])
 			if (TC[i].func_setup != NULL)
 				(*TC[i].func_setup) ();

-			TEST(shmctl(shm_id_1, TC[i].cmd, &buf));
+			TEST(shmctl(*(TC[i].shmid), TC[i].cmd, TC[i].arg));

 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL, "%s call failed - errno "
@@ -294,11 +317,11 @@ void do_child(void)
 }

 /*
- * func_stat() - check the functionality of the IPC_STAT command with shmctl()
+ * func_istat() - check the functionality of the IPC_STAT command with shmctl()
  *		 by looking at the pid of the creator, the segement size,
  *		 the number of attaches and the mode.
  */
-void func_stat(void)
+void func_istat(void)
 {
 	int fail = 0;
 	pid_t pid;
@@ -419,6 +442,50 @@ void func_set(void)
 	tst_resm(TPASS, "new mode and change time are correct");
 }

+
+static void func_info(void)
+{
+	if (info.shmmin != 1)
+		tst_resm(TFAIL, "value of shmmin is incorrect");
+	else
+		tst_resm(TPASS, "get correct shared memory limits");
+}
+
+static void func_sstat(void)
+{
+	if (buf.shm_segsz != SHM_SIZE)
+		tst_resm(TFAIL, "segment size is incorrect");
+	else
+		tst_resm(TPASS, "size of attache is correct");
+}
+
+static void func_lock(void)
+{
+	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
+		tst_resm(TBROK, "stat failed in func_lock()");
+		return;
+	}
+
+	if (buf.shm_perm.mode & SHM_LOCKED)
+		tst_resm(TPASS, "SHM_LOCK is setted");
+	else
+		tst_resm(TFAIL, "SHM_LOCK is not setted");
+}
+
+static void func_unlock(void)
+{
+	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
+		tst_resm(TBROK, "stat failed in func_unlock()");
+		return;
+	}
+
+	if (buf.shm_perm.mode & SHM_LOCKED)
+		tst_resm(TFAIL, "SHM_LOCK is not cleared");
+	else
+		tst_resm(TPASS, "SHM_LOCK is cleared");
+}
+
+
 /*
  * func_rmid() - check the functionality of the IPC_RMID command with shmctl()
  */
-- 
1.8.1

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
  2013-05-23  8:39 ` [LTP] [PATCH 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK DAN LI
@ 2013-05-23 13:01   ` Jan Stancek
  2013-05-24  5:18     ` DAN LI
  0 siblings, 1 reply; 10+ messages in thread
From: Jan Stancek @ 2013-05-23 13:01 UTC (permalink / raw)
  To: DAN LI; +Cc: LTP list



----- Original Message -----
> From: "DAN LI" <li.dan@cn.fujitsu.com>
> To: "LTP list" <ltp-list@lists.sourceforge.net>
> Sent: Thursday, 23 May, 2013 10:39:28 AM
> Subject: [LTP]  [PATCH 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
> 
> 
> Additional tests for features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
> 
> 
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>

Hi,

1/2 cleanup looks OK to me, comments for 2/2 are inline.

> ---
>  testcases/kernel/syscalls/ipc/shmctl/shmctl01.c | 83
>  ++++++++++++++++++++++---
>  1 file changed, 75 insertions(+), 8 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> index 34ff30c..c0f2c81 100644
> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> @@ -43,13 +43,18 @@
>   *	call cleanup
>   */
> 
> +#ifndef _GNU_SOURCE
> +#define _GNU_SOURCE
> +#endif
>  #include "ipcshm.h"
>  #include "libtestsuite.h"
> 
>  char *TCID = "shmctl01";
> 
>  static int shm_id_1 = -1;
> +static int shm_index;
>  static struct shmid_ds buf;
> +static struct shminfo info;
>  static long save_time;
> 
>  #define FIRST	0
> @@ -64,12 +69,24 @@ static pid_t pid_arr[N_ATTACH];
>  static int sync_pipes[2];
> 
>  /* Setup, cleanup and check routines for IPC_STAT */
> -static void stat_setup(void), func_stat(void);
> +static void stat_setup(void), func_istat(void);
>  static void stat_cleanup(void);
> 
>  /* Setup and check routines for IPC_SET */
>  static void set_setup(void), func_set(void);
> 
> +/* Check routine for IPC_INFO */
> +static void func_info(void);
> +
> +/* Check routine for SHM_STAT */
> +static void func_sstat(void);
> +
> +/* Check routine for SHM_LOCK */
> +static void func_lock(void);
> +
> +/* Check routine for SHM_UNLOCK */
> +static void func_unlock(void);
> +
>  /* Check routine for IPC_RMID */
>  static void func_rmid(void);
> 
> @@ -77,21 +94,27 @@ static void func_rmid(void);
>  static void do_child(void);
> 
>  static struct test_case_t {
> +	int *shmid;
>  	int cmd;
> +	struct shmid_ds *arg;
>  	void (*func_test) ();
>  	void (*func_setup) ();
>  } TC[] = {
> -	{IPC_STAT, func_stat, stat_setup},
> +	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
>  #ifndef UCLINUX
>  	    /*
>  	     * The second test is not applicable to uClinux;
>  	     * shared memory segments are detached on exec(),
>  	     * so cannot be passed to uClinux children.
>  	     */
> -	{IPC_STAT, func_stat, stat_setup},
> +	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
>  #endif
> -	{IPC_SET, func_set, set_setup},
> -	{IPC_RMID, func_rmid, NULL},
> +	{&shm_id_1, IPC_SET, &buf, func_set, set_setup},
> +	{&shm_id_1, IPC_INFO, (struct shmid_ds *) &info, func_info, NULL},
> +	{&shm_index, SHM_STAT, &buf, func_sstat, NULL},
> +	{&shm_id_1, SHM_LOCK, &buf, func_lock, NULL},
> +	{&shm_id_1, SHM_UNLOCK, &buf, func_unlock, NULL},
> +	{&shm_id_1, IPC_RMID, &buf, func_rmid, NULL},
>  };

Are last 3 cases actually using buf?

> 
>  static int TST_TOTAL = ARRAY_SIZE(TC);
> @@ -146,7 +169,7 @@ int main(int argc, char *argv[])
>  			if (TC[i].func_setup != NULL)
>  				(*TC[i].func_setup) ();
> 
> -			TEST(shmctl(shm_id_1, TC[i].cmd, &buf));
> +			TEST(shmctl(*(TC[i].shmid), TC[i].cmd, TC[i].arg));
> 
>  			if (TEST_RETURN == -1) {
>  				tst_resm(TFAIL, "%s call failed - errno "
> @@ -294,11 +317,11 @@ void do_child(void)
>  }
> 
>  /*
> - * func_stat() - check the functionality of the IPC_STAT command with
> shmctl()
> + * func_istat() - check the functionality of the IPC_STAT command with
> shmctl()
>   *		 by looking at the pid of the creator, the segement size,
>   *		 the number of attaches and the mode.
>   */
> -void func_stat(void)
> +void func_istat(void)
>  {
>  	int fail = 0;
>  	pid_t pid;
> @@ -419,6 +442,50 @@ void func_set(void)
>  	tst_resm(TPASS, "new mode and change time are correct");
>  }
> 
> +
> +static void func_info(void)
> +{
> +	if (info.shmmin != 1)
> +		tst_resm(TFAIL, "value of shmmin is incorrect");
> +	else
> +		tst_resm(TPASS, "get correct shared memory limits");
> +}
> +
> +static void func_sstat(void)
> +{
> +	if (buf.shm_segsz != SHM_SIZE)

I think this will work only if there are no shared memory segments before
test starts. Because shm_index == 0, this will check first one:

# ipcs -m
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0xffffffff 134971392  root       600        4          0                       

# ./shmctl01 
shmctl01    1  TPASS  :  pid, size, # of attaches and mode are correct - pass #1
shmctl01    2  TPASS  :  pid, size, # of attaches and mode are correct - pass #2
shmctl01    3  TPASS  :  new mode and change time are correct
shmctl01    4  TPASS  :  get correct shared memory limits
shmctl01    5  TFAIL  :  segment size is incorrect
shmctl01    6  TPASS  :  SHM_LOCK is setted
shmctl01    7  TPASS  :  SHM_LOCK is cleared
shmctl01    8  TPASS  :  shared memory appears to be removed

> +		tst_resm(TFAIL, "segment size is incorrect");
> +	else
> +		tst_resm(TPASS, "size of attache is correct");
> +}
> +
> +static void func_lock(void)
> +{
> +	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
> +		tst_resm(TBROK, "stat failed in func_lock()");
> +		return;
> +	}
> +
> +	if (buf.shm_perm.mode & SHM_LOCKED)
> +		tst_resm(TPASS, "SHM_LOCK is setted");

Just "set", I suggest: SHM_LOCKED flag is set/cleared

Regards,
Jan

> +	else
> +		tst_resm(TFAIL, "SHM_LOCK is not setted");
> +}
> +
> +static void func_unlock(void)
> +{
> +	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
> +		tst_resm(TBROK, "stat failed in func_unlock()");
> +		return;
> +	}
> +
> +	if (buf.shm_perm.mode & SHM_LOCKED)
> +		tst_resm(TFAIL, "SHM_LOCK is not cleared");
> +	else
> +		tst_resm(TPASS, "SHM_LOCK is cleared");
> +}
> +
> +
>  /*
>   * func_rmid() - check the functionality of the IPC_RMID command with
>   shmctl()
>   */
> --
> 1.8.1
> 
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
  2013-05-23 13:01   ` Jan Stancek
@ 2013-05-24  5:18     ` DAN LI
  0 siblings, 0 replies; 10+ messages in thread
From: DAN LI @ 2013-05-24  5:18 UTC (permalink / raw)
  To: Jan Stancek; +Cc: LTP list

On 05/23/2013 09:01 PM, Jan Stancek wrote:
> 
> 
> ----- Original Message -----
>> From: "DAN LI" <li.dan@cn.fujitsu.com>
>> To: "LTP list" <ltp-list@lists.sourceforge.net>
>> Sent: Thursday, 23 May, 2013 10:39:28 AM
>> Subject: [LTP]  [PATCH 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
>>
>>
>> Additional tests for features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
>>
>>
>> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
> 
> Hi,
> 
> 1/2 cleanup looks OK to me, comments for 2/2 are inline.
> 
>> ---
>>  testcases/kernel/syscalls/ipc/shmctl/shmctl01.c | 83
>>  ++++++++++++++++++++++---
>>  1 file changed, 75 insertions(+), 8 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
>> b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
>> index 34ff30c..c0f2c81 100644
>> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
>> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
>> @@ -43,13 +43,18 @@
>>   *	call cleanup
>>   */
>>
>> +#ifndef _GNU_SOURCE
>> +#define _GNU_SOURCE
>> +#endif
>>  #include "ipcshm.h"
>>  #include "libtestsuite.h"
>>
>>  char *TCID = "shmctl01";
>>
>>  static int shm_id_1 = -1;
>> +static int shm_index;
>>  static struct shmid_ds buf;
>> +static struct shminfo info;
>>  static long save_time;
>>
>>  #define FIRST	0
>> @@ -64,12 +69,24 @@ static pid_t pid_arr[N_ATTACH];
>>  static int sync_pipes[2];
>>
>>  /* Setup, cleanup and check routines for IPC_STAT */
>> -static void stat_setup(void), func_stat(void);
>> +static void stat_setup(void), func_istat(void);
>>  static void stat_cleanup(void);
>>
>>  /* Setup and check routines for IPC_SET */
>>  static void set_setup(void), func_set(void);
>>
>> +/* Check routine for IPC_INFO */
>> +static void func_info(void);
>> +
>> +/* Check routine for SHM_STAT */
>> +static void func_sstat(void);
>> +
>> +/* Check routine for SHM_LOCK */
>> +static void func_lock(void);
>> +
>> +/* Check routine for SHM_UNLOCK */
>> +static void func_unlock(void);
>> +
>>  /* Check routine for IPC_RMID */
>>  static void func_rmid(void);
>>
>> @@ -77,21 +94,27 @@ static void func_rmid(void);
>>  static void do_child(void);
>>
>>  static struct test_case_t {
>> +	int *shmid;
>>  	int cmd;
>> +	struct shmid_ds *arg;
>>  	void (*func_test) ();
>>  	void (*func_setup) ();
>>  } TC[] = {
>> -	{IPC_STAT, func_stat, stat_setup},
>> +	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
>>  #ifndef UCLINUX
>>  	    /*
>>  	     * The second test is not applicable to uClinux;
>>  	     * shared memory segments are detached on exec(),
>>  	     * so cannot be passed to uClinux children.
>>  	     */
>> -	{IPC_STAT, func_stat, stat_setup},
>> +	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
>>  #endif
>> -	{IPC_SET, func_set, set_setup},
>> -	{IPC_RMID, func_rmid, NULL},
>> +	{&shm_id_1, IPC_SET, &buf, func_set, set_setup},
>> +	{&shm_id_1, IPC_INFO, (struct shmid_ds *) &info, func_info, NULL},
>> +	{&shm_index, SHM_STAT, &buf, func_sstat, NULL},
>> +	{&shm_id_1, SHM_LOCK, &buf, func_lock, NULL},
>> +	{&shm_id_1, SHM_UNLOCK, &buf, func_unlock, NULL},
>> +	{&shm_id_1, IPC_RMID, &buf, func_rmid, NULL},
>>  };
> 
> Are last 3 cases actually using buf?

Actually, not used...

Passing NULL to shmctl is just ok.

> 
>>
>>  static int TST_TOTAL = ARRAY_SIZE(TC);
>> @@ -146,7 +169,7 @@ int main(int argc, char *argv[])
>>  			if (TC[i].func_setup != NULL)
>>  				(*TC[i].func_setup) ();
>>
>> -			TEST(shmctl(shm_id_1, TC[i].cmd, &buf));
>> +			TEST(shmctl(*(TC[i].shmid), TC[i].cmd, TC[i].arg));
>>
>>  			if (TEST_RETURN == -1) {
>>  				tst_resm(TFAIL, "%s call failed - errno "
>> @@ -294,11 +317,11 @@ void do_child(void)
>>  }
>>
>>  /*
>> - * func_stat() - check the functionality of the IPC_STAT command with
>> shmctl()
>> + * func_istat() - check the functionality of the IPC_STAT command with
>> shmctl()
>>   *		 by looking at the pid of the creator, the segement size,
>>   *		 the number of attaches and the mode.
>>   */
>> -void func_stat(void)
>> +void func_istat(void)
>>  {
>>  	int fail = 0;
>>  	pid_t pid;
>> @@ -419,6 +442,50 @@ void func_set(void)
>>  	tst_resm(TPASS, "new mode and change time are correct");
>>  }
>>
>> +
>> +static void func_info(void)
>> +{
>> +	if (info.shmmin != 1)
>> +		tst_resm(TFAIL, "value of shmmin is incorrect");
>> +	else
>> +		tst_resm(TPASS, "get correct shared memory limits");
>> +}
>> +
>> +static void func_sstat(void)
>> +{
>> +	if (buf.shm_segsz != SHM_SIZE)
> 
> I think this will work only if there are no shared memory segments before
> test starts. Because shm_index == 0, this will check first one:

You are right.

I will get the functionality test of SHM_STAT to check if shmctl returns correct
shared memory id.

> 
> # ipcs -m
> ------ Shared Memory Segments --------
> key        shmid      owner      perms      bytes      nattch     status      
> 0xffffffff 134971392  root       600        4          0                       
> 
> # ./shmctl01 
> shmctl01    1  TPASS  :  pid, size, # of attaches and mode are correct - pass #1
> shmctl01    2  TPASS  :  pid, size, # of attaches and mode are correct - pass #2
> shmctl01    3  TPASS  :  new mode and change time are correct
> shmctl01    4  TPASS  :  get correct shared memory limits
> shmctl01    5  TFAIL  :  segment size is incorrect
> shmctl01    6  TPASS  :  SHM_LOCK is setted
> shmctl01    7  TPASS  :  SHM_LOCK is cleared
> shmctl01    8  TPASS  :  shared memory appears to be removed
> 
>> +		tst_resm(TFAIL, "segment size is incorrect");
>> +	else
>> +		tst_resm(TPASS, "size of attache is correct");
>> +}
>> +
>> +static void func_lock(void)
>> +{
>> +	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
>> +		tst_resm(TBROK, "stat failed in func_lock()");
>> +		return;
>> +	}
>> +
>> +	if (buf.shm_perm.mode & SHM_LOCKED)
>> +		tst_resm(TPASS, "SHM_LOCK is setted");
> 
> Just "set", I suggest: SHM_LOCKED flag is set/cleared
> 
Ok.

Thank you for reviewing. :)

Regards,
DAN LI

> Regards,
> Jan
> 
>> +	else
>> +		tst_resm(TFAIL, "SHM_LOCK is not setted");
>> +}
>> +
>> +static void func_unlock(void)
>> +{
>> +	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
>> +		tst_resm(TBROK, "stat failed in func_unlock()");
>> +		return;
>> +	}
>> +
>> +	if (buf.shm_perm.mode & SHM_LOCKED)
>> +		tst_resm(TFAIL, "SHM_LOCK is not cleared");
>> +	else
>> +		tst_resm(TPASS, "SHM_LOCK is cleared");
>> +}
>> +
>> +
>>  /*
>>   * func_rmid() - check the functionality of the IPC_RMID command with
>>   shmctl()
>>   */
>> --
>> 1.8.1
>>
>> ------------------------------------------------------------------------------
>> Try New Relic Now & We'll Send You this Cool Shirt
>> New Relic is the only SaaS-based application performance monitoring service
>> that delivers powerful full stack analytics. Optimize and monitor your
>> browser, app, & servers with just a few lines of code. Try New Relic
>> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
>> _______________________________________________
>> Ltp-list mailing list
>> Ltp-list@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/ltp-list
>>
> 



------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP]  [PATCH V2 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
  2013-05-23  8:35 [LTP] [PATCH 1/2] shmctl/shmctl01.c: cleanup DAN LI
  2013-05-23  8:39 ` [LTP] [PATCH 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK DAN LI
@ 2013-05-24  5:23 ` DAN LI
  2013-05-24  8:02   ` Jan Stancek
  2013-05-24  9:50 ` [LTP] [PATCH V3 " DAN LI
  2013-05-24 12:46 ` [LTP] [PATCH 1/2] shmctl/shmctl01.c: cleanup Wanlong Gao
  3 siblings, 1 reply; 10+ messages in thread
From: DAN LI @ 2013-05-24  5:23 UTC (permalink / raw)
  To: ltp-list



Additional tests for features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.


Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
 testcases/kernel/syscalls/ipc/shmctl/shmctl01.c | 87 ++++++++++++++++++++++---
 1 file changed, 78 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
index 34ff30c..55711a7 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
@@ -43,13 +43,18 @@
  *	call cleanup
  */

+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 #include "ipcshm.h"
 #include "libtestsuite.h"

 char *TCID = "shmctl01";

 static int shm_id_1 = -1;
+static int shm_index;
 static struct shmid_ds buf;
+static struct shminfo info;
 static long save_time;

 #define FIRST	0
@@ -64,12 +69,24 @@ static pid_t pid_arr[N_ATTACH];
 static int sync_pipes[2];

 /* Setup, cleanup and check routines for IPC_STAT */
-static void stat_setup(void), func_stat(void);
+static void stat_setup(void), func_istat(void);
 static void stat_cleanup(void);

 /* Setup and check routines for IPC_SET */
 static void set_setup(void), func_set(void);

+/* Check routine for IPC_INFO */
+static void func_info(void);
+
+/* Check routine for SHM_STAT */
+static void func_sstat(int shmid);
+
+/* Check routine for SHM_LOCK */
+static void func_lock(void);
+
+/* Check routine for SHM_UNLOCK */
+static void func_unlock(void);
+
 /* Check routine for IPC_RMID */
 static void func_rmid(void);

@@ -77,21 +94,27 @@ static void func_rmid(void);
 static void do_child(void);

 static struct test_case_t {
+	int *shmid;
 	int cmd;
+	struct shmid_ds *arg;
 	void (*func_test) ();
 	void (*func_setup) ();
 } TC[] = {
-	{IPC_STAT, func_stat, stat_setup},
+	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
 #ifndef UCLINUX
 	    /*
 	     * The second test is not applicable to uClinux;
 	     * shared memory segments are detached on exec(),
 	     * so cannot be passed to uClinux children.
 	     */
-	{IPC_STAT, func_stat, stat_setup},
+	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
 #endif
-	{IPC_SET, func_set, set_setup},
-	{IPC_RMID, func_rmid, NULL},
+	{&shm_id_1, IPC_SET, &buf, func_set, set_setup},
+	{&shm_id_1, IPC_INFO, (struct shmid_ds *) &info, func_info, NULL},
+	{&shm_index, SHM_STAT, &buf, func_sstat, NULL},
+	{&shm_id_1, SHM_LOCK, NULL, func_lock, NULL},
+	{&shm_id_1, SHM_UNLOCK, NULL, func_unlock, NULL},
+	{&shm_id_1, IPC_RMID, NULL, func_rmid, NULL},
 };

 static int TST_TOTAL = ARRAY_SIZE(TC);
@@ -146,7 +169,7 @@ int main(int argc, char *argv[])
 			if (TC[i].func_setup != NULL)
 				(*TC[i].func_setup) ();

-			TEST(shmctl(shm_id_1, TC[i].cmd, &buf));
+			TEST(shmctl(*(TC[i].shmid), TC[i].cmd, TC[i].arg));

 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL, "%s call failed - errno "
@@ -155,7 +178,10 @@ int main(int argc, char *argv[])
 				continue;
 			}
 			if (STD_FUNCTIONAL_TEST) {
-				(*TC[i].func_test) ();
+				if (TC[i].cmd == SHM_STAT)
+					(*TC[i].func_test) (TEST_RETURN);
+				else
+					(*TC[i].func_test) ();
 			} else {
 				tst_resm(TPASS, "call succeeded");

@@ -294,11 +320,11 @@ void do_child(void)
 }

 /*
- * func_stat() - check the functionality of the IPC_STAT command with shmctl()
+ * func_istat() - check the functionality of the IPC_STAT command with shmctl()
  *		 by looking at the pid of the creator, the segement size,
  *		 the number of attaches and the mode.
  */
-void func_stat(void)
+void func_istat(void)
 {
 	int fail = 0;
 	pid_t pid;
@@ -419,6 +445,49 @@ void func_set(void)
 	tst_resm(TPASS, "new mode and change time are correct");
 }

+static void func_info(void)
+{
+	if (info.shmmin != 1)
+		tst_resm(TFAIL, "value of shmmin is incorrect");
+	else
+		tst_resm(TPASS, "get correct shared memory limits");
+}
+
+static void func_sstat(int shmid)
+{
+	if (shmid >= 0)
+		tst_resm(TPASS, "get correct shared memery id");
+	else
+		tst_resm(TFAIL, "shared memery id is incorrect");
+}
+
+static void func_lock(void)
+{
+	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
+		tst_resm(TBROK, "stat failed in func_lock()");
+		return;
+	}
+
+	if (buf.shm_perm.mode & SHM_LOCKED)
+		tst_resm(TPASS, "SHM_LOCK is set");
+	else
+		tst_resm(TFAIL, "SHM_LOCK is cleared");
+}
+
+static void func_unlock(void)
+{
+	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
+		tst_resm(TBROK, "stat failed in func_unlock()");
+		return;
+	}
+
+	if (buf.shm_perm.mode & SHM_LOCKED)
+		tst_resm(TFAIL, "SHM_LOCK is set");
+	else
+		tst_resm(TPASS, "SHM_LOCK is cleared");
+}
+
+
 /*
  * func_rmid() - check the functionality of the IPC_RMID command with shmctl()
  */
-- 
1.8.1




------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH V2 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
  2013-05-24  5:23 ` [LTP] [PATCH V2 " DAN LI
@ 2013-05-24  8:02   ` Jan Stancek
  0 siblings, 0 replies; 10+ messages in thread
From: Jan Stancek @ 2013-05-24  8:02 UTC (permalink / raw)
  To: DAN LI; +Cc: ltp-list





----- Original Message -----
> From: "DAN LI" <li.dan@cn.fujitsu.com>
> To: ltp-list@lists.sourceforge.net
> Cc: "Jan Stancek" <jstancek@redhat.com>
> Sent: Friday, 24 May, 2013 7:23:22 AM
> Subject: [LTP] [PATCH V2 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
> 
> 
> 
> Additional tests for features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
> 
> 
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>

Hi,

comments inline.

> ---
>  testcases/kernel/syscalls/ipc/shmctl/shmctl01.c | 87
>  ++++++++++++++++++++++---
>  1 file changed, 78 insertions(+), 9 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> index 34ff30c..55711a7 100644
> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> @@ -43,13 +43,18 @@
>   *	call cleanup
>   */
> 
> +#ifndef _GNU_SOURCE
> +#define _GNU_SOURCE
> +#endif
>  #include "ipcshm.h"
>  #include "libtestsuite.h"
> 
>  char *TCID = "shmctl01";
> 
>  static int shm_id_1 = -1;
> +static int shm_index;
>  static struct shmid_ds buf;
> +static struct shminfo info;
>  static long save_time;
> 
>  #define FIRST	0
> @@ -64,12 +69,24 @@ static pid_t pid_arr[N_ATTACH];
>  static int sync_pipes[2];
> 
>  /* Setup, cleanup and check routines for IPC_STAT */
> -static void stat_setup(void), func_stat(void);
> +static void stat_setup(void), func_istat(void);
>  static void stat_cleanup(void);
> 
>  /* Setup and check routines for IPC_SET */
>  static void set_setup(void), func_set(void);
> 
> +/* Check routine for IPC_INFO */
> +static void func_info(void);
> +
> +/* Check routine for SHM_STAT */
> +static void func_sstat(int shmid);
> +
> +/* Check routine for SHM_LOCK */
> +static void func_lock(void);
> +
> +/* Check routine for SHM_UNLOCK */
> +static void func_unlock(void);
> +
>  /* Check routine for IPC_RMID */
>  static void func_rmid(void);
> 
> @@ -77,21 +94,27 @@ static void func_rmid(void);
>  static void do_child(void);
> 
>  static struct test_case_t {
> +	int *shmid;
>  	int cmd;
> +	struct shmid_ds *arg;
>  	void (*func_test) ();
>  	void (*func_setup) ();
>  } TC[] = {
> -	{IPC_STAT, func_stat, stat_setup},
> +	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
>  #ifndef UCLINUX
>  	    /*
>  	     * The second test is not applicable to uClinux;
>  	     * shared memory segments are detached on exec(),
>  	     * so cannot be passed to uClinux children.
>  	     */
> -	{IPC_STAT, func_stat, stat_setup},
> +	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
>  #endif
> -	{IPC_SET, func_set, set_setup},
> -	{IPC_RMID, func_rmid, NULL},
> +	{&shm_id_1, IPC_SET, &buf, func_set, set_setup},
> +	{&shm_id_1, IPC_INFO, (struct shmid_ds *) &info, func_info, NULL},
> +	{&shm_index, SHM_STAT, &buf, func_sstat, NULL},
> +	{&shm_id_1, SHM_LOCK, NULL, func_lock, NULL},
> +	{&shm_id_1, SHM_UNLOCK, NULL, func_unlock, NULL},
> +	{&shm_id_1, IPC_RMID, NULL, func_rmid, NULL},
>  };
> 
>  static int TST_TOTAL = ARRAY_SIZE(TC);
> @@ -146,7 +169,7 @@ int main(int argc, char *argv[])
>  			if (TC[i].func_setup != NULL)
>  				(*TC[i].func_setup) ();
> 
> -			TEST(shmctl(shm_id_1, TC[i].cmd, &buf));
> +			TEST(shmctl(*(TC[i].shmid), TC[i].cmd, TC[i].arg));
> 
>  			if (TEST_RETURN == -1) {
>  				tst_resm(TFAIL, "%s call failed - errno "
> @@ -155,7 +178,10 @@ int main(int argc, char *argv[])
>  				continue;
>  			}
>  			if (STD_FUNCTIONAL_TEST) {
> -				(*TC[i].func_test) ();
> +				if (TC[i].cmd == SHM_STAT)
> +					(*TC[i].func_test) (TEST_RETURN);

This works only because original code didn't put void in parameters of func_test/setup,
and feels a bit hackish. I think better approach would be to change it to:

void (*func_test) (int);
void (*func_setup) (void);

then you can call (*TC[i].func_test) (TEST_RETURN) for all testcases,
just some of them won't make use of that parameter.

> +				else
> +					(*TC[i].func_test) ();
>  			} else {
>  				tst_resm(TPASS, "call succeeded");
> 
> @@ -294,11 +320,11 @@ void do_child(void)
>  }
> 
>  /*
> - * func_stat() - check the functionality of the IPC_STAT command with
> shmctl()
> + * func_istat() - check the functionality of the IPC_STAT command with
> shmctl()
>   *		 by looking at the pid of the creator, the segement size,
>   *		 the number of attaches and the mode.
>   */
> -void func_stat(void)
> +void func_istat(void)
>  {
>  	int fail = 0;
>  	pid_t pid;
> @@ -419,6 +445,49 @@ void func_set(void)
>  	tst_resm(TPASS, "new mode and change time are correct");
>  }
> 
> +static void func_info(void)
> +{
> +	if (info.shmmin != 1)
> +		tst_resm(TFAIL, "value of shmmin is incorrect");
> +	else
> +		tst_resm(TPASS, "get correct shared memory limits");
> +}
> +
> +static void func_sstat(int shmid)
> +{
> +	if (shmid >= 0)
> +		tst_resm(TPASS, "get correct shared memery id");

typo, memery -> memory

> +	else
> +		tst_resm(TFAIL, "shared memery id is incorrect");

same typo, memery -> memory

Regards,
Jan

> +}
> +
> +static void func_lock(void)
> +{
> +	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
> +		tst_resm(TBROK, "stat failed in func_lock()");
> +		return;
> +	}
> +
> +	if (buf.shm_perm.mode & SHM_LOCKED)
> +		tst_resm(TPASS, "SHM_LOCK is set");
> +	else
> +		tst_resm(TFAIL, "SHM_LOCK is cleared");
> +}
> +
> +static void func_unlock(void)
> +{
> +	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
> +		tst_resm(TBROK, "stat failed in func_unlock()");
> +		return;
> +	}
> +
> +	if (buf.shm_perm.mode & SHM_LOCKED)
> +		tst_resm(TFAIL, "SHM_LOCK is set");
> +	else
> +		tst_resm(TPASS, "SHM_LOCK is cleared");
> +}
> +
> +
>  /*
>   * func_rmid() - check the functionality of the IPC_RMID command with
>   shmctl()
>   */
> --
> 1.8.1
> 
> 
> 
> 

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [LTP]  [PATCH V3 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
  2013-05-23  8:35 [LTP] [PATCH 1/2] shmctl/shmctl01.c: cleanup DAN LI
  2013-05-23  8:39 ` [LTP] [PATCH 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK DAN LI
  2013-05-24  5:23 ` [LTP] [PATCH V2 " DAN LI
@ 2013-05-24  9:50 ` DAN LI
  2013-05-24 12:13   ` Jan Stancek
  2013-05-24 12:47   ` Wanlong Gao
  2013-05-24 12:46 ` [LTP] [PATCH 1/2] shmctl/shmctl01.c: cleanup Wanlong Gao
  3 siblings, 2 replies; 10+ messages in thread
From: DAN LI @ 2013-05-24  9:50 UTC (permalink / raw)
  To: ltp-list



Additional tests for features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.


Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
 testcases/kernel/syscalls/ipc/shmctl/shmctl01.c | 96 +++++++++++++++++++++----
 1 file changed, 81 insertions(+), 15 deletions(-)

Hi,
Jan

How about this V3?

Regards,
DAN LI


diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
index 34ff30c..cba1a1d 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
@@ -43,13 +43,18 @@
  *	call cleanup
  */

+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 #include "ipcshm.h"
 #include "libtestsuite.h"

 char *TCID = "shmctl01";

 static int shm_id_1 = -1;
+static int shm_index;
 static struct shmid_ds buf;
+static struct shminfo info;
 static long save_time;

 #define FIRST	0
@@ -64,34 +69,52 @@ static pid_t pid_arr[N_ATTACH];
 static int sync_pipes[2];

 /* Setup, cleanup and check routines for IPC_STAT */
-static void stat_setup(void), func_stat(void);
+static void stat_setup(void), func_istat(int ret);
 static void stat_cleanup(void);

 /* Setup and check routines for IPC_SET */
-static void set_setup(void), func_set(void);
+static void set_setup(void), func_set(int ret);
+
+/* Check routine for IPC_INFO */
+static void func_info(int ret);
+
+/* Check routine for SHM_STAT */
+static void func_sstat(int ret);
+
+/* Check routine for SHM_LOCK */
+static void func_lock(int ret);
+
+/* Check routine for SHM_UNLOCK */
+static void func_unlock(int ret);

 /* Check routine for IPC_RMID */
-static void func_rmid(void);
+static void func_rmid(int ret);

 /* Child function */
 static void do_child(void);

 static struct test_case_t {
+	int *shmid;
 	int cmd;
-	void (*func_test) ();
-	void (*func_setup) ();
+	struct shmid_ds *arg;
+	void (*func_test) (int);
+	void (*func_setup) (void);
 } TC[] = {
-	{IPC_STAT, func_stat, stat_setup},
+	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
 #ifndef UCLINUX
 	    /*
 	     * The second test is not applicable to uClinux;
 	     * shared memory segments are detached on exec(),
 	     * so cannot be passed to uClinux children.
 	     */
-	{IPC_STAT, func_stat, stat_setup},
+	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
 #endif
-	{IPC_SET, func_set, set_setup},
-	{IPC_RMID, func_rmid, NULL},
+	{&shm_id_1, IPC_SET, &buf, func_set, set_setup},
+	{&shm_id_1, IPC_INFO, (struct shmid_ds *) &info, func_info, NULL},
+	{&shm_index, SHM_STAT, &buf, func_sstat, NULL},
+	{&shm_id_1, SHM_LOCK, NULL, func_lock, NULL},
+	{&shm_id_1, SHM_UNLOCK, NULL, func_unlock, NULL},
+	{&shm_id_1, IPC_RMID, NULL, func_rmid, NULL},
 };

 static int TST_TOTAL = ARRAY_SIZE(TC);
@@ -146,7 +169,7 @@ int main(int argc, char *argv[])
 			if (TC[i].func_setup != NULL)
 				(*TC[i].func_setup) ();

-			TEST(shmctl(shm_id_1, TC[i].cmd, &buf));
+			TEST(shmctl(*(TC[i].shmid), TC[i].cmd, TC[i].arg));

 			if (TEST_RETURN == -1) {
 				tst_resm(TFAIL, "%s call failed - errno "
@@ -155,7 +178,7 @@ int main(int argc, char *argv[])
 				continue;
 			}
 			if (STD_FUNCTIONAL_TEST) {
-				(*TC[i].func_test) ();
+				(*TC[i].func_test) (TEST_RETURN);
 			} else {
 				tst_resm(TPASS, "call succeeded");

@@ -294,11 +317,11 @@ void do_child(void)
 }

 /*
- * func_stat() - check the functionality of the IPC_STAT command with shmctl()
+ * func_istat() - check the functionality of the IPC_STAT command with shmctl()
  *		 by looking at the pid of the creator, the segement size,
  *		 the number of attaches and the mode.
  */
-void func_stat(void)
+void func_istat(int ret)
 {
 	int fail = 0;
 	pid_t pid;
@@ -392,7 +415,7 @@ void set_setup(void)
 /*
  * func_set() - check the functionality of the IPC_SET command with shmctl()
  */
-void func_set(void)
+void func_set(int ret)
 {
 	int fail = 0;

@@ -419,10 +442,53 @@ void func_set(void)
 	tst_resm(TPASS, "new mode and change time are correct");
 }

+static void func_info(int ret)
+{
+	if (info.shmmin != 1)
+		tst_resm(TFAIL, "value of shmmin is incorrect");
+	else
+		tst_resm(TPASS, "get correct shared memory limits");
+}
+
+static void func_sstat(int ret)
+{
+	if (ret >= 0)
+		tst_resm(TPASS, "get correct shared memory id");
+	else
+		tst_resm(TFAIL, "shared memory id is incorrect");
+}
+
+static void func_lock(int ret)
+{
+	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
+		tst_resm(TBROK, "stat failed in func_lock()");
+		return;
+	}
+
+	if (buf.shm_perm.mode & SHM_LOCKED)
+		tst_resm(TPASS, "SHM_LOCK is set");
+	else
+		tst_resm(TFAIL, "SHM_LOCK is cleared");
+}
+
+static void func_unlock(int ret)
+{
+	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
+		tst_resm(TBROK, "stat failed in func_unlock()");
+		return;
+	}
+
+	if (buf.shm_perm.mode & SHM_LOCKED)
+		tst_resm(TFAIL, "SHM_LOCK is set");
+	else
+		tst_resm(TPASS, "SHM_LOCK is cleared");
+}
+
+
 /*
  * func_rmid() - check the functionality of the IPC_RMID command with shmctl()
  */
-void func_rmid(void)
+void func_rmid(int ret)
 {
 	/* Do another shmctl() - we should get EINVAL */
 	if (shmctl(shm_id_1, IPC_STAT, &buf) != -1)
-- 
1.8.1

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH V3 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
  2013-05-24  9:50 ` [LTP] [PATCH V3 " DAN LI
@ 2013-05-24 12:13   ` Jan Stancek
  2013-05-24 12:47   ` Wanlong Gao
  1 sibling, 0 replies; 10+ messages in thread
From: Jan Stancek @ 2013-05-24 12:13 UTC (permalink / raw)
  To: DAN LI; +Cc: ltp-list





----- Original Message -----
> From: "DAN LI" <li.dan@cn.fujitsu.com>
> To: ltp-list@lists.sourceforge.net
> Cc: "Jan Stancek" <jstancek@redhat.com>
> Sent: Friday, 24 May, 2013 11:50:07 AM
> Subject: [LTP] [PATCH V3 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
> 
> 
> 
> Additional tests for features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
> 
> 
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
> ---
>  testcases/kernel/syscalls/ipc/shmctl/shmctl01.c | 96
>  +++++++++++++++++++++----
>  1 file changed, 81 insertions(+), 15 deletions(-)
> 
> Hi,
> Jan
> 
> How about this V3?
> 
> Regards,
> DAN LI

Looks good to me.
Reviewed-by: Jan Stancek <jstancek@redhat.com>

> 
> 
> diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> index 34ff30c..cba1a1d 100644
> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
> @@ -43,13 +43,18 @@
>   *	call cleanup
>   */
> 
> +#ifndef _GNU_SOURCE
> +#define _GNU_SOURCE
> +#endif
>  #include "ipcshm.h"
>  #include "libtestsuite.h"
> 
>  char *TCID = "shmctl01";
> 
>  static int shm_id_1 = -1;
> +static int shm_index;
>  static struct shmid_ds buf;
> +static struct shminfo info;
>  static long save_time;
> 
>  #define FIRST	0
> @@ -64,34 +69,52 @@ static pid_t pid_arr[N_ATTACH];
>  static int sync_pipes[2];
> 
>  /* Setup, cleanup and check routines for IPC_STAT */
> -static void stat_setup(void), func_stat(void);
> +static void stat_setup(void), func_istat(int ret);
>  static void stat_cleanup(void);
> 
>  /* Setup and check routines for IPC_SET */
> -static void set_setup(void), func_set(void);
> +static void set_setup(void), func_set(int ret);
> +
> +/* Check routine for IPC_INFO */
> +static void func_info(int ret);
> +
> +/* Check routine for SHM_STAT */
> +static void func_sstat(int ret);
> +
> +/* Check routine for SHM_LOCK */
> +static void func_lock(int ret);
> +
> +/* Check routine for SHM_UNLOCK */
> +static void func_unlock(int ret);
> 
>  /* Check routine for IPC_RMID */
> -static void func_rmid(void);
> +static void func_rmid(int ret);
> 
>  /* Child function */
>  static void do_child(void);
> 
>  static struct test_case_t {
> +	int *shmid;
>  	int cmd;
> -	void (*func_test) ();
> -	void (*func_setup) ();
> +	struct shmid_ds *arg;
> +	void (*func_test) (int);
> +	void (*func_setup) (void);
>  } TC[] = {
> -	{IPC_STAT, func_stat, stat_setup},
> +	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
>  #ifndef UCLINUX
>  	    /*
>  	     * The second test is not applicable to uClinux;
>  	     * shared memory segments are detached on exec(),
>  	     * so cannot be passed to uClinux children.
>  	     */
> -	{IPC_STAT, func_stat, stat_setup},
> +	{&shm_id_1, IPC_STAT, &buf, func_istat, stat_setup},
>  #endif
> -	{IPC_SET, func_set, set_setup},
> -	{IPC_RMID, func_rmid, NULL},
> +	{&shm_id_1, IPC_SET, &buf, func_set, set_setup},
> +	{&shm_id_1, IPC_INFO, (struct shmid_ds *) &info, func_info, NULL},
> +	{&shm_index, SHM_STAT, &buf, func_sstat, NULL},
> +	{&shm_id_1, SHM_LOCK, NULL, func_lock, NULL},
> +	{&shm_id_1, SHM_UNLOCK, NULL, func_unlock, NULL},
> +	{&shm_id_1, IPC_RMID, NULL, func_rmid, NULL},
>  };
> 
>  static int TST_TOTAL = ARRAY_SIZE(TC);
> @@ -146,7 +169,7 @@ int main(int argc, char *argv[])
>  			if (TC[i].func_setup != NULL)
>  				(*TC[i].func_setup) ();
> 
> -			TEST(shmctl(shm_id_1, TC[i].cmd, &buf));
> +			TEST(shmctl(*(TC[i].shmid), TC[i].cmd, TC[i].arg));
> 
>  			if (TEST_RETURN == -1) {
>  				tst_resm(TFAIL, "%s call failed - errno "
> @@ -155,7 +178,7 @@ int main(int argc, char *argv[])
>  				continue;
>  			}
>  			if (STD_FUNCTIONAL_TEST) {
> -				(*TC[i].func_test) ();
> +				(*TC[i].func_test) (TEST_RETURN);
>  			} else {
>  				tst_resm(TPASS, "call succeeded");
> 
> @@ -294,11 +317,11 @@ void do_child(void)
>  }
> 
>  /*
> - * func_stat() - check the functionality of the IPC_STAT command with
> shmctl()
> + * func_istat() - check the functionality of the IPC_STAT command with
> shmctl()
>   *		 by looking at the pid of the creator, the segement size,
>   *		 the number of attaches and the mode.
>   */
> -void func_stat(void)
> +void func_istat(int ret)
>  {
>  	int fail = 0;
>  	pid_t pid;
> @@ -392,7 +415,7 @@ void set_setup(void)
>  /*
>   * func_set() - check the functionality of the IPC_SET command with shmctl()
>   */
> -void func_set(void)
> +void func_set(int ret)
>  {
>  	int fail = 0;
> 
> @@ -419,10 +442,53 @@ void func_set(void)
>  	tst_resm(TPASS, "new mode and change time are correct");
>  }
> 
> +static void func_info(int ret)
> +{
> +	if (info.shmmin != 1)
> +		tst_resm(TFAIL, "value of shmmin is incorrect");
> +	else
> +		tst_resm(TPASS, "get correct shared memory limits");
> +}
> +
> +static void func_sstat(int ret)
> +{
> +	if (ret >= 0)
> +		tst_resm(TPASS, "get correct shared memory id");
> +	else
> +		tst_resm(TFAIL, "shared memory id is incorrect");
> +}
> +
> +static void func_lock(int ret)
> +{
> +	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
> +		tst_resm(TBROK, "stat failed in func_lock()");
> +		return;
> +	}
> +
> +	if (buf.shm_perm.mode & SHM_LOCKED)
> +		tst_resm(TPASS, "SHM_LOCK is set");
> +	else
> +		tst_resm(TFAIL, "SHM_LOCK is cleared");
> +}
> +
> +static void func_unlock(int ret)
> +{
> +	if (shmctl(shm_id_1, IPC_STAT, &buf) == -1) {
> +		tst_resm(TBROK, "stat failed in func_unlock()");
> +		return;
> +	}
> +
> +	if (buf.shm_perm.mode & SHM_LOCKED)
> +		tst_resm(TFAIL, "SHM_LOCK is set");
> +	else
> +		tst_resm(TPASS, "SHM_LOCK is cleared");
> +}
> +
> +
>  /*
>   * func_rmid() - check the functionality of the IPC_RMID command with
>   shmctl()
>   */
> -void func_rmid(void)
> +void func_rmid(int ret)
>  {
>  	/* Do another shmctl() - we should get EINVAL */
>  	if (shmctl(shm_id_1, IPC_STAT, &buf) != -1)
> --
> 1.8.1
> 

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 1/2] shmctl/shmctl01.c: cleanup
  2013-05-23  8:35 [LTP] [PATCH 1/2] shmctl/shmctl01.c: cleanup DAN LI
                   ` (2 preceding siblings ...)
  2013-05-24  9:50 ` [LTP] [PATCH V3 " DAN LI
@ 2013-05-24 12:46 ` Wanlong Gao
  3 siblings, 0 replies; 10+ messages in thread
From: Wanlong Gao @ 2013-05-24 12:46 UTC (permalink / raw)
  To: DAN LI; +Cc: LTP list

On 05/23/2013 04:35 PM, DAN LI wrote:
> 1. Remove useless comments
> 
> 2. Revise code to follow ltp-code-style
> 
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>

Applied, thank you.

Wanlong Gao


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH V3 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
  2013-05-24  9:50 ` [LTP] [PATCH V3 " DAN LI
  2013-05-24 12:13   ` Jan Stancek
@ 2013-05-24 12:47   ` Wanlong Gao
  1 sibling, 0 replies; 10+ messages in thread
From: Wanlong Gao @ 2013-05-24 12:47 UTC (permalink / raw)
  To: DAN LI; +Cc: ltp-list

On 05/24/2013 05:50 PM, DAN LI wrote:
> Additional tests for features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK.
> 
> 
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>

Applied, thank you.

Wanlong Gao


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-05-24 12:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-23  8:35 [LTP] [PATCH 1/2] shmctl/shmctl01.c: cleanup DAN LI
2013-05-23  8:39 ` [LTP] [PATCH 2/2] shmctl/shmctl01.c: Test features IPC_INFO, SHM_STAT, SHM_LOCK and SHM_UNLOCK DAN LI
2013-05-23 13:01   ` Jan Stancek
2013-05-24  5:18     ` DAN LI
2013-05-24  5:23 ` [LTP] [PATCH V2 " DAN LI
2013-05-24  8:02   ` Jan Stancek
2013-05-24  9:50 ` [LTP] [PATCH V3 " DAN LI
2013-05-24 12:13   ` Jan Stancek
2013-05-24 12:47   ` Wanlong Gao
2013-05-24 12:46 ` [LTP] [PATCH 1/2] shmctl/shmctl01.c: cleanup Wanlong Gao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.