All of lore.kernel.org
 help / color / mirror / Atom feed
From: DAN LI <li.dan@cn.fujitsu.com>
To: LTP list <ltp-list@lists.sourceforge.net>
Subject: [LTP]  [PATCH] semctl01.c: Pass the correct parameter
Date: Tue, 21 May 2013 16:51:53 +0800	[thread overview]
Message-ID: <519B35A9.8090300@cn.fujitsu.com> (raw)


For SEM_STAT, the semid argument is not a semaphore identifier,  but instead an
index into the kernel’s internal array that maintains information about all
semaphore sets on the system.

Pass a correct index of the kernel' internal array intead of a semaphores id when
testing feature SEM_STAT.

Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
 testcases/kernel/syscalls/ipc/semctl/semctl01.c | 28 +++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl01.c b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
index 687d909..aee6ccf 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl01.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
@@ -52,6 +52,8 @@ char *TCID = "semctl01";
 int TST_TOTAL = 13;

 static int sem_id_1 = -1;
+static int sem_id;
+static int sem_index;

 static int sync_pipes[2];

@@ -67,12 +69,12 @@ static void pid_setup(void), func_pid(int);
 static void func_gval(int);
 static void sall_setup(void), func_sall(void);
 static void func_sval(void);
-static void func_rmid(void);
+static void rmid_setup(void), func_rmid(void);
 static void child_cnt(void);
 static void child_pid(void);
 static void func_iinfo(int);
 static void func_sinfo(void);
-static void func_sstat(int);
+static void sstat_setup(void), func_sstat(int);

 static struct semid_ds buf;
 static struct seminfo ipc_buf;
@@ -117,8 +119,8 @@ static struct test_case_t {
 	{SEM4, SETVAL, func_sval, SEMUN_CAST INCVAL, NULL},
 	{0, IPC_INFO, func_iinfo, SEMUN_CAST & ipc_buf, NULL},
 	{0, SEM_INFO, func_sinfo, SEMUN_CAST & ipc_buf, NULL},
-	{0, SEM_STAT, func_sstat, SEMUN_CAST & buf, NULL},
-	{0, IPC_RMID, func_rmid, SEMUN_CAST & buf, NULL},
+	{0, SEM_STAT, func_sstat, SEMUN_CAST & buf, sstat_setup},
+	{0, IPC_RMID, func_rmid, SEMUN_CAST & buf, rmid_setup},
 };

 int main(int argc, char *argv[])
@@ -538,6 +540,11 @@ static void func_sval(void)
 		tst_resm(TPASS, "semaphore value is correct");
 }

+static void rmid_setup(void)
+{
+	sem_id_1 = sem_id;
+}
+
 /*
  * func_rmid() - check the functionality of the IPC_RMID command with semctl()
  */
@@ -560,10 +567,13 @@ static void func_rmid(void)

 static void func_iinfo(int hidx)
 {
-	if (hidx >= 0)
+	if (hidx >= 0) {
+		sem_index = hidx;
 		tst_resm(TPASS, "the highest index is correct");
-	else
+	} else {
+		sem_index = 0;
 		tst_resm(TFAIL, "the highest index is incorrect");
+	}
 }

 static void func_sinfo(void)
@@ -574,6 +584,12 @@ static void func_sinfo(void)
 		tst_resm(TPASS, "number of semaphore sets is correct");
 }

+static void sstat_setup(void)
+{
+	sem_id = sem_id_1;
+	sem_id_1 = sem_index;
+}
+
 static void func_sstat(int semidx)
 {
 	if (semidx >= 0)
-- 
1.7.11.rc0

------------------------------------------------------------------------------
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

             reply	other threads:[~2013-05-21  8:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-21  8:51 DAN LI [this message]
2013-05-21 10:22 ` [LTP] [PATCH] semctl01.c: Pass the correct parameter Jan Stancek
2013-05-22  1:47   ` DAN LI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=519B35A9.8090300@cn.fujitsu.com \
    --to=li.dan@cn.fujitsu.com \
    --cc=ltp-list@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.