This patch implements a basic test for enablement of pidns
for running kernel. If kernel does not supports PIDNS for
the running version , don't run pidns testcases simply
<Signed-off By>: Rishikesh K Rajak <[EMAIL PROTECTED]>
<Acked-by>: Serge Hallyn <[EMAIL PROTECTED]>
---
Index: ltp-full-20071130/testcases/kernel/containers/pidns/Makefile
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ltp-full-20071130/testcases/kernel/containers/pidns/Makefile 2007-12-27 16:26:18.000000000 +0530
@@ -0,0 +1,21 @@
+CFLAGS += -Wall
+CPPFLAGS += -I../../../../include -I../libclone
+LDLIBS += -L../../../../lib -L../libclone ../libclone/libclone.a -lltp
+
+SRCS = $(wildcard *.c)
+NOLTPSRCS =
+TARGETS = $(patsubst %.c,%,$(SRCS))
+NOLTP_TARGETS = $(patsubst %.c,%_noltp,$(NOLTPSRCS))
+
+%_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) check_pidns_enabled; do ln -f $$i ../../../bin/$$i; done
Index: ltp-full-20071130/testcases/kernel/containers/pidns/check_pidns_enabled.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ltp-full-20071130/testcases/kernel/containers/pidns/check_pidns_enabled.c 2007-12-27 16:27:32.000000000 +0530
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) International Business Machines Corp., 2007
+* 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.
+* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*
+***************************************************************************
+
+* File: check_pidns_enabled.c
+*
+* Description:
+* This testcase builds into the ltp framework to verify that kernel is
+* PID NS enabled or not.
+*
+* Verify that:
+* 1. Verify that the kernel version is 2.6.24.
+* 2. Verify that clone() function return value.
+*
+* Test Name: check_pidns_enabled
+*
+* Test Assertion & Strategy:
+* Check that the kernel version is 2.6.24 and clone returns no failure after passing
+* the clone falg as CLONE_NEWPID.
+*
+* History:
+*
+* FLAG DATE NAME DESCRIPTION
+* 27/12/07 RISHIKESH K RAJAK <[EMAIL PROTECTED]> Created this test
+*
+*******************************************************************************************/
+#include <sched.h>
+#include <stdio.h>
+#include "../libclone/libclone.h"
+#include "test.h"
+
+int dummy(void *v)
+{
+ /* Simply return from the child */
+ return 0;
+}
+
+/* MAIN */
+int main()
+{
+ void *childstack, *stack;
+ int pid;
+
+ /* Test for the running kernel version
+ * provided by LTP library API
+ */
+ if (tst_kvercmp(2,6,24) < 0)
+ return 1;
+ stack = malloc(getpagesize());
+ if (!stack) {
+ perror("malloc");
+ return 2;
+ }
+
+ childstack = stack + getpagesize();
+
+#ifdef __ia64__
+ pid = clone2(dummy, childstack, getpagesize(), CLONE_NEWPID, NULL, NULL, NULL, NULL);
+#else
+ pid = clone(dummy, childstack, CLONE_NEWPID, NULL);
+#endif
+
+ /* Check for the clone function return value */
+ if (pid == -1)
+ return 3;
+ return 0;
+}
+
Index: ltp-full-20071130/testcases/kernel/containers/container_test.sh
===================================================================
--- ltp-full-20071130.orig/testcases/kernel/containers/container_test.sh 2007-12-27 16:26:11.000000000 +0530
+++ ltp-full-20071130/testcases/kernel/containers/container_test.sh 2007-12-27 16:26:18.000000000 +0530
@@ -51,6 +51,13 @@
echo "Running ipcns tests."
runipcnstest.sh
else
- echo "ipc namespaces not enabled in kernel. Not running pidns tests."
+ echo "ipc namespaces not enabled in kernel. Not running ipcns tests."
+fi
+
+check_pidns_enabled
+if [ $? -eq 0 ]; then
+ echo "Running pidns tests."
+else
+ echo "pid namespaces not enabled in kernel. Not running pidns tests."
fi
Index: ltp-full-20071130/testcases/kernel/containers/Makefile
===================================================================
--- ltp-full-20071130.orig/testcases/kernel/containers/Makefile 2007-12-27 16:26:11.000000000 +0530
+++ ltp-full-20071130/testcases/kernel/containers/Makefile 2007-12-27 16:26:18.000000000 +0530
@@ -1,4 +1,4 @@
-SUBDIRS = libclone utsname sysvipc
+SUBDIRS = libclone utsname sysvipc pidns
all:
@set -e; $(MAKE) check_for_unshare; \
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list