[PATCH v2] libmisc: More useful default configuration
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed Dec 3 08:46:01 UTC 2014
The dummy.c is a de-facto default configuration so use unlimited objects
and the stack checker. This makes it easier for new RTEMS users which
will likely use this file if they just work with the usual main()
function as the application entry point. Provide proper arguments for
main() using the BSP command line. Add spare user extensions and
drivers.
---
cpukit/libmisc/dummy/dummy.c | 75 +++++++++++++++++++++++++++++++--
testsuites/libtests/Makefile.am | 1 +
testsuites/libtests/configure.ac | 1 +
testsuites/libtests/dummy01/Makefile.am | 19 +++++++++
testsuites/libtests/dummy01/dummy01.doc | 11 +++++
testsuites/libtests/dummy01/dummy01.scn | 2 +
testsuites/libtests/dummy01/init.c | 59 ++++++++++++++++++++++++++
7 files changed, 164 insertions(+), 4 deletions(-)
create mode 100644 testsuites/libtests/dummy01/Makefile.am
create mode 100644 testsuites/libtests/dummy01/dummy01.doc
create mode 100644 testsuites/libtests/dummy01/dummy01.scn
create mode 100644 testsuites/libtests/dummy01/init.c
diff --git a/cpukit/libmisc/dummy/dummy.c b/cpukit/libmisc/dummy/dummy.c
index 839a556..82618d5 100644
--- a/cpukit/libmisc/dummy/dummy.c
+++ b/cpukit/libmisc/dummy/dummy.c
@@ -13,18 +13,85 @@
#include "config.h"
#endif
+#include <stdlib.h>
+
#include <rtems.h>
-int main( int, char **, char **);
+int main( int argc, char **argv );
+
+static void Init( rtems_task_argument arg )
+{
+ const char *boot_cmdline = *((const char **) arg);
+ char *cmdline = NULL;
+ int argc = 0;
+ char **argv = NULL;
+ int result;
+
+ if ( boot_cmdline != NULL ) {
+ size_t n = strlen( boot_cmdline ) + 1;
+
+ cmdline = malloc( n );
+ if ( cmdline != NULL ) {
+ char* command;
+
+ memcpy( cmdline, boot_cmdline, n);
+
+ command = cmdline;
+
+ /*
+ * Break the line up into arguments with "" being ignored.
+ */
+ while ( true ) {
+ command = strtok( command, " \t\r\n" );
+ if ( command == NULL )
+ break;
+
+ ++argc;
+ command = '\0';
+ }
+
+ /*
+ * If there are arguments, allocate enough memory for the argv
+ * array to be passed into main().
+ *
+ * NOTE: If argc is 0, then argv will be NULL.
+ */
+ argv = calloc( argc, sizeof( *argv ) );
+ if ( argv != NULL ) {
+ int a;
+
+ command = cmdline;
+ argv[ 0 ] = command;
+
+ for ( a = 1; a < argc; ++a ) {
+ command += strlen( command ) + 1;
+ argv[ a ] = command;
+ }
+ } else {
+ argc = 0;
+ }
+ }
+ }
+
+ result = main( argc, argv );
+
+ free( argv );
+ free( cmdline );
+
+ exit( result );
+}
/* configuration information */
/* This is enough to get a basic main() up. */
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
-#define CONFIGURE_MAXIMUM_TASKS 10
+#define CONFIGURE_UNIFIED_WORK_AREAS
+#define CONFIGURE_UNLIMITED_OBJECTS
+#define CONFIGURE_STACK_CHECKER_ENABLED
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
-#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
-#define CONFIGURE_INIT_TASK_ENTRY_POINT (void *)main
+#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 8
+#define CONFIGURE_MAXIMUM_DRIVERS 16
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
/* Include basic device drivers needed to call delays */
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am
index 4f22ac8..4c564ce 100644
--- a/testsuites/libtests/Makefile.am
+++ b/testsuites/libtests/Makefile.am
@@ -1,6 +1,7 @@
ACLOCAL_AMFLAGS = -I ../aclocal
_SUBDIRS = POSIX
+_SUBDIRS += dummy01
_SUBDIRS += pwdgrp02
_SUBDIRS += shell01
_SUBDIRS += pwdgrp01
diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac
index 53a017b..e5dc281 100644
--- a/testsuites/libtests/configure.ac
+++ b/testsuites/libtests/configure.ac
@@ -67,6 +67,7 @@ AM_CONDITIONAL(DLTESTS,[test x"$TEST_LIBDL" = x"yes"])
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile
+dummy01/Makefile
pwdgrp02/Makefile
shell01/Makefile
pwdgrp01/Makefile
diff --git a/testsuites/libtests/dummy01/Makefile.am b/testsuites/libtests/dummy01/Makefile.am
new file mode 100644
index 0000000..b30d678
--- /dev/null
+++ b/testsuites/libtests/dummy01/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = dummy01
+dummy01_SOURCES = init.c
+
+dist_rtems_tests_DATA = dummy01.scn dummy01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(dummy01_OBJECTS)
+LINK_LIBS = $(dummy01_LDLIBS)
+
+dummy01$(EXEEXT): $(dummy01_OBJECTS) $(dummy01_DEPENDENCIES)
+ @rm -f dummy01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/libtests/dummy01/dummy01.doc b/testsuites/libtests/dummy01/dummy01.doc
new file mode 100644
index 0000000..bca8421
--- /dev/null
+++ b/testsuites/libtests/dummy01/dummy01.doc
@@ -0,0 +1,11 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: dummy01
+
+directives:
+
+ - main()
+
+concepts:
+
+ - Make sure the default configuration works.
diff --git a/testsuites/libtests/dummy01/dummy01.scn b/testsuites/libtests/dummy01/dummy01.scn
new file mode 100644
index 0000000..cc3e9b9
--- /dev/null
+++ b/testsuites/libtests/dummy01/dummy01.scn
@@ -0,0 +1,2 @@
+*** BEGIN OF TEST DUMMY 1 ***
+*** END OF TEST DUMMY 1 ***
diff --git a/testsuites/libtests/dummy01/init.c b/testsuites/libtests/dummy01/init.c
new file mode 100644
index 0000000..434ac0a
--- /dev/null
+++ b/testsuites/libtests/dummy01/init.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include <bsp.h>
+
+#include "tmacros.h"
+
+const char rtems_test_name[] = "DUMMY 1";
+
+static void install_bsp_extension(void)
+{
+#ifdef BSP_INITIAL_EXTENSION
+ static const rtems_extensions_table bsp_ext = BSP_INITIAL_EXTENSION;
+
+ rtems_status_code sc;
+ rtems_id id;
+
+ sc = rtems_extension_create(
+ rtems_build_name('B', 'S', 'P', ' '),
+ &bsp_ext,
+ &id
+ );
+ rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+#endif
+}
+
+int main(int argc, char **argv)
+{
+ int i;
+
+ TEST_BEGIN();
+
+ install_bsp_extension();
+
+ for (i = 0; i < argc; ++i) {
+ printf("argv[%i] = %s\n", i, argv[i]);
+ }
+
+ TEST_END();
+
+ return 0;
+}
--
1.8.4.5
More information about the devel
mailing list