Hi,
I've introduced autoconf to modify_ldt test cases.
The modification is very similar to the modification to signalfd.
Signed-off-by: Masatake YAMATO<[EMAIL PROTECTED]>
diff --git a/configure.ac b/configure.ac
index 3edc6cd..05df57d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,5 +6,8 @@ AC_CONFIG_HEADERS([include/config.h])
m4_include([m4/ltp-signalfd.m4])
LTP_CHECK_SYSCALL_SIGNALFD
+m4_include([m4/ltp-modify_ldt.m4])
+LTP_CHECK_SYSCALL_MODIFY_LDT
+
AC_OUTPUT
diff --git a/m4/ltp-modify_ldt.m4 b/m4/ltp-modify_ldt.m4
new file mode 100644
index 0000000..adc1cd1
--- /dev/null
+++ b/m4/ltp-modify_ldt.m4
@@ -0,0 +1,33 @@
+dnl
+dnl Copyright (c) Red Hat Inc., 2008
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+dnl
+dnl Author: Masatake YAMATO <[EMAIL PROTECTED]>
+dnl
+
+dnl
+dnl LTP_CHECK_SYSCALL_MODIFY_LDT
+dnl ----------------------------
+dnl
+AC_DEFUN([LTP_CHECK_SYSCALL_MODIFY_LDT],
+[dnl
+AC_CHECK_FUNCS(modify_ldt)
+AC_CHECK_HEADERS(asm/ldt.h,[LTP_SYSCALL_MODIFY_LDT_HEADER=yes])
+if test x"$LTP_SYSCALL_MODIFY_LDT_HEADER" = xyes; then
+ AC_CHECK_TYPES([struct user_desc, struct modify_ldt_ldt_s],[],[],[dnl
+#include <asm/ldt.h>
+])
+fi])dnl
diff --git a/m4/ltp-signalfd.m4 b/m4/ltp-signalfd.m4
index 89021a4..083e9ab 100644
--- a/m4/ltp-signalfd.m4
+++ b/m4/ltp-signalfd.m4
@@ -40,7 +40,7 @@ AC_DEFUN([LTP_CHECK_SYSCALL_SIGNALFD],
_LTP_CHECK_SYSCALL_SIGNALFD_FUNCTION
_LTP_CHECK_SYSCALL_SIGNALFD_HEADER
-if test "$LTP_SYSCALL_SIGNALFD_HEADER" = yes; then
+if test x"$LTP_SYSCALL_SIGNALFD_HEADER" = xyes; then
_LTP_CHECK_SYSCALL_SIGNALFD_FIELD_PREFIX
fi]dnl
)dnl
diff --git a/runtest/syscalls b/runtest/syscalls
index a4a87e9..6a271bd 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -527,8 +527,8 @@ mmap07 mmap07
mmap08 mmap08
mmap09 mmap09
-modify_ldt01 run-modify_ldt01.sh
-modify_ldt02 run-modify_ldt02.sh
+modify_ldt01 modify_ldt01
+modify_ldt02 modify_ldt02
#
# These tests require an unmounted block device
diff --git a/testcases/kernel/syscalls/modify_ldt/Makefile
b/testcases/kernel/syscalls/modify_ldt/Makefile
index c169d69..9cd92c5 100644
--- a/testcases/kernel/syscalls/modify_ldt/Makefile
+++ b/testcases/kernel/syscalls/modify_ldt/Makefile
@@ -15,42 +15,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
-
-include ../utils/cond.mk
-
+CFLAGS += -I../../../../include -g -Wall -Wall
+LDLIBS += -L../../../../lib -lltp
SRCS = $(wildcard *.c)
TARGETS = $(patsubst %.c,%,$(SRCS))
-SYSCALL = modify_ldt
-
-ifeq ($(call check_header,asm/ldt.h),yes)
-
-# TODO: Next shell call makes cross-compiling LTP difficult.
-NEEDSPECIAL:=$(shell echo "\#include <asm/ldt.h>" | $(CC) -E - 2>&1 | grep
user_desc)
-ifeq ($(strip $(NEEDSPECIAL)),)
-CFLAGS+=-I../../../../include -g -Wall
-else
-CFLAGS+=-I../../../../include -g -Wall -DMODIFY_LDT_SPECIALCASE
-endif
-
-LDLIBS += -L../../../../lib -lltp
all: $(TARGETS)
install:
@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
- cp run-$(SYSCALL)01.sh ../../../bin/run-$(SYSCALL)01.sh
- cp run-$(SYSCALL)02.sh ../../../bin/run-$(SYSCALL)02.sh
-
-else ### does not have asm/ldt.h ###
-
-all:
-
-install:
- cp run-$(SYSCALL)01.sh ../../../bin/run-$(SYSCALL)01.sh
- cp run-$(SYSCALL)02.sh ../../../bin/run-$(SYSCALL)02.sh
-
-endif
clean:
rm -f $(TARGETS)
+
diff --git a/testcases/kernel/syscalls/modify_ldt/modify_ldt01.c
b/testcases/kernel/syscalls/modify_ldt/modify_ldt01.c
index 8fcc673..1eaa350 100644
--- a/testcases/kernel/syscalls/modify_ldt/modify_ldt01.c
+++ b/testcases/kernel/syscalls/modify_ldt/modify_ldt01.c
@@ -49,50 +49,53 @@
* None
*/
-#ifdef __i386__
-#include <asm/ldt.h>
-#include <asm/unistd.h>
-#endif
-#include <errno.h>
+#include "config.h"
#include "test.h"
#include "usctest.h"
-/* Newer ldt.h files use user_desc, instead of modify_ldt_ldt_s */
-#ifdef MODIFY_LDT_SPECIALCASE
-#define modify_ldt_ldt_s user_desc
+TCID_DEFINE(modify_ldt01);
+int TST_TOTAL = 1;
+extern int Tst_count;
+
+
+#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);
+
-#if !defined(modify_ldt_ldt_s) || !defined(user_desc)
- typedef struct modify_ldt_ldt_t
- {
- unsigned int entry_number;
- unsigned long int base_addr;
- unsigned int limit;
- unsigned int seg_32bit:1;
- unsigned int contents:2;
- unsigned int read_exec_only:1;
- unsigned int limit_in_pages:1;
- unsigned int seg_not_present:1;
- unsigned int useable:1;
- unsigned int empty:25;
- }modify_ldt_s;
+#include <asm/unistd.h>
+#include <errno.h>
+
+/* Newer ldt.h files use user_desc, instead of modify_ldt_ldt_s */
+#ifdef HAVE_STRUCT_USER_DESC
+typedef struct user_desc modify_ldt_s;
+#elif HAVE_STRUCT_MODIFY_LDT_LDT_S
+typedef struct modify_ldt_ldt_s modify_ldt_s;
+#else
+typedef struct modify_ldt_ldt_t
+{
+ unsigned int entry_number;
+ unsigned long int base_addr;
+ unsigned int limit;
+ unsigned int seg_32bit:1;
+ unsigned int contents:2;
+ unsigned int read_exec_only:1;
+ unsigned int limit_in_pages:1;
+ unsigned int seg_not_present:1;
+ unsigned int useable:1;
+ unsigned int empty:25;
+} modify_ldt_s;
#endif
+int create_segment(void *, size_t);
void cleanup(void);
void setup(void);
-char *TCID= "modify_ldt01";
-int TST_TOTAL = 1;
-extern int Tst_count;
-int seg[4];
-int flag;
#define FAILED 1
-#if defined(__i386__)
-
-int create_segment(void *, size_t);
-
-extern int modify_ldt(int, void*, unsigned long);
int main(int ac, char **av)
{
@@ -102,6 +105,9 @@ int main(int ac, char **av)
void *ptr;
int retval, func;
+ int flag;
+ int seg[4];
+
/* parse standard options */
if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char
*)NULL){
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
@@ -217,15 +223,25 @@ int main(int ac, char **av)
return(0);
}
-#else /* if defined(linux) && defined(__i386__) */
-
-int main()
+/*
+ * create_segment() -
+ */
+int
+create_segment(void *seg, size_t size)
{
- tst_resm(TINFO, "modify_ldt01 test only for ix86");
- return 0;
-}
+ modify_ldt_s entry;
-#endif /* if defined(linux) && defined(__i386__) */
+ entry.entry_number = 0;
+ entry.base_addr = (unsigned long)seg;
+ entry.limit = size;
+ entry.seg_32bit = 1;
+ entry.contents = 0;
+ entry.read_exec_only = 0;
+ entry.limit_in_pages = 0;
+ entry.seg_not_present = 0;
+
+ return modify_ldt(1, &entry, sizeof(entry));
+}
/*
* setup() - performs all ONE TIME setup for this test
@@ -257,21 +273,18 @@ cleanup(void)
tst_exit();
}
-#if defined(__i386__)
-int
-create_segment(void *seg, size_t size)
+#elif HAVE_MODIFY_LDT
+int main()
{
- modify_ldt_s entry;
-
- entry.entry_number = 0;
- entry.base_addr = (unsigned long)seg;
- entry.limit = size;
- entry.seg_32bit = 1;
- entry.contents = 0;
- entry.read_exec_only = 0;
- entry.limit_in_pages = 0;
- entry.seg_not_present = 0;
+ tst_resm(TCONF, "modify_ldt is available but not tested on the platform
than __i386__");
+ return 0;
+}
- return modify_ldt(1, &entry, sizeof(entry));
+#else
+int main()
+{
+ tst_resm(TINFO, "modify_ldt01 test only for ix86");
+ return 0;
}
-#endif /* if defined(linux) && defined(__i386__) */
+
+#endif /* defined(__i386__) */
diff --git a/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
b/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
index 0896632..20d9586 100644
--- a/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
+++ b/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
@@ -43,53 +43,58 @@
* None
*/
-#if defined(__i386__)
+#include "config.h"
+#include "test.h"
+#include "usctest.h"
+
+
+TCID_DEFINE(modify_ldt02);
+int TST_TOTAL = 1;
+extern int Tst_count;
+
+
+#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>
-#endif
#include <string.h>
#include <sys/wait.h>
#include <errno.h>
-#include "test.h"
-#include "usctest.h"
/* Newer ldt.h files use user_desc, instead of modify_ldt_ldt_s */
-#ifdef MODIFY_LDT_SPECIALCASE
-#define modify_ldt_ldt_s user_desc
-#endif
-
-#if !defined(modify_ldt_ldt_s) || !defined(user_desc)
- typedef struct modify_ldt_ldt_t
- {
- unsigned int entry_number;
- unsigned long int base_addr;
- unsigned int limit;
- unsigned int seg_32bit:1;
- unsigned int contents:2;
- unsigned int read_exec_only:1;
- unsigned int limit_in_pages:1;
- unsigned int seg_not_present:1;
- unsigned int useable:1;
- unsigned int empty:25;
- }modify_ldt_s;
+#ifdef HAVE_STRUCT_USER_DESC
+typedef struct user_desc modify_ldt_s;
+#elif HAVE_STRUCT_MODIFY_LDT_LDT_S
+typedef struct modify_ldt_ldt_s modify_ldt_s;
+#else
+typedef struct modify_ldt_ldt_t
+{
+ unsigned int entry_number;
+ unsigned long int base_addr;
+ unsigned int limit;
+ unsigned int seg_32bit:1;
+ unsigned int contents:2;
+ unsigned int read_exec_only:1;
+ unsigned int limit_in_pages:1;
+ unsigned int seg_not_present:1;
+ unsigned int useable:1;
+ unsigned int empty:25;
+} modify_ldt_s;
#endif
int create_segment(void *, size_t);
+int read_segment(unsigned int);
void cleanup(void);
void setup(void);
-char *TCID= "modify_ldt02";
-int TST_TOTAL = 1;
-extern int Tst_count;
-
-int flag;
#define FAILED 1
-int seg[4];
-#if defined(__i386__)
-extern int modify_ldt(int, void*, unsigned long);
-int read_segment(unsigned int);
int
main(int ac, char **av)
{
@@ -98,6 +103,10 @@ main(int ac, char **av)
int val, pid, status;
+ int flag;
+ int seg[4];
+
+
/* parse standard options */
if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char
*)NULL){
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
@@ -199,21 +208,14 @@ int read_segment(unsigned int index)
: "r" (index*sizeof(int)));
return res;
}
-#else /* if defined(__i386__) */
-
-int main()
-{
- tst_resm(TINFO, "modify_ldt02 test only for ix86");
- return 0;
-}
-#endif /* if defined(__i386__) */
void
sigsegv_handler(int sig)
{
tst_resm(TINFO, "received signal: %d", sig);
exit(0);
}
+
/*
* setup() - performs all ONE TIME setup for this test
*/
@@ -251,3 +253,19 @@ cleanup(void)
/* exit with return code appropriate for results */
tst_exit();
}
+#elif HAVE_MODIFY_LDT
+int main()
+{
+ tst_resm(TCONF, "modify_ldt is available but not tested on the platform
than __i386__");
+ return 0;
+}
+
+#else /* if defined(__i386__) */
+
+int main()
+{
+ tst_resm(TINFO, "modify_ldt02 test only for ix86");
+ return 0;
+}
+
+#endif /* if defined(__i386__) */
diff --git a/testcases/kernel/syscalls/modify_ldt/run-modify_ldt01.sh
b/testcases/kernel/syscalls/modify_ldt/run-modify_ldt01.sh
deleted file mode 100755
index 78bf7a1..0000000
--- a/testcases/kernel/syscalls/modify_ldt/run-modify_ldt01.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-syscall=modify_ldt
-
-if [ -f $LTPROOT/testcases/bin/${syscall}01 ]; then
- $LTPROOT/testcases/bin/${syscall}01
-else
- echo "${syscall}01 0 CONF : System doesn't support execution of the
test"
-
-fi
-
diff --git a/testcases/kernel/syscalls/modify_ldt/run-modify_ldt02.sh
b/testcases/kernel/syscalls/modify_ldt/run-modify_ldt02.sh
deleted file mode 100755
index 0dd2e1f..0000000
--- a/testcases/kernel/syscalls/modify_ldt/run-modify_ldt02.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-syscall=modify_ldt
-
-if [ -f $LTPROOT/testcases/bin/${syscall}02 ]; then
- $LTPROOT/testcases/bin/${syscall}02
-else
- echo "${syscall}02 0 CONF : System doesn't support execution of the
test"
-
-fi
-
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list