From 9f4b8dc11b1eea55c8b8df5fb99e9ece84a452e3 Mon Sep 17 00:00:00 2001 From: Thomas Cort Date: Thu, 29 Aug 2013 08:56:27 -0400 Subject: [PATCH] kernel: move do_padconf and add a test case padconf is specific to arm, so it's being moved to kernel/arch/earm. Add a test case to ensure the proper error is returned on non-ARM systems. Change-Id: I07ebbe64825d59bc0ef9c818d3d54891dafb4419 --- kernel/arch/earm/Makefile.inc | 2 +- kernel/{system => arch/earm}/do_padconf.c | 0 kernel/system/Makefile.inc | 5 -- test/kernel/run | 2 +- test/kernel/sys_padconf/Makefile | 16 ++++++ test/kernel/sys_padconf/padconftest.c | 59 +++++++++++++++++++++++ test/kernel/sys_padconf/run | 14 ++++++ test/kernel/sys_padconf/system.conf | 4 ++ 8 files changed, 95 insertions(+), 7 deletions(-) rename kernel/{system => arch/earm}/do_padconf.c (100%) create mode 100644 test/kernel/sys_padconf/Makefile create mode 100644 test/kernel/sys_padconf/padconftest.c create mode 100755 test/kernel/sys_padconf/run create mode 100644 test/kernel/sys_padconf/system.conf diff --git a/kernel/arch/earm/Makefile.inc b/kernel/arch/earm/Makefile.inc index 2ca8212cb..cd61e526a 100644 --- a/kernel/arch/earm/Makefile.inc +++ b/kernel/arch/earm/Makefile.inc @@ -63,7 +63,7 @@ ORIG_UNPAGED_OBJS += ${unpaged_obj} CLEANFILES+= ${ORIG_UNPAGED_OBJS} -SRCS+= mpx.S arch_clock.c arch_do_vmctl.c arch_system.c \ +SRCS+= mpx.S arch_clock.c arch_do_vmctl.c arch_system.c do_padconf.c \ omap_serial.c omap_timer.c omap_padconf.c omap_intr.c omap_rtc.c \ omap_reset.c exception.c klib.S memory.c \ protect.c direct_tty_utils.c arch_reset.c \ diff --git a/kernel/system/do_padconf.c b/kernel/arch/earm/do_padconf.c similarity index 100% rename from kernel/system/do_padconf.c rename to kernel/arch/earm/do_padconf.c diff --git a/kernel/system/Makefile.inc b/kernel/system/Makefile.inc index 627e28cab..e90b47640 100644 --- a/kernel/system/Makefile.inc +++ b/kernel/system/Makefile.inc @@ -40,11 +40,6 @@ SRCS+= \ do_schedctl.c \ do_statectl.c -.if ${MACHINE_ARCH} == "earm" -SRCS+= \ - do_padconf.c -.endif - .if ${MACHINE_ARCH} == "i386" SRCS+= \ do_devio.c \ diff --git a/test/kernel/run b/test/kernel/run index c1e8b1d04..39d931e19 100755 --- a/test/kernel/run +++ b/test/kernel/run @@ -1,5 +1,5 @@ #!/bin/sh -tests="sys_vumap" +tests="sys_padconf sys_vumap" for i in $tests; do (cd $i && ./run); done diff --git a/test/kernel/sys_padconf/Makefile b/test/kernel/sys_padconf/Makefile new file mode 100644 index 000000000..ad82370c5 --- /dev/null +++ b/test/kernel/sys_padconf/Makefile @@ -0,0 +1,16 @@ +# Makefile for the sys_padconf test. + +.include + +PROG= padconftest +SRCS= padconftest.c + +DPADD+= ${LIBSYS} +LDADD+= -lsys + +MAN= + +BINDIR?= /usr/tests/minix-posix + +.include "${NETBSDSRCDIR}/drivers/Makefile.inc" +.include diff --git a/test/kernel/sys_padconf/padconftest.c b/test/kernel/sys_padconf/padconftest.c new file mode 100644 index 000000000..b0e06bb38 --- /dev/null +++ b/test/kernel/sys_padconf/padconftest.c @@ -0,0 +1,59 @@ +/* Test for sys_padconf() */ +#include +#include +#include +#include +#include +#include +#include + +static unsigned int failures = 0; + +/* + * padconf is only supported on ARM. On other systems sys_padconf() should + * return -EBADREQUEST. + */ +static void test_badrequest(void) +{ +#if !defined(__arm__) + int r; + + r = sys_padconf(0xffffffff, 0xffffffff, 0xffffffff); + if (r != -EBADREQUEST) { + printf("Expected r=%d | Got r=%d\n", -EBADREQUEST, r); + failures++; + } +#endif + return; +} + +static void do_tests(void) +{ + test_badrequest(); +} + +static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info)) +{ + do_tests(); + + /* The returned code will determine the outcome of the RS call, and + * thus the entire test. The actual error code does not matter. + */ + return (failures) ? EINVAL : 0; +} + +static void sef_local_startup(void) +{ + sef_setcb_init_fresh(sef_cb_init_fresh); + + sef_startup(); +} + +int main(int argc, char **argv) +{ + env_setargs(argc, argv); + + sef_local_startup(); + + return 0; +} diff --git a/test/kernel/sys_padconf/run b/test/kernel/sys_padconf/run new file mode 100755 index 000000000..c47743c69 --- /dev/null +++ b/test/kernel/sys_padconf/run @@ -0,0 +1,14 @@ +#!/bin/sh + +make >/dev/null + +echo -n "Kernel test (sys_padconf): " +service up `pwd`/padconftest -config system.conf -label padconftest -script /etc/rs.single +r=$? + +if [ $r -ne 0 ]; then + echo "failure" + exit 1 +fi + +echo "ok" diff --git a/test/kernel/sys_padconf/system.conf b/test/kernel/sys_padconf/system.conf new file mode 100644 index 000000000..0e2f3309e --- /dev/null +++ b/test/kernel/sys_padconf/system.conf @@ -0,0 +1,4 @@ +service padconftest { + system PADCONF; +}; + -- 2.44.0