Add func=0 argument test for modify_ldt(2).

Signed-off-by: Zeng Linggang <[email protected]>
---
 runtest/ltplite                                    |   1 +
 runtest/stress.part3                               |   1 +
 runtest/syscalls                                   |   1 +
 testcases/kernel/syscalls/.gitignore               |   1 +
 .../kernel/syscalls/modify_ldt/modify_ldt03.c      | 105 +++++++++++++++++++++
 5 files changed, 109 insertions(+)
 create mode 100644 testcases/kernel/syscalls/modify_ldt/modify_ldt03.c

diff --git a/runtest/ltplite b/runtest/ltplite
index f7127fe..fd618b8 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -451,6 +451,7 @@ mmap09 mmap09
 
 modify_ldt01 modify_ldt01
 modify_ldt02 modify_ldt02
+modify_ldt03 modify_ldt03
 
 #
 # These tests require an unmounted block device
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index 2f31e93..1c8d182 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -384,6 +384,7 @@ mmap09 mmap09
 
 modify_ldt01 modify_ldt01
 modify_ldt02 modify_ldt02
+modify_ldt03 modify_ldt03
 
 mprotect01 mprotect01
 mprotect02 mprotect02
diff --git a/runtest/syscalls b/runtest/syscalls
index 2a408c4..1b07739 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -585,6 +585,7 @@ mmap14 mmap14
 
 modify_ldt01 modify_ldt01
 modify_ldt02 modify_ldt02
+modify_ldt03 modify_ldt03
 
 #
 # These tests require an unmounted block device
diff --git a/testcases/kernel/syscalls/.gitignore 
b/testcases/kernel/syscalls/.gitignore
index 0138ba9..df01d72 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -530,6 +530,7 @@
 /mmap/mmap14
 /modify_ldt/modify_ldt01
 /modify_ldt/modify_ldt02
+/modify_ldt/modify_ldt03
 /mount/mount01
 /mount/mount02
 /mount/mount03
diff --git a/testcases/kernel/syscalls/modify_ldt/modify_ldt03.c 
b/testcases/kernel/syscalls/modify_ldt/modify_ldt03.c
new file mode 100644
index 0000000..799800a
--- /dev/null
+++ b/testcases/kernel/syscalls/modify_ldt/modify_ldt03.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Zeng Linggang <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.
+ */
+/*
+ * DESCRIPTION
+ *     Basic test for modify_ldt(2) using func=0 argument.
+ */
+
+#include "config.h"
+#include "test.h"
+#include "usctest.h"
+
+char *TCID = "modify_ldt03";
+int TST_TOTAL = 1;
+
+#if defined(__i386__) && defined(HAVE_MODIFY_LDT)
+
+#ifdef HAVE_ASM_LDT_H
+#include <asm/ldt.h>
+#endif
+extern int modify_ldt(int, void *, unsigned long);
+
+#include <asm/unistd.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include "safe_macros.h"
+
+static char buf[sizeof(struct user_desc)];
+static void cleanup(void);
+static void setup(void);
+
+int main(int ac, char **av)
+{
+       int lc;
+       char *msg;
+
+       msg = parse_opts(ac, av, NULL, NULL);
+       if (msg != NULL)
+               tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+       setup();
+
+       for (lc = 0; TEST_LOOPING(lc); lc++) {
+
+               tst_count = 0;
+
+               TEST(modify_ldt(0, buf, sizeof(struct user_desc)));
+
+               if (TEST_RETURN < 0) {
+                       tst_resm(TFAIL | TTERRNO,
+                                "modify_ldt() failed with errno: %s",
+                                strerror(TEST_ERRNO));
+               } else {
+                       tst_resm(TPASS, "modify_ldt() tested success");
+               }
+       }
+
+       cleanup();
+       tst_exit();
+}
+
+static void setup(void)
+{
+       tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+       TEST_PAUSE;
+}
+
+static void cleanup(void)
+{
+       TEST_CLEANUP;
+}
+
+#elif HAVE_MODIFY_LDT
+
+int main(void)
+{
+       tst_resm(TCONF,
+                "modify_ldt is available but not tested on the platform than "
+                "__i386__");
+       tst_exit();
+}
+
+#else /* if defined(__i386__) */
+
+int main(void)
+{
+       tst_resm(TINFO, "modify_ldt03 test only for ix86");
+       tst_exit();
+}
+
+#endif /* if defined(__i386__) */
-- 
1.8.4.2




------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to