* [LTP] [PATCH] modify_ldt/modify_ldt03.c: add a new test
@ 2014-02-20 11:02 Zeng Linggang
2014-03-18 13:35 ` chrubis
0 siblings, 1 reply; 3+ messages in thread
From: Zeng Linggang @ 2014-02-20 11:02 UTC (permalink / raw)
To: ltp-list
Add func=0 argument test for modify_ldt(2).
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
runtest/ltplite | 1 +
runtest/stress.part3 | 1 +
runtest/syscalls | 1 +
testcases/kernel/syscalls/.gitignore | 1 +
.../kernel/syscalls/modify_ldt/modify_ldt03.c | 110 +++++++++++++++++++++
5 files changed, 114 insertions(+)
create mode 100644 testcases/kernel/syscalls/modify_ldt/modify_ldt03.c
diff --git a/runtest/ltplite b/runtest/ltplite
index 4b5300d..c7a5fd0 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -448,6 +448,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 bb4807c..d9a846a 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -381,6 +381,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 afa7976..a6b265c 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -576,6 +576,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 1caf8e3..f7bd5b1 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -520,6 +520,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..7dce116
--- /dev/null
+++ b/testcases/kernel/syscalls/modify_ldt/modify_ldt03.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
+ *
+ * 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"
+
+TCID_DEFINE(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 unsigned long bytecount = 10;
+static void *ptr;
+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, ptr, bytecount));
+
+ 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;
+
+ ptr = SAFE_MALLOC(cleanup, bytecount);
+}
+
+static void cleanup(void)
+{
+ free(ptr);
+
+ 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
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [LTP] [PATCH] modify_ldt/modify_ldt03.c: add a new test
2014-02-20 11:02 [LTP] [PATCH] modify_ldt/modify_ldt03.c: add a new test Zeng Linggang
@ 2014-03-18 13:35 ` chrubis
[not found] ` <1395207368.3217.1.camel@G08JYZSD130126>
0 siblings, 1 reply; 3+ messages in thread
From: chrubis @ 2014-03-18 13:35 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
> +#include "config.h"
> +#include "test.h"
> +#include "usctest.h"
> +
> +TCID_DEFINE(modify_ldt03);
This macro is primarily used to define right TCID when compiling two
tests from one source (the _16 ones). There is no need to use it
otherwise.
> +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 unsigned long bytecount = 10;
Where did you get this number from? Is this sizeof(struct user_desc) ?
> +static void *ptr;
Do you need to allocate the memory, wouldn't char buf[bytecount] do the
same?
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-03-19 16:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-20 11:02 [LTP] [PATCH] modify_ldt/modify_ldt03.c: add a new test Zeng Linggang
2014-03-18 13:35 ` chrubis
[not found] ` <1395207368.3217.1.camel@G08JYZSD130126>
2014-03-19 16:31 ` [LTP] [PATCH v2] " chrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox