summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-05-05 15:29:54 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-05-05 15:29:54 +0000
commitbdaa9488e88a49746e058386c3b74ba338525812 (patch)
tree79fc10946258032dcf13ecf0b7e04c6a3e76b00f /misc
parent9b2361a20d85493471d52545259128bdb3640b29 (diff)
2010-05-05 Joel Sherrill <joel.sherrill@oarcorp.com>
* qemu_vfat/Makefile, qemu_vfat/README, qemu_vfat/init.c: Now includes a start_test example which parses arguments. * qemu_vfat/start_test.c: New file.
Diffstat (limited to 'misc')
-rw-r--r--misc/ChangeLog6
-rw-r--r--misc/qemu_vfat/Makefile2
-rw-r--r--misc/qemu_vfat/README1
-rw-r--r--misc/qemu_vfat/init.c4
-rw-r--r--misc/qemu_vfat/start_test.c91
5 files changed, 102 insertions, 2 deletions
diff --git a/misc/ChangeLog b/misc/ChangeLog
index 46dac60..6a69f09 100644
--- a/misc/ChangeLog
+++ b/misc/ChangeLog
@@ -1,5 +1,11 @@
2010-05-05 Joel Sherrill <joel.sherrill@oarcorp.com>
+ * qemu_vfat/Makefile, qemu_vfat/README, qemu_vfat/init.c: Now includes
+ a start_test example which parses arguments.
+ * qemu_vfat/start_test.c: New file.
+
+2010-05-05 Joel Sherrill <joel.sherrill@oarcorp.com>
+
* qemu_vfat/.cvsignore, qemu_vfat/Makefile, qemu_vfat/README,
qemu_vfat/init.c, qemu_vfat/system.h: New files.
diff --git a/misc/qemu_vfat/Makefile b/misc/qemu_vfat/Makefile
index 3b873d5..98f13ca 100644
--- a/misc/qemu_vfat/Makefile
+++ b/misc/qemu_vfat/Makefile
@@ -12,7 +12,7 @@ PGM=${ARCH}/qemu_vfat.exe
MANAGERS=all
# C source names
-CSRCS = init.c
+CSRCS = init.c start_test.c
COBJS = $(CSRCS:%.c=${ARCH}/%.o)
include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
diff --git a/misc/qemu_vfat/README b/misc/qemu_vfat/README
index 14b1922..d9ba661 100644
--- a/misc/qemu_vfat/README
+++ b/misc/qemu_vfat/README
@@ -17,3 +17,4 @@ executable exercised with different arguments or input files.
With this setup, you can copy those test support files into
the host directory and the RTEMS "main" will use those in
support of the testing.
+
diff --git a/misc/qemu_vfat/init.c b/misc/qemu_vfat/init.c
index 05a2913..6d297b3 100644
--- a/misc/qemu_vfat/init.c
+++ b/misc/qemu_vfat/init.c
@@ -30,9 +30,10 @@
* with the "rtems_fsmount" function.
* See cpukit/libmisc/fsmount for definition of fields
*/
+#define MOUNT_POINT "/mnt/test"
fstab_t fs_table[] = {
{
- "/dev/hda1", "/mnt/test",
+ "/dev/hda1", MOUNT_POINT,
&msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED,
0
@@ -148,6 +149,7 @@ Init (rtems_task_argument ignored)
fileio_start_shell ();
#endif
#if defined(USE_START_TEST)
+ chdir( MOUNT_POINT );
start_test ();
#endif
puts( "*** END OF QEMU VFAT AND SHELL TEST ***" );
diff --git a/misc/qemu_vfat/start_test.c b/misc/qemu_vfat/start_test.c
new file mode 100644
index 0000000..b062e18
--- /dev/null
+++ b/misc/qemu_vfat/start_test.c
@@ -0,0 +1,91 @@
+/*
+ * Start Test Example
+ *
+ * $Id$
+ */
+
+#if defined(USE_START_TEST)
+
+#define __need_getopt_newlib
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rtems/shell.h>
+
+#define COMMAND_LINE_ARGUMENTS_FILE "arguments"
+
+#define ARGV_LENGTH 80
+#define ARGV_LIMIT 32
+
+int Argc;
+char *Argv[ARGV_LIMIT];
+char Argv_String[ ARGV_LENGTH ];
+
+void parse_arguments(void)
+{
+ FILE *in;
+ char *cStatus;
+ size_t length;
+ int sc;
+
+ in = fopen( COMMAND_LINE_ARGUMENTS_FILE, "r" );
+ if ( !in ) {
+ fprintf( stderr, "Unable to open %s\n", COMMAND_LINE_ARGUMENTS_FILE );
+ exit(1);
+ }
+
+ cStatus = fgets( Argv_String, sizeof(Argv_String), in );
+ if ( cStatus == NULL ) {
+ fprintf( stderr, "Unable to read %s\n", COMMAND_LINE_ARGUMENTS_FILE );
+ exit(1);
+ }
+
+ // If the last line does not have a CR, then we don't want to
+ // arbitrarily clobber an = instead of a \n.
+ length = strlen(Argv_String);
+ if ( Argv_String[ length - 1] != '\n' ) {
+ fprintf(
+ stderr,
+ "Line appears to be too long in %s\n",
+ COMMAND_LINE_ARGUMENTS_FILE
+ );
+ exit(1);
+ }
+
+ Argv_String[ length - 1] = '\0';
+
+ sc = rtems_shell_make_args(
+ &Argv_String[0],
+ &Argc,
+ &Argv[1],
+ ARGV_LIMIT - 1
+ );
+ if ( sc ) {
+ fprintf( stderr, "Error parsing arguments\n" );
+ exit(1);
+ }
+
+ /* Since we added the program name ourselves and started at 0 */
+ Argc++;
+ fclose(in);
+}
+
+void print_arguments(void)
+{
+ int i;
+
+ for ( i=0 ; i<Argc ; i++ ) {
+ fprintf( stderr, "argc[%d] = %s\n", i, Argv[i] );
+ }
+
+}
+
+void start_test(void)
+{
+ Argv[0] = "my_program";
+ parse_arguments();
+ print_arguments();
+ /* If this were a real user test, we would invoke the main here */
+}
+#endif