]> rtime.felk.cvut.cz Git - frescor/forb.git/commitdiff
forb: Added shared library for testing of forbrun-based server execution
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 15 Feb 2011 13:40:05 +0000 (14:40 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 15 Feb 2011 16:17:15 +0000 (17:17 +0100)
src/tests/sharead_lib/Makefile [new file with mode: 0644]
src/tests/sharead_lib/Makefile.omk [new file with mode: 0644]
src/tests/sharead_lib/forb_shlib.c [new file with mode: 0644]
src/tests/sharead_lib/test_obj.idl [new file with mode: 0644]

diff --git a/src/tests/sharead_lib/Makefile b/src/tests/sharead_lib/Makefile
new file mode 100644 (file)
index 0000000..d538d21
--- /dev/null
@@ -0,0 +1,14 @@
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ;  while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd`  ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+       @echo -e "\nThe Makefile.rules has not been found in this or partent directory: `pwd`\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
diff --git a/src/tests/sharead_lib/Makefile.omk b/src/tests/sharead_lib/Makefile.omk
new file mode 100644 (file)
index 0000000..908480f
--- /dev/null
@@ -0,0 +1,7 @@
+shared_LIBRARIES = forb_shlib_test
+forb_shlib_test_SOURCES = forb_shlib.c
+forb_shlib_test_SERVER_IDL = test_obj.idl
+
+INCLUDES += -I.
+
+lib_LOADLIBES = forb ulut fosa rt wvtest
diff --git a/src/tests/sharead_lib/forb_shlib.c b/src/tests/sharead_lib/forb_shlib.c
new file mode 100644 (file)
index 0000000..7ecb0dc
--- /dev/null
@@ -0,0 +1,42 @@
+#include <forb.h>
+#include "test_obj.h"
+#define WVTEST_CONFIGURED
+#include <wvtest.h>
+#include <forb/executor.h>
+#include <forb/object.h>
+#include <forb/iop.h>
+
+static CORBA_long add(test_obj obj, CORBA_long val, CORBA_Environment *ev)
+{
+       int to_add = (intptr_t)forb_object_instance_data(obj);
+       return val + to_add;
+}
+
+static CORBA_long add_indirect(test_obj obj, test_obj indirect_obj, CORBA_long val, CORBA_Environment *ev)
+{
+       return test_obj_add(indirect_obj, val, ev);
+}
+
+static const struct forb_test_obj_impl test_obj_impl = {
+       .add = add,
+       .add_indirect = add_indirect,
+};
+
+
+void *executor_thread(void *arg)
+{
+       forb_executor_t *executor = arg;
+       forb_executor_run(executor);
+       return NULL;
+}
+
+int forb_main(forb_orb orb, int argc, char *argv[])
+{
+       test_obj testobj;
+
+       testobj = forb_test_obj_new(orb, &test_obj_impl, (void*)1);
+       if (!testobj)
+               return -1;
+       forb_execute_object(testobj);
+       return 0;
+}
diff --git a/src/tests/sharead_lib/test_obj.idl b/src/tests/sharead_lib/test_obj.idl
new file mode 100644 (file)
index 0000000..0edea5d
--- /dev/null
@@ -0,0 +1,6 @@
+interface test_obj {
+       // Adds some number the value @a val
+       long add(in long val);
+       // Adds some number the value @a val by calling @a add method of indirect_obj
+       long add_indirect(in test_obj indirect_obj, in long val);
+};