]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
forb: Add tests for forbrun command line parameters
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 18 Feb 2011 21:40:50 +0000 (22:40 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 18 Feb 2011 22:32:59 +0000 (23:32 +0100)
src/forbrun/tests/Makefile.omk
src/forbrun/tests/forbrun.sh
src/forbrun/tests/forbrun_printargs.c [new file with mode: 0644]

index 2eaa706e492a0e7025a9100b09d2440ed882c06e..220ab1ceee259c501356496107a528f5a26bde55 100644 (file)
@@ -8,6 +8,10 @@ shared_LIBRARIES += test_client
 test_client_SOURCES = test_client.c
 test_client_CLIENT_IDL = test_obj.idl
 
+shared_LIBRARIES += forbrun_printargs
+forbrun_printargs_SOURCES = forbrun_printargs.c
+
+
 INCLUDES += -I.
 
 lib_LOADLIBES = forb ulut fosa rt wvtest
index 7c5fde1e573a06b12e21c40678e238e6ec5a97ce..0faad99bfcdcd2f6fb5f566de258918caf01c94b 100755 (executable)
@@ -5,7 +5,18 @@
 WVSTART "Without any parameters do nothing"
 WVPASS forbrun
 
-WVSTART "argv[0] in forb_main() contains the name of the library"
+WVSTART "Passing of command line parameters to forb_main() in libraries"
+WVPASS sh -c 'forbrun -- libforbrun_printargs.so \
+                             -- libforbrun_printargs.so 1 2 3 4 \
+                     -- libforbrun_printargs.so --exit > output'
+cat <<EOF > expected
+libforbrun_printargs.so
+libforbrun_printargs.so 1 2 3 4
+libforbrun_printargs.so --exit
+EOF
+WVPASS diff -u expected output
+
+WVSTART "Non-zero return value in forb_main() causes forbrun to fail "
 WVFAIL sh -c 'forbrun -- libtest_obj.so 2> error'
 WVPASSEQ "$(cat error)" "Usage: libtest_obj.so <string>"
 
diff --git a/src/forbrun/tests/forbrun_printargs.c b/src/forbrun/tests/forbrun_printargs.c
new file mode 100644 (file)
index 0000000..86aa4eb
--- /dev/null
@@ -0,0 +1,17 @@
+#include <forb.h>
+#include <stdio.h>
+
+int forb_main(forb_orb orb, int argc, char *argv[])
+{
+       int i;
+       for (i=0; i<argc; i++)
+               printf("%s%s", argv[i], i+1 < argc ? " " : "");
+       printf("\n");
+       if (argc < 2 || strcmp(argv[1], "--exit") != 0) {
+               /* Allow starting the next shared library */
+               forb_signal_server_ready(orb);
+               /* Exit only this thread, not the whole forbrun */
+               pthread_exit(0);
+       }
+       return 0;
+}