# (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.
@$(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
$(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)
$(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))
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))" ] ; \
@touch $(USER_LIB_DIR)/timestamp
endef
-
+$(USER_LIB_DIR)/timestamp:
+ $(Q)touch $@
# Syntax: $(call SOLIB_template,<library-name>)
define SOLIB_template
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
#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;
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;
}