]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/commitdiff
rtems: Use Makefile.rules which pass OMK test suite
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 12 Mar 2011 16:15:21 +0000 (17:15 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 12 Mar 2011 16:15:21 +0000 (17:15 +0100)
build/rtems/Makefile.rules
src/fwp/fwp/lib/fwp/tests/fwp_vrestest/fwp_vrestest1.c

index 6ea26c787b3e3c32d45a1cb5760eaa1ec788251a..8e1689a2427a388dd5f3128ef1a46cd37c657521 100644 (file)
@@ -4,7 +4,7 @@
 #  (C) Copyright 2006, 2007, 2008, 2009, 2010, 2011 by Michal Sojka - Czech Technical University, FEE, DCE
 #
 #  Homepage: http://rtime.felk.cvut.cz/omk/
-#  Version:  0.2-71-g101fc03
+#  Version:  0.2-89-g95151fe
 #
 # The OMK build system is distributed under the GNU General Public
 # License.  See file COPYING for details.
@@ -83,16 +83,11 @@ all:
        @$(MAKE) -C $(MAKERULES_DIR) OMK_SERIALIZE_INCLUDED=n SOURCES_DIR=$(MAKERULES_DIR) RELATIVE_DIR="" $(MAKECMDGOALS) W=0
 endif
 
-ifdef OMK_TESTSROOT
-# Usage: $(call canttest,<error message>)
-define canttest
-       ( echo "$(1)" > $(OUTPUT_DIR)/_canttest; echo "$(1)"; exit 1 )
-endef
-else
-define canttest
-       echo "$(1)"
-endef
-endif
+# omk-get-var target allows external scripts/programs to determine the
+# values of OMK variables such as RELATIVE_DIR etc.
+.PHONY: omk-get-var
+omk-get-var:
+       @$(foreach var,$(VAR),echo $(var)=$($(var));)
 
 #=========================
 # Include the config file
@@ -513,15 +508,22 @@ $(2): $(1)
        $(Q)if [ -n `dirname $$@` ] ; then \
              if [ ! -e `dirname $$@` ] ; then \
                mkdir -p `dirname $$@` ; fi ; fi
-       $(Q)echo >$$@ '/* Automatically generated from $$< */'
-       $(Q)echo >>$$@ '/* Conditionals to control compilation */'
-       $(Q)set -o pipefail ; $(NM) $$< \
+       $(Q)echo >$$@.tmp '/* Automatically generated from $$< */'
+       $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */'
+# Bellow, the tricks with redirection are for shells without set -o pipefail
+# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html)
+       $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
                | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
-               | sort >>$$@
-       $(Q)echo >>$$@ '/* Defines from the values defined to symbols */'
-       $(Q)set -o pipefail ; $(NM) $$< \
+               | sort >>$$@.tmp` && exit $$$$status
+       $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */'
+       $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
                | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
-               | sort >>$$@
+               | sort >>$$@.tmp` && exit $$$$status
+       $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */'
+       $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\
+               | sed -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \
+               | sort >>$$@.tmp` && exit $$$$status
+       $(Q)mv $$@.tmp $$@
 endef
 
 idl_COMPILE = $(IDL_COMPILER)
@@ -532,7 +534,7 @@ $(2).c $(2)-stubs.c $(2)-skels.c $(2)-common.c $(2).h: $(1) $$(wildcard $$(first
        $(Q) $$(idl_COMPILE) $$($(2)_IDLFLAGS) $(1)
 endef
 
-# Syntax: $(call PROGRAM_template,<dir>,<executable-name>,<link-variant>)
+# Syntax: $(call PROGRAM_template,<executable-name>,<dir>,<link-variant>)
 define PROGRAM_template
 USER_IDLS  += $$($(1)_SERVER_IDL) $$($(1)_CLIENT_IDL) $$($(1)_IDL)
 $(1)_GEN_SOURCES += $$(filter %.c,$$($(1)_SERVER_IDL:%.idl=%-skels.c))
@@ -554,7 +556,6 @@ USER_SOURCES += $$($(1)_SOURCES)
 USER_EMBEDTARFILES += $$($(1)_EMBEDTARFILES)
 
 $(2)/$(1): $(USER_LIB_DIR)/timestamp
-
 $(2)/$(1): $$($(1)_OBJS)
        @$(QUIET_CMD_ECHO) "  LINK    $$@"
        $(Q) $$(shell if [ -z "$$(filter %.cc,$$($(1)_SOURCES))" ] ; \
@@ -598,7 +599,8 @@ $(USER_LIB_DIR)/lib$(1).a: $$($(1)_OBJS)
        @touch $(USER_LIB_DIR)/timestamp
 endef
 
-
+$(USER_LIB_DIR)/timestamp:
+       $(Q)touch $@
 
 # Syntax: $(call SOLIB_template,<library-name>)
 define SOLIB_template
@@ -631,7 +633,7 @@ endef
 library-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(cmetric_include_HEADERS)) \
                    $(lib_LIBRARIES:%=$(USER_LIB_DIR)/lib%.a) $(shared_LIBRARIES:%=$(USER_LIB_DIR)/lib%.so)
 
-binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%) $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/% $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%)
+binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%) $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%) $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%)
 
 # Special rules for CMETRIC generated headers
 
index fc0faab2fcd62af389077111e747fb1bfade2099..ee47040715520352ef68870bcd6a252480ecd8f9 100644 (file)
 #include <stdio.h>
 #include <arpa/inet.h>
 #include <time.h>
+#define WVTEST_CONFIGURED
+#include <wvtest.h>
+#include <stdlib.h>
 
-#define  NUM  10000
+#define  NUM  2
 
-int main()
+WVTEST_MAIN("FWP VRES synchronous communication")
 {
 //     struct sockaddr_in local_addr, rem_addr, from;
         ssize_t len;
@@ -42,58 +45,59 @@ int main()
        vparam1.period.tv_sec = 2; 
        vparam1.period.tv_nsec = 111111; 
 
-       printf("Start\n");
-       if (fwp_init() != 0) {
+       if (WVFAIL(fwp_init() != 0)) {
                printf("fwp_init failed!\n");
-               return -1;
+               exit(1);
        }       
        
-       printf("Create vres1\n");
-       if ((fwp_vres_create(&vparam1, &vres1) < 0)) {
+       if (WVFAIL(fwp_vres_create(&vparam1, &vres1) < 0)) {
                printf("Unable to create vres1\n");
-               return -1;
+               exit(1);
        }
-       printf("Vres1 created\n");
-       
-       printf("Create vres2\n");
-       if ((fwp_vres_create(&vparam1, &vres2) < 0)) {
+
+       if (WVFAIL(fwp_vres_create(&vparam1, &vres2) < 0)) {
                printf("Unable to create vres2\n");
-               return -1;
+               exit(1);
        }
-       printf("Vres2 created\n");
+
        /* local_addr should be handled when creating socket */
-       if (fwp_receive_endpoint_create(7777, &attr, &repoint) < 0) {
-               return -1;
+       if (WVFAIL(fwp_receive_endpoint_create(7777, &attr, &repoint) < 0)) {
+               exit(1);
        }
-       printf("Receive endpoint created\n");
        
-       if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, &attr, 
-                                    &sepoint) < 0){
-               return -1;
+       if (WVFAIL(fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, &attr, 
+                                           &sepoint) < 0)) {
+               exit(1);
        }
-       printf("Send endpoint 1 created\n");
-       fwp_send_endpoint_bind(sepoint, vres1);
+
+       WVPASS(fwp_send_endpoint_bind(sepoint, vres1) == 0);
        
        for (count = 0; count < NUM; count++) { 
                sprintf(msg1,"msg%d",count);
-               fwp_send_sync(sepoint, msg1, sizeof(msg1));
+               WVPASSEQ(fwp_send_sync(sepoint, msg1, sizeof(msg1)), sizeof(msg1));
                
                clock_gettime(CLOCK_MONOTONIC, &sendtime);
                printf("Sent: sec = %ld nsec = %ld \n", sendtime.tv_sec,
                       sendtime.tv_nsec);
                
-               if ((len = fwp_recv(repoint, buffer, sizeof(buffer), &from, 0)) < 0) {
+               if (WVFAIL((len = fwp_recv(repoint, buffer, sizeof(buffer), &from, 0)) < 0)) {
                        perror("Error while receiving data");
-                       return -1;
+                       exit(1);
                } 
-                       else printf("Received - %s\n", buffer);
+               else printf("Received - %s\n", buffer);
+               WVPASSEQSTR(msg1, buffer);
        }
 
-       if (fwp_vres_destroy(vres1) < 0) {
+       if (WVFAIL(fwp_vres_destroy(vres1) < 0)) {
+               perror("Unable to destroy vres1\n");
+               exit(1);
+       }
+       if (WVFAIL(fwp_vres_destroy(vres2) < 0)) {
                perror("Unable to destroy vres1\n");
-               return -1;
+               exit(1);
        }
+       WVPASSEQ(fwp_endpoint_destroy(sepoint), 0);
+       WVPASSEQ(fwp_endpoint_destroy(repoint), 0);
        printf("Vres1 detroyed\n");
        printf("Test PASSED!\n");
-       return 0;
 }