summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-08-05 19:36:57 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-08-05 19:36:57 +0000
commit7c86172aba2e8c498f149764a4534af174ebad12 (patch)
treee49a3e3f42e067b6e4dd602e4151f73678d6eb94 /testsuites/libtests
parent2009-08-05 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-7c86172aba2e8c498f149764a4534af174ebad12.tar.bz2
2009-08-05 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, configure.ac: Add test for new BSP Boot Command Line helper routines. * bspcmdline01/.cvsignore, bspcmdline01/Makefile.am, bspcmdline01/bspcmdline01.doc, bspcmdline01/bspcmdline01.scn, bspcmdline01/init.c, bspcmdline01/test.c: New files.
Diffstat (limited to 'testsuites/libtests')
-rw-r--r--testsuites/libtests/ChangeLog8
-rw-r--r--testsuites/libtests/Makefile.am4
-rw-r--r--testsuites/libtests/bspcmdline01/.cvsignore2
-rw-r--r--testsuites/libtests/bspcmdline01/Makefile.am28
-rw-r--r--testsuites/libtests/bspcmdline01/bspcmdline01.doc26
-rw-r--r--testsuites/libtests/bspcmdline01/bspcmdline01.scn46
-rw-r--r--testsuites/libtests/bspcmdline01/init.c156
-rw-r--r--testsuites/libtests/bspcmdline01/test.c136
-rw-r--r--testsuites/libtests/configure.ac1
9 files changed, 405 insertions, 2 deletions
diff --git a/testsuites/libtests/ChangeLog b/testsuites/libtests/ChangeLog
index 07ad2fab72..d329c911cf 100644
--- a/testsuites/libtests/ChangeLog
+++ b/testsuites/libtests/ChangeLog
@@ -1,3 +1,11 @@
+2009-08-05 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * Makefile.am, configure.ac: Add test for new BSP Boot Command Line
+ helper routines.
+ * bspcmdline01/.cvsignore, bspcmdline01/Makefile.am,
+ bspcmdline01/bspcmdline01.doc, bspcmdline01/bspcmdline01.scn,
+ bspcmdline01/init.c, bspcmdline01/test.c: New files.
+
2009-07-09 Joel Sherrill <joel.sherrill@OARcorp.com>
* malloctest/init.c, malloctest/malloctest.scn: Add heap resize test
diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am
index 38132baaab..b56a5038e1 100644
--- a/testsuites/libtests/Makefile.am
+++ b/testsuites/libtests/Makefile.am
@@ -4,8 +4,8 @@
ACLOCAL_AMFLAGS = -I ../aclocal
-SUBDIRS = cpuuse malloctest heapwalk putenvtest monitor monitor02 rtmonuse \
- stackchk termios rtems++ tztest
+SUBDIRS = bspcmdline01 cpuuse malloctest heapwalk putenvtest monitor \
+ monitor02 rtmonuse stackchk termios rtems++ tztest
include $(top_srcdir)/../automake/subdirs.am
include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/libtests/bspcmdline01/.cvsignore b/testsuites/libtests/bspcmdline01/.cvsignore
new file mode 100644
index 0000000000..282522db03
--- /dev/null
+++ b/testsuites/libtests/bspcmdline01/.cvsignore
@@ -0,0 +1,2 @@
+Makefile
+Makefile.in
diff --git a/testsuites/libtests/bspcmdline01/Makefile.am b/testsuites/libtests/bspcmdline01/Makefile.am
new file mode 100644
index 0000000000..ba7d16ffd3
--- /dev/null
+++ b/testsuites/libtests/bspcmdline01/Makefile.am
@@ -0,0 +1,28 @@
+##
+## $Id$
+##
+
+MANAGERS = all
+
+rtems_tests_PROGRAMS = bspcmdline01
+bspcmdline01_SOURCES = init.c
+
+dist_rtems_tests_DATA = bspcmdline01.scn
+dist_rtems_tests_DATA += bspcmdline01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+bspcmdline01_LDADD = $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(bspcmdline01_OBJECTS) $(bspcmdline01_LDADD)
+LINK_LIBS = $(bspcmdline01_LDLIBS)
+
+bspcmdline01$(EXEEXT): $(bspcmdline01_OBJECTS) $(bspcmdline01_DEPENDENCIES)
+ @rm -f bspcmdline01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/libtests/bspcmdline01/bspcmdline01.doc b/testsuites/libtests/bspcmdline01/bspcmdline01.doc
new file mode 100644
index 0000000000..5fc4c8767f
--- /dev/null
+++ b/testsuites/libtests/bspcmdline01/bspcmdline01.doc
@@ -0,0 +1,26 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989-2009.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.com/license/LICENSE.
+#
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: bspcmdline01
+
+directives:
+
+ bsp_cmdline_get
+ bsp_cmdline_get_param
+ bsp_cmdline_get_param_rhs
+ bsp_cmdline_get_param_raw
+
+concepts:
+
++ Ensure that the BSP Boot Command Line Helper routines are
+ fully exercised.
diff --git a/testsuites/libtests/bspcmdline01/bspcmdline01.scn b/testsuites/libtests/bspcmdline01/bspcmdline01.scn
new file mode 100644
index 0000000000..4c9efc9e1a
--- /dev/null
+++ b/testsuites/libtests/bspcmdline01/bspcmdline01.scn
@@ -0,0 +1,46 @@
+*** TEST OF PARSING BOOT COMMAND STRING ***
+BSP does not have a boot command line
+
+Test Parameter Error Conditions
+bsp_cmdline_get_param - name=NULL - returns NULL
+bsp_cmdline_get_param - result=NULL - returns NULL
+bsp_cmdline_get_param - length=0 - returns NULL
+bsp_cmdline_get_param_raw - name=NULL - returns NULL
+bsp_cmdline_get_param - bsp_boot_cmdline=NULL - returns NULL
+bsp_cmdline_get_param_raw - bsp_boot_cmdline=NULL - returns NULL
+
+Testing for param=(--arg)
+ Command Line : (--arg=)
+bsp_cmdline_get_param_raw(--arg)
+bsp_cmdline_get_param_raw(--arg) returned (--arg=)
+bsp_cmdline_get_param_rhs(--arg)
+bsp_cmdline_get_param_rhs(--arg) returned (ZERO_LENGTH_STRING) value=(ZERO_LENGTH_STRING)
+
+Testing for param=(-g) - Expect NULL
+ Command Line : (--arg=)
+bsp_cmdline_get_param_raw(-g)
+bsp_cmdline_get_param_raw(-g) returned NULL
+bsp_cmdline_get_param_rhs(-g)
+bsp_cmdline_get_param_rhs(-g) returned NULL
+
+Testing for param=(-name)
+ Command Line : (--ip=192.168.1.151 --name=fred)
+bsp_cmdline_get_param_raw(-name)
+bsp_cmdline_get_param_raw(-name) returned (-name=fred)
+bsp_cmdline_get_param_rhs(-name)
+bsp_cmdline_get_param_rhs(-name) returned (fred) value=(fred)
+
+Testing for param=(-ip)
+ Command Line : (--ip=192.168.1.151 --name=fred)
+bsp_cmdline_get_param_raw(-ip)
+bsp_cmdline_get_param_raw(-ip) returned (-ip=192.168.1.151 --name=fred)
+bsp_cmdline_get_param_rhs(-ip)
+bsp_cmdline_get_param_rhs(-ip) returned (192.168.1.151) value=(192.168.1.151)
+
+Testing for param=(-name)
+ Command Line : (--ip=192.168.1.151 --name="joel and michele" --cpu=fast)
+bsp_cmdline_get_param_raw(-name)
+bsp_cmdline_get_param_raw(-name) returned (-name="joel and michele" --cpu=fast)
+bsp_cmdline_get_param_rhs(-name)
+bsp_cmdline_get_param_rhs(-name) returned (joel and michele) value=(joel and michele)
+*** END OF OF PARSING BOOT COMMAND STRING ***
diff --git a/testsuites/libtests/bspcmdline01/init.c b/testsuites/libtests/bspcmdline01/init.c
new file mode 100644
index 0000000000..629e4f6f9a
--- /dev/null
+++ b/testsuites/libtests/bspcmdline01/init.c
@@ -0,0 +1,156 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <tmacros.h>
+#include <rtems/bspcmdline.h>
+
+extern const char *bsp_boot_cmdline;
+
+void test_errors(void)
+{
+ const char *p;
+ char result[32];
+
+ bsp_boot_cmdline = NULL;
+
+ puts( "bsp_cmdline_get_param - name=NULL - returns NULL" );
+ p = bsp_cmdline_get_param( NULL, result, 32 );
+ assert( p == NULL );
+
+ puts( "bsp_cmdline_get_param - result=NULL - returns NULL" );
+ p = bsp_cmdline_get_param( "name", NULL, 32 );
+ assert( p == NULL );
+
+ puts( "bsp_cmdline_get_param - length=0 - returns NULL" );
+ p = bsp_cmdline_get_param( "name", result, 0 );
+ assert( p == NULL );
+
+ puts( "bsp_cmdline_get_param_raw - name=NULL - returns NULL" );
+ p = bsp_cmdline_get_param_raw( NULL );
+ assert( p == NULL );
+
+ bsp_boot_cmdline = NULL;
+
+ puts( "bsp_cmdline_get_param - bsp_boot_cmdline=NULL - returns NULL" );
+ p = bsp_cmdline_get_param( "name", result, 5 );
+ assert( p == NULL );
+
+ puts( "bsp_cmdline_get_param_raw - bsp_boot_cmdline=NULL - returns NULL" );
+ p = bsp_cmdline_get_param_raw( "name" );
+ assert( p == NULL );
+}
+
+void test_search(
+ bool null_expected,
+ const char *cmdline,
+ const char *param
+)
+{
+ const char *p;
+ char value[80];
+ size_t length;
+
+ bsp_boot_cmdline = cmdline;
+
+ printf(
+ "\n"
+ "Testing for param=(%s)%s\n"
+ " Command Line : (%s)\n",
+ param,
+ ((null_expected) ? " - Expect NULL" : ""),
+ cmdline
+ );
+
+ printf( "bsp_cmdline_get_param_raw(%s)\n", param );
+ p = bsp_cmdline_get_param_raw( param );
+ if ( null_expected ) {
+ if ( p )
+ puts( "ERROR - bsp_cmdline_get_param_raw did not return NULL" );
+ else
+ printf( "bsp_cmdline_get_param_raw(%s) returned NULL\n", param );
+ assert( !p );
+ } else {
+ if ( p )
+ printf( "bsp_cmdline_get_param_raw(%s) returned (%s)\n", param, p );
+ else
+ printf( "bsp_cmdline_get_param_raw(%s) returned NULL\n", param );
+
+ assert( p );
+ }
+
+ printf( "bsp_cmdline_get_param_rhs(%s)\n", param );
+ length = sizeof(value);
+ p = bsp_cmdline_get_param_rhs( param, value, length );
+ if ( null_expected ) {
+ if ( p )
+ puts( "ERROR - bsp_cmdline_get_param_rhs did not return NULL" );
+ else
+ printf( "bsp_cmdline_get_param_rhs(%s) returned NULL\n", param );
+ assert( !p );
+ } else {
+ if ( !p )
+ puts( "ERROR - bsp_cmdline_get_param_rhs returned NULL" );
+ assert( p );
+ printf(
+ "bsp_cmdline_get_param_rhs(%s) returned (%s) value=(%s)\n",
+ param,
+ ((*p == '\0') ? "ZERO_LENGTH_STRING" : p ),
+ ((*value == '\0') ? "ZERO_LENGTH_STRING" : value )
+ );
+ }
+
+}
+
+rtems_task Init(
+ rtems_task_argument ignored
+)
+{
+ puts( "\n\n*** TEST OF PARSING BOOT COMMAND STRING ***" );
+
+ if ( bsp_cmdline_get() ) {
+ printf(
+ "BSP has a boot command line:\n"
+ "%s\n",
+ bsp_boot_cmdline
+ );
+ } else {
+ puts( "BSP does not have a boot command line" );
+ }
+
+ puts( "\nTest Parameter Error Conditions" );
+ test_errors();
+
+ test_search( false, "--arg=", "--arg" );
+ test_search( true, "--arg=", "-g" );
+ test_search( false, "--ip=192.168.1.151 --name=fred", "-name" );
+ test_search( false, "--ip=192.168.1.151 --name=fred", "-ip" );
+ test_search(
+ false,
+ "--ip=192.168.1.151 --name=\"joel and michele\" --cpu=fast",
+ "-name"
+ );
+
+ puts( "*** END OF OF PARSING BOOT COMMAND STRING ***" );
+ rtems_test_exit(0);
+}
+
+/* configuration information */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 1
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT
+#include <rtems/confdefs.h>
+
+/* global variables */
diff --git a/testsuites/libtests/bspcmdline01/test.c b/testsuites/libtests/bspcmdline01/test.c
new file mode 100644
index 0000000000..6bfdce03c1
--- /dev/null
+++ b/testsuites/libtests/bspcmdline01/test.c
@@ -0,0 +1,136 @@
+/*
+ * COPYRIGHT (c) 1989-2009.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include <stdbool.h>
+#include <rtems/bspcmdline.h>
+
+#define rtems_test_exit(_x) exit(_x)
+
+extern const char *bsp_boot_cmdline;
+
+void test_errors(void)
+{
+ const char *p;
+ char result[32];
+
+ bsp_boot_cmdline = NULL;
+
+ puts( "bsp_cmdline_get_param - name=NULL - returns NULL" );
+ p = bsp_cmdline_get_param( NULL, result, 32 );
+ assert( p == NULL );
+
+ puts( "bsp_cmdline_get_param - result=NULL - returns NULL" );
+ p = bsp_cmdline_get_param( "name", NULL, 32 );
+ assert( p == NULL );
+
+ puts( "bsp_cmdline_get_param - length=0 - returns NULL" );
+ p = bsp_cmdline_get_param( "name", result, 0 );
+ assert( p == NULL );
+
+ puts( "bsp_cmdline_get_param_raw - name=NULL - returns NULL" );
+ p = bsp_cmdline_get_param_raw( NULL );
+ assert( p == NULL );
+
+ bsp_boot_cmdline = NULL;
+
+ puts( "bsp_cmdline_get_param - bsp_boot_cmdline=NULL - returns NULL" );
+ p = bsp_cmdline_get_param( "name", result, 5 );
+ assert( p == NULL );
+
+ puts( "bsp_cmdline_get_param_raw - bsp_boot_cmdline=NULL - returns NULL" );
+ p = bsp_cmdline_get_param_raw( "name" );
+ assert( p == NULL );
+}
+
+void test_search(
+ bool null_expected,
+ const char *cmdline,
+ const char *param
+)
+{
+ const char *p;
+ char value[80];
+ size_t length;
+
+ bsp_boot_cmdline = cmdline;
+
+ printf(
+ "\n"
+ "Testing for param=(%s)%s\n"
+ " Command Line : (%s)\n",
+ param,
+ ((null_expected) ? " - Expect NULL" : ""),
+ cmdline
+ );
+
+ printf( "bsp_cmdline_get_param_raw(%s)\n", param );
+ p = bsp_cmdline_get_param_raw( param );
+ if ( null_expected ) {
+ if ( p )
+ puts( "ERROR - bsp_cmdline_get_param_raw did not return NULL" );
+ else
+ printf( "bsp_cmdline_get_param_raw(%s) returned NULL\n", param );
+ assert( !p );
+ } else {
+ if ( p )
+ printf( "bsp_cmdline_get_param_raw(%s) returned (%s)\n", param, p );
+ else
+ printf( "bsp_cmdline_get_param_raw(%s) returned NULL\n", param );
+
+ assert( p );
+ }
+
+
+ printf( "bsp_cmdline_get_param_rhs(%s)\n", param );
+ length = sizeof(value);
+ p = bsp_cmdline_get_param_rhs( param, value, length );
+ if ( null_expected ) {
+ if ( p )
+ puts( "ERROR - bsp_cmdline_get_param_rhs did not return NULL" );
+ else
+ printf( "bsp_cmdline_get_param_rhs(%s) returned NULL\n", param );
+ assert( !p );
+ } else {
+ if ( !p )
+ puts( "ERROR - bsp_cmdline_get_param_rhs returned NULL" );
+ assert( p );
+ printf(
+ "bsp_cmdline_get_param_rhs(%s) returned (%s) value=(%s)\n",
+ param,
+ ((*p == '\0') ? "ZERO_LENGTH_STRING" : p ),
+ ((*value == '\0') ? "ZERO_LENGTH_STRING" : value )
+ );
+ }
+
+}
+
+void test_cmdline(void)
+{
+
+ puts( "\n\n*** TEST OF PARSING BOOT COMMAND STRING ***" );
+
+ puts( "Test Parameter Error Conditions" );
+ test_errors();
+
+ test_search( false, "--arg=", "--arg" );
+ test_search( true, "--arg=", "-g" );
+ test_search( false, "--ip=192.168.1.151 --name=fred", "-name" );
+ test_search( false, "--ip=192.168.1.151 --name=fred", "-ip" );
+ test_search(
+ false,
+ "--ip=192.168.1.151 --name=\"joel and michele\" --cpu=fast",
+ "-name"
+ );
+
+ puts( "*** END OF OF PARSING BOOT COMMAND STRING ***" );
+}
diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac
index 48f6234a74..012e3ddb19 100644
--- a/testsuites/libtests/configure.ac
+++ b/testsuites/libtests/configure.ac
@@ -33,6 +33,7 @@ AM_CONDITIONAL(HAS_CXX,test "$rtems_cv_HAS_CPLUSPLUS" = "yes")
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile
+bspcmdline01/Makefile
cpuuse/Makefile
heapwalk/Makefile
malloctest/Makefile