+SUBDIRS = tests
+
bin_PROGRAMS = forbrun
forbrun_SOURCES = forbrun.c
-shared_LIBRARIES = forb_shlib_test
-forb_shlib_test_SOURCES = forb_shlib.c
-forb_shlib_test_SERVER_IDL = test_obj.idl
+wvtest_SCRIPTS = forbrun.sh
+
+shared_LIBRARIES = test_obj
+test_obj_SOURCES = test_obj.c
+test_obj_SERVER_IDL = test_obj.idl
+
+shared_LIBRARIES += test_client
+test_client_SOURCES = test_client.c
+test_client_CLIENT_IDL = test_obj.idl
INCLUDES += -I.
+++ /dev/null
-#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;
-}
--- /dev/null
+#!/bin/bash
+
+. $(dirname $0)/wvtest.sh
+
+WVSTART "Without any parameters do nothing"
+WVPASS forbrun
+
+WVSTART "argv[0] in forb_main() contains the name of the library"
+WVFAIL sh -c 'forbrun libtest_obj.so 2> error'
+WVPASSEQ "$(cat error)" "Usage: libtest_obj.so <string>"
+
+WVSTART "Both server and client in a single process"
+WVPASS sh -c 'forbrun libtest_obj.so "Hello" -- libtest_client.so > output'
+WVPASSEQ "$(cat output)" "Hello"
+
+WVSTART "Server and client in separate processes"
+# Run server on background
+rm -f test.pid
+WVPASS sh -c 'forbrun --daemon=test.pid libtest_obj.so "Hello" > output'
+WVPASS test -f test.pid
+
+# Run client
+WVPASS forbrun libtest_client.so
+WVPASS kill $(cat test.pif)
+
+# Test whether the server was called
+WVPASSEQ "$(cat output)" "Hello"
+
--- /dev/null
+#include <forb.h>
+#include "test_obj.h"
+#include <stdio.h>
+
+int forb_main(forb_orb orb, int argc, char *argv[])
+{
+ CORBA_Environment ev;
+ test_obj obj = forb_resolve_reference(orb, "mytestobj");
+ test_obj_printmsg(obj, &ev);
+ return 0;
+}
--- /dev/null
+#include <forb.h>
+#include "test_obj.h"
+#include <forb/executor.h>
+#include <forb/object.h>
+#include <forb/iop.h>
+#include <stdio.h>
+
+static CORBA_long printmsg(test_obj obj, CORBA_Environment *ev)
+{
+ char *msg = forb_object_instance_data(obj);
+ return printf("%s\n", msg);
+}
+
+static const struct forb_test_obj_impl test_obj_impl = {
+ .printmsg = printmsg,
+};
+
+
+int forb_main(forb_orb orb, int argc, char *argv[])
+{
+ test_obj testobj;
+ int ret;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s <string>\n", argv[0]);
+ return 1;
+ }
+
+ testobj = forb_test_obj_new(orb, &test_obj_impl, argv[1]);
+ if (!testobj)
+ return 1;
+
+ ret = forb_register_reference(testobj, "mytestobj");
+ if (ret) {
+ fprintf(stderr, "%s: forb_register_reference(\"mytestobj\") failed\n",
+ argv[0]);
+ return 1;
+ }
+
+ forb_execute_object(testobj);
+ return 0;
+}
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);
+ // Print message specified during object initialization
+ long printmsg();
};
--- /dev/null
+../../../../wvtest/sh/wvtest.sh
\ No newline at end of file