diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-21 18:09:39 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-21 18:09:39 +0000 |
commit | 622ea63d734f5a3e86eaffac117d6fb66507ec7f (patch) | |
tree | b76c752f7e5693fb75712fb03a7fb8c13b06eee6 | |
parent | ae15cd5e53907a95e42586d1a96a24b71299349d (diff) | |
download | nuttx-622ea63d734f5a3e86eaffac117d6fb66507ec7f.tar.gz nuttx-622ea63d734f5a3e86eaffac117d6fb66507ec7f.tar.bz2 nuttx-622ea63d734f5a3e86eaffac117d6fb66507ec7f.zip |
Finishes first cut of examples/nxflat
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1922 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | nuttx/examples/nxflat/nxflat_main.c | 47 | ||||
-rw-r--r-- | nuttx/examples/nxflat/tests/Makefile | 26 | ||||
-rwxr-xr-x | nuttx/examples/nxflat/tests/mkdirlist.sh | 35 | ||||
-rwxr-xr-x | nuttx/examples/nxflat/tests/mksymtab.sh | 38 |
4 files changed, 131 insertions, 15 deletions
diff --git a/nuttx/examples/nxflat/nxflat_main.c b/nuttx/examples/nxflat/nxflat_main.c index 3eddcb4a2..e792fa1b7 100644 --- a/nuttx/examples/nxflat/nxflat_main.c +++ b/nuttx/examples/nxflat/nxflat_main.c @@ -40,10 +40,18 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <pthread.h> #include <debug.h> +#include <errno.h> +#include <nuttx/binfmt.h> #include "tests/romfs.h" #include "tests/dirlist.h" +#include "tests/symtab.h" /**************************************************************************** * Definitions @@ -57,11 +65,23 @@ * Private Data ****************************************************************************/ +static const char delimiter[] = + "****************************************************************************"; + /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** + * Name: testheader + ****************************************************************************/ + +static inline void testheader(FAR const char *progname) +{ + printf("\n%s\n* Executing %s\n%s\n\n", delimiter, progname, delimiter); +} + +/**************************************************************************** * Public Functions ****************************************************************************/ @@ -79,5 +99,32 @@ void user_initialize(void) int user_start(int argc, char *argv[]) { + struct binary_s bin; + int ret; + int i; + + for (i = 0; dirlist[i]; i++) + { + testheader(dirlist[i]); + + memset(&bin, 0, sizeof(struct binary_s)); + bin.filename = dirlist[i]; + bin.exports = exports; + bin.nexports = NEXPORTS; + + ret = load_module(&bin); + if (ret < 0) + { + fprintf(stderr, "ERROR: Failed to load program '%s'\n", dirlist[i]); + exit(1); + } + + ret = exec_module(&bin, 50); + if (ret < 0) + { + fprintf(stderr, "ERROR: Failed to execute program '%s'\n", dirlist[i]); + unload_module(&bin); + } + } return 0; } diff --git a/nuttx/examples/nxflat/tests/Makefile b/nuttx/examples/nxflat/tests/Makefile index 6420e4773..c327e71b4 100644 --- a/nuttx/examples/nxflat/tests/Makefile +++ b/nuttx/examples/nxflat/tests/Makefile @@ -43,13 +43,14 @@ ROMFS_DIR = $(TESTS_DIR)/romfs ROMFS_IMG = $(TESTS_DIR)/romfs.img ROMFS_HDR = $(TESTS_DIR)/romfs.h ROMFS_DIRLIST = $(TESTS_DIR)/dirlist.h +SYMTAB = $(TESTS_DIR)/symtab.h define DIR_template $(1)_$(2): @$(MAKE) -C $(1) $(3) TOPDIR=$(TOPDIR) ROMFS_DIR=$(ROMFS_DIR) CROSSDEV=$(CROSSDEV) endef -all: $(ROMFS_HDR) $(ROMFS_DIRLIST) +all: $(ROMFS_HDR) $(ROMFS_DIRLIST) $(SYMTAB) .PHONY: all build clean install populate $(foreach DIR, $(SUBDIRS), $(eval $(call DIR_template,$(DIR),build, all))) @@ -83,25 +84,20 @@ $(ROMFS_IMG): populate $(ROMFS_HDR) : $(ROMFS_IMG) @xxd -i $^ >$@ +# Create the dirlist.h header file from the romfs directory + $(ROMFS_DIRLIST) : populate - @echo "#ifndef __EXAMPLES_NXFLAT_TESTS_DIRLIST_H" >$(ROMFS_DIRLIST) - @echo "#define __EXAMPLES_NXFLAT_TESTS_DIRLIST_H" >>$(ROMFS_DIRLIST) - @echo "" >>$(ROMFS_DIRLIST) - @echo "static const char *dirlist[] =" >>$(ROMFS_DIRLIST) - @echo "{" >>$(ROMFS_DIRLIST) - @(\ - for file in `ls $(ROMFS_DIR)`; do \ - echo " \"$$file\"," >>$(ROMFS_DIRLIST); \ - done; \ - ) - @echo "};" >>$(ROMFS_DIRLIST) - @echo "" >>$(ROMFS_DIRLIST) - @echo "#endif /* __EXAMPLES_NXFLAT_TESTS_DIRLIST_H */" >>$(ROMFS_DIRLIST) + @$(TESTS_DIR)/mkdirlist.sh $(ROMFS_DIR) >$@ + +# Create the exported symbol table list from the derived *-thunk.S files + +$(SYMTAB): build + @$(TESTS_DIR)/mksymtab.sh $(TESTS_DIR) >$@ # Clean each subdirectory clean: $(foreach DIR, $(SUBDIRS), $(DIR)_clean) - @rm -f $(ROMFS_HDR) $(ROMFS_IMG) + @rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB) @rm -rf $(ROMFS_DIR) diff --git a/nuttx/examples/nxflat/tests/mkdirlist.sh b/nuttx/examples/nxflat/tests/mkdirlist.sh new file mode 100755 index 000000000..cc55ac0b5 --- /dev/null +++ b/nuttx/examples/nxflat/tests/mkdirlist.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +usage="Usage: %0 <romfs-dir-path>" + +dir=$1 +if [ -z "$dir" ]; then + echo "ERROR: Missing <romfs-dir-path>" + echo "" + echo $usage + exit 1 +fi + +if [ ! -d "$dir" ]; then + echo "ERROR: Directory $dir does not exist" + echo "" + echo $usage + exit 1 +fi + +echo "#ifndef __EXAMPLES_NXFLAT_TESTS_DIRLIST_H" +echo "#define __EXAMPLES_NXFLAT_TESTS_DIRLIST_H" +echo "" +echo "static const char *dirlist[] =" +echo "{" + +for file in `ls $dir`; do + echo " \"$file\"," +done + +echo " NULL" +echo "};" +echo "" +echo "#endif /* __EXAMPLES_NXFLAT_TESTS_DIRLIST_H */" + + diff --git a/nuttx/examples/nxflat/tests/mksymtab.sh b/nuttx/examples/nxflat/tests/mksymtab.sh new file mode 100755 index 000000000..a5161ae73 --- /dev/null +++ b/nuttx/examples/nxflat/tests/mksymtab.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +usage="Usage: %0 <test-dir-path>" + +dir=$1 +if [ -z "$dir" ]; then + echo "ERROR: Missing <test-dir-path>" + echo "" + echo $usage + exit 1 +fi + +if [ ! -d "$dir" ]; then + echo "ERROR: Directory $dir does not exist" + echo "" + echo $usage + exit 1 +fi + +varlist=`find $dir -name "*-thunk.S"| xargs grep -h asciz | cut -f3 | sort | uniq` + +echo "#ifndef __EXAMPLES_NXFLAT_TESTS_SYMTAB_H" +echo "#define __EXAMPLES_NXFLAT_TESTS_SYMTAB_H" +echo "" +echo "#include <nuttx/symtab.h>" +echo "" +echo "static const struct symtab_s exports[] = " +echo "{" +for string in $varlist; do + var=`echo $string | sed -e "s/\"//g"` + echo " {$string, $var}," +done + +echo "};" +echo "#define NEXPORTS (sizeof(exports)/sizeof(struct symtab_s))" +echo "" +echo "#endif /* __EXAMPLES_NXFLAT_TESTS_SYMTAB_H */" + |