"risrajak@linux.vnet.ibm.com" added sysvipc (conatainers) namespace testcases
diff --git a/README b/README
index 777887f..16de1ac 100644
--- a/README
+++ b/README
@@ -79,7 +79,7 @@
new snippets to be added, or take one of these and finish it off.
testcases/kernel/containers/*
- Contains all the testcases related to container functionality ( e.g: utsname etc..)
+ Contains all the testcases related to container functionality ( e.g: sysvipc, utsname etc..)
For further information on the each of the container functionality refer
the following file: testcases/kernel/containers/README
diff --git a/testcases/kernel/containers/Makefile b/testcases/kernel/containers/Makefile
index 32a2c70..6ac7609 100644
--- a/testcases/kernel/containers/Makefile
+++ b/testcases/kernel/containers/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS = libclone utsname
+SUBDIRS = libclone utsname sysvipc
all noltp noltp_check:
@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done
diff --git a/testcases/kernel/containers/README b/testcases/kernel/containers/README
index cefc4c4..ca54ce6 100644
--- a/testcases/kernel/containers/README
+++ b/testcases/kernel/containers/README
@@ -5,6 +5,8 @@
(e.g: utsname etc..) tests and report results. Please refer the following
each functionality README file for detail:
+sysvipc/*
+ Contains all the testcases related to IPC NS tests.
utsname/*
Contains all the testcases related to utsname tests.
libclone/*
diff --git a/testcases/kernel/containers/container_test.sh b/testcases/kernel/containers/container_test.sh
index a045286..e9bd6c8 100755
--- a/testcases/kernel/containers/container_test.sh
+++ b/testcases/kernel/containers/container_test.sh
@@ -39,3 +39,6 @@
#else
#echo "User namespaces not enabled in kernel. Not running userns tests."
#fi
+
+runipcnstest.sh
+
diff --git a/testcases/kernel/containers/sysvipc/Makefile b/testcases/kernel/containers/sysvipc/Makefile
new file mode 100644
index 0000000..fa14f46
--- /dev/null
+++ b/testcases/kernel/containers/sysvipc/Makefile
@@ -0,0 +1,23 @@
+
+CFLAGS += -I../../../../include -I../libclone -Wall
+LDLIBS += -L../../../../lib -L../libclone ../libclone/libclone.a -lltp
+
+SRCS = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+NOLTP_TARGETS = $(patsubst %.c,%_noltp,$(SRCS))
+
+%_noltp : %.c
+ $(CC) -g -DNO_LTP -o $@ $< ../libclone/libclone.a
+
+all: $(TARGETS)
+
+noltp: $(NOLTP_TARGETS)
+
+clean:
+ rm -f $(TARGETS) *.o $(NOLTP_TARGETS)
+
+install:
+ @set -e; for i in $(TARGETS) runipcnstest.sh ; do ln -f $$i ../../../bin/$$i ; chmod +x runipcnstest.sh ; done
+
+noltp_check: noltp
+ ./runtests_noltp.sh
diff --git a/testcases/kernel/containers/sysvipc/runipcnstest.sh b/testcases/kernel/containers/sysvipc/runipcnstest.sh
new file mode 100644
index 0000000..9e5ad06
--- /dev/null
+++ b/testcases/kernel/containers/sysvipc/runipcnstest.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+exit_code=0
+echo "sysvipc tests"
+for type in none clone unshare; do
+ echo "**sysvipc $type"
+ shmnstest $type
+ if [ $? -ne 0 ]; then
+ exit_code=$?
+ fi
+done
+exit $exit_code
diff --git a/testcases/kernel/containers/sysvipc/runtests_noltp.sh b/testcases/kernel/containers/sysvipc/runtests_noltp.sh
new file mode 100644
index 0000000..37d6231
--- /dev/null
+++ b/testcases/kernel/containers/sysvipc/runtests_noltp.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+exit_code=0
+echo "sysvipc tests"
+for type in none clone unshare; do
+ echo "**sysvipc $type"
+ ./shmnstest_noltp $type
+ if [ $? -ne 0 ]; then
+ exit_code=$?
+ fi
+done
+exit $exit_code
diff --git a/testcases/kernel/containers/sysvipc/shmnstest.c b/testcases/kernel/containers/sysvipc/shmnstest.c
new file mode 100644
index 0000000..d86f3ae
--- /dev/null
+++ b/testcases/kernel/containers/sysvipc/shmnstest.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2007 IBM
+ * Author: Serge Hallyn <serue@us.ibm.com>
+ *
+ * Create shm with key 0xEAEAEA
+ * clone, clone(CLONE_NEWIPC), or unshare(CLONE_NEWIPC)
+ * In cloned process, try to get the created shm
+ */
+
+#define _GNU_SOURCE 1
+#include <sys/wait.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#ifndef NO_LTP
+#include <test.h>
+#include <libclone.h>
+#else
+#include "../libclone/libclone.h"
+#endif
+
+char *TCID = "sysvipc_namespace";
+int TST_TOTAL=1;
+#define TESTKEY 0xEAEAEA
+
+#ifdef NO_LTP
+#define TFAIL "FAILURE: "
+#define TPASS "PASS: "
+#define TINFO "INFO: "
+#define tst_resm(x, format, arg...) printf("%s:" format, x,## arg)
+#define tst_exit(ret) exit(ret)
+#endif
+
+int p1[2];
+int p2[2];
+
+int check_shmid(void *vtest)
+{
+ char buf[3];
+ int id;
+
+ close(p1[1]);
+ close(p2[0]);
+
+ read(p1[0], buf, 3);
+ id = shmget(TESTKEY, 100, 0);
+ if (id == -1) {
+ write(p2[1], "notfnd", 7);
+ } else {
+ write(p2[1], "exists", 7);
+ shmctl(id, IPC_RMID, NULL);
+ }
+ tst_exit(0);
+}
+
+#define UNSHARESTR "unshare"
+#define CLONESTR "clone"
+#define NONESTR "none"
+int main(int argc, char *argv[])
+{
+ int r, pid, use_clone = T_NONE;
+ int id;
+ char *tsttype = NONESTR;
+ char buf[7];
+
+ if (argc != 2) {
+ tst_resm(TFAIL, "Usage: %s <clone|unshare|none>\n", argv[0]);
+ tst_resm(TFAIL, " where clone, unshare, or fork specifies unshare method.");
+ tst_exit(2);
+ }
+ if (pipe(p1) == -1) { perror("pipe"); exit(EXIT_FAILURE); }
+ if (pipe(p2) == -1) { perror("pipe"); exit(EXIT_FAILURE); }
+ tsttype = NONESTR;
+ if (strcmp(argv[1], "clone") == 0) {
+ use_clone = T_CLONE;
+ tsttype = CLONESTR;
+ } else if (strcmp(argv[1], "unshare") == 0) {
+ use_clone = T_UNSHARE;
+ tsttype = UNSHARESTR;
+ }
+
+ /* first create the key */
+ id = shmget(TESTKEY, 100, IPC_CREAT);
+ if (id == -1) {
+ perror("shmget");
+ tst_resm(TFAIL, "shmget failed\n");
+ tst_exit(3);
+ }
+
+ tst_resm(TINFO, "shmid namespaces test : %s\n",tsttype);
+ /* fire off the test */
+ r = do_clone_unshare_test(use_clone, CLONE_NEWIPC, check_shmid, NULL);
+ if (r < 0) {
+ tst_resm(TFAIL, "%s failed\n", tsttype);
+ tst_exit(1);
+ }
+
+ close(p1[0]);
+ close(p2[1]);
+ write(p1[1], "go", 3);
+ read(p2[0], buf, 7);
+ if (strcmp(buf, "exists") == 0) {
+ if (use_clone == T_NONE)
+ tst_resm(TPASS, "plain cloned process found shmid\n");
+ else
+ tst_resm(TFAIL, "%s: child process found shmid\n",
+ tsttype);
+ } else {
+ if (use_clone == T_NONE)
+ tst_resm(TFAIL, "plain cloned process didn't find shmid\n");
+ else
+ tst_resm(TPASS, "%s: child process didn't find shmid\n",
+ tsttype);
+ }
+
+ /* destroy the key */
+ shmctl(id, IPC_RMID, NULL);
+ tst_exit(0);
+}