public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: DAN LI <li.dan@cn.fujitsu.com>
To: LTP list <ltp-list@lists.sourceforge.net>
Subject: [LTP]  [PATCH 2/2]semctl/semctl01.c: Test features IPC_INFO, SEM_INFO and SEM_STAT
Date: Thu, 09 May 2013 16:46:41 +0800	[thread overview]
Message-ID: <518B6271.2030707@cn.fujitsu.com> (raw)
In-Reply-To: <518B618F.80400@cn.fujitsu.com>


Additional tests for features IPC_INFO, SEM_INFO and SEM_STAT.

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

diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl01.c b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
index 93d7cd7..8e5c907 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl01.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
@@ -32,11 +32,19 @@
  *        system. Fix this by using pipes to synchronize processes.
  */

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

 char *TCID = "semctl01";
+
+#ifdef __linux__
+int TST_TOTAL = 13;
+#else
 int TST_TOTAL = 10;
+#endif

 static int sem_id_1 = -1;

@@ -57,8 +65,14 @@ static void func_sval(void);
 static void func_rmid(void);
 static void child_cnt(void);
 static void child_pid(void);
+#ifdef __linux__
+static void func_iinfo(int);
+static void func_sinfo(void);
+static void func_sstat(int);
+#endif

 static struct semid_ds buf;
+static struct seminfo ipc_buf;
 static unsigned short array[PSEMS];
 static struct sembuf sops;

@@ -98,6 +112,11 @@ static struct test_case_t {
 	{SEM4, GETZCNT, func_cnt, SEMUN_CAST & buf, cnt_setup},
 	{0, SETALL, func_sall, SEMUN_CAST array, sall_setup},
 	{SEM4, SETVAL, func_sval, SEMUN_CAST INCVAL, NULL},
+#ifdef __linux__
+	{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},
+#endif
 	{0, IPC_RMID, func_rmid, SEMUN_CAST & buf, NULL},
 };

@@ -161,6 +180,8 @@ int main(int argc, char *argv[])
 					case GETZCNT:
 					case GETPID:
 					case GETVAL:
+					case IPC_INFO:
+					case SEM_STAT:
 						(*TC[i].func_test)
 						    (TEST_RETURN);
 						break;
@@ -536,6 +557,30 @@ static void func_rmid(void)
 	sem_id_1 = -1;
 }

+static void func_iinfo(int hidx)
+{
+	if (hidx >= 0)
+		tst_resm(TPASS, "the highest index is correct");
+	else
+		tst_resm(TFAIL, "the highest index is incorrect");
+}
+
+static void func_sinfo(void)
+{
+	if (ipc_buf.semusz < 1)
+		tst_resm(TFAIL, "number of semaphore sets is incorrect");
+	else
+		tst_resm(TPASS, "number of semaphore sets is correct");
+}
+
+static void func_sstat(int semidx)
+{
+	if (semidx >= 0)
+		tst_resm(TPASS, "id of the semaphore set is correct");
+	else
+		tst_resm(TFAIL, "id of the semaphore set is incorrect");
+}
+
 void setup(void)
 {

-- 
1.8.1



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2013-05-09  8:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-09  8:42 [LTP] [PATCH 1/2]semctl/semctl01.c: cleanup DAN LI
2013-05-09  8:46 ` DAN LI [this message]
2013-05-09 13:32   ` [LTP] [PATCH 2/2]semctl/semctl01.c: Test features IPC_INFO, SEM_INFO and SEM_STAT chrubis
     [not found]     ` <201305091220.44861.vapier@gentoo.org>
2013-05-10  8:30       ` Wanlong Gao
2013-05-10 15:36         ` Mike Frysinger
2013-05-13  2:28           ` Wanlong Gao
2013-05-09 16:22 ` [LTP] [PATCH 1/2]semctl/semctl01.c: cleanup Mike Frysinger
2013-05-10  2:35   ` DAN LI
2013-05-10 15:27     ` Mike Frysinger
2013-05-13 11:23       ` chrubis

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=518B6271.2030707@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox