diff options
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/Banded_Connections.dsw | 41 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/Makefile | 66 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/Makefile.bor | 7 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/README | 130 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/client.bor | 34 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/client.cpp | 363 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/client.dsp | 204 | ||||
-rwxr-xr-x | TAO/tests/RTCORBA/Banded_Connections/run_test.pl | 76 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/server.bor | 35 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/server.conf | 9 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/server.cpp | 557 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/server.dsp | 216 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Banded_Connections/test.idl | 16 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Makefile | 3 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/Makefile.bor | 1 | ||||
-rw-r--r-- | TAO/tests/RTCORBA/RTCORBA_tests.dsw | 24 |
16 files changed, 1781 insertions, 1 deletions
diff --git a/TAO/tests/RTCORBA/Banded_Connections/Banded_Connections.dsw b/TAO/tests/RTCORBA/Banded_Connections/Banded_Connections.dsw new file mode 100644 index 00000000000..d17cf7c9604 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/Banded_Connections.dsw @@ -0,0 +1,41 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "client"=.\client.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "server"=.\server.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/TAO/tests/RTCORBA/Banded_Connections/Makefile b/TAO/tests/RTCORBA/Banded_Connections/Makefile new file mode 100644 index 00000000000..a14c9effa80 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/Makefile @@ -0,0 +1,66 @@ +#---------------------------------------------------------------------------- +# +# $Id$ +# +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif # ! TAO_ROOT + +LDLIBS = -lTAO_Strategies -lTAO + +IDL_FILES = test +IDL_SRC = testC.cpp testS.cpp +BIN_UNCHECKED = server client + +SRC = $(addsuffix .cpp, $(BIN)) $(IDL_SRC) + +CLIENT_OBJS = client.o testC.o +SERVER_OBJS = server.o $(IDL_SRC:.cpp=.o) + +BUILD = $(BIN) +VBIN = $(BIN:%=%$(VAR)) +TAO_IDLFLAGS += -Ge 1 + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(TAO_ROOT)/rules.tao.GNU + +ifeq ($(rt_corba),1) +BIN=$(BIN_UNCHECKED) +endif # rt_corba + +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +.PRECIOUS: $(foreach ext, $(IDL_EXT), test$(ext)) + +server: $(addprefix $(VDIR),$(SERVER_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(TAO_SRVR_LIBS) $(POSTLINK) + +client: $(addprefix $(VDIR),$(CLIENT_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(TAO_CLNT_LIBS) $(POSTLINK) + +realclean: clean + -$(RM) $(foreach ext, $(IDL_EXT), test$(ext)) + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/TAO/tests/RTCORBA/Banded_Connections/Makefile.bor b/TAO/tests/RTCORBA/Banded_Connections/Makefile.bor new file mode 100644 index 00000000000..adecf33c643 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/Makefile.bor @@ -0,0 +1,7 @@ +# +# Makefile for building the Server_Protocol test executables +# + +MAKEFILES = server.bor client.bor + +!include <$(ACE_ROOT)\include\makeinclude\recurse.bor> diff --git a/TAO/tests/RTCORBA/Banded_Connections/README b/TAO/tests/RTCORBA/Banded_Connections/README new file mode 100644 index 00000000000..fc367260a41 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/README @@ -0,0 +1,130 @@ +$Id$ + +This is a unit test for RTCORBA::SERVER_DECLARED priority model. + +Scenario: +--------- + +The server creates a POA with RTCORBA::SERVER_DECLARED priority model +policy. Two objects are created using this POA, one inherits the POA +priority and the second one overrides POA priority with its own. +Server threadpool resources are configured appropriately. (Once POA +threadpools are completely supported, this means associating a +two-lane threadpool with the POA, one lane corresponding to POA +priority, and another to object priority. However, currently, while +RTCORBA POA threadpools are not in place yet, this means emulating POA +threadpool with TAO's Reactor-per-priority scheme, i.e., ORB-level +pool with lane for each endpoint priority.) Finally, the server +attempts to create a third object, using invalid/not matching the +resources priority, i.e., priority not matching any of the pool +lanes. This attempt should fail, and the server expects to receive +the appropriate exception. + +The client obtains two object references and invokes a method on each +several times. On each invocation, the client passes object's server +declared priority as operation argument. This allows the servant to +check that appropriate resources are being used for servicing client +requests. In particular, servant checks that priority of the thread +used for servicing the request equals to the server declared priority +of the object, known from the operation argument. + + +To run (on Unix): +------- +$./server [-p <ior_output_file1> -o <ior_output_file2> -c <wrong_priority>] + -a <poa_priority> -b <object_priority> + -ORBsvcconf server.conf + -ORBendpoint xxxx://targethost:0/priority=<poa_priority> + -ORBendpoint xxxx://targethost:0/priority=<object_priority> + [more endpoints if desired] + +$./client [-p <ior1> -o <ior2>] + + +Options: +-------- + Server: + +-p <ior_output_file1> Default: test1.ior + Filename for output of the first object's IOR + (i.e., object that does not override POA + priority). + +-o <ior_output_file2> Default: test2.ior + Filename for output of the second object's IOR + (i.e., object that overrides POA priority). + +-a <poa_priority> Default: -1, must be overridden + SERVER_DECLARED priority of the poa. + +-b <object_priority> Default: -1, must be overridden + SERVER_DECLARED priority of the second object. + +-c <wrong_priority> Default: -1 + Invalid/not matching the configuration + priority value, used in an attempt to activate + a third object. The test checks that such + attempt fails and an appropriate exception is + thrown. + +The following are the required server ORB options for this test. +These options help set up server resources to emulate a two-lane POA +threadpool, one lane with <poa_priority>, and one lane +with <object_priority>. Once POA threadpools are implemented, these +options will go away. +-ORBSvcConf server.conf +-ORBendpoint xxxx://targethost:0/priority=<poa_priority> +-ORBendpoint xxxx://targethost:0/priority=<object_priority> + + Client: + +-p <ior1> Default: file://test1.ior + IOR for the first object (with POA's + priority). + +-o <ior2> Default: file://test2.ior + IOR for the second object. + + +Expected output: +---------------- +Below is the expected output from run_test.pl on a Windows +platform. See run_test.pl for command-line options used for client and +server. NOTE: expected output differs on unix. + +In general, the output must contain "BAD_PARAM exception is caught as +expected.", and server declared priorities must equal corresponding +servant thread priorities. + + +********** RTCORBA SERVER_DECLARED Priority Unit Test + + +Activated object one as <IOR:010000000d00000049444c3a546573743a312e3000000000010 +0000000000000b2000000010102cd0a0000006c6f63616c686f7374004b052300000014010f004e5 +354790af039d4650c000100000001000000000000000100000001000000cd0400000000000000080 +0000001cdcdcd004f4154010000001400000001cdcdcd01000100000000000901010000000000024 +f41541a00000001cdcdcd010000000a0000006c6f63616c686f7374004b050300cdcd020000001a0 +0000001cdcdcd01000000020041540a00000001cdcdcd010000000300> + + +Activated object two as <IOR:010000000d00000049444c3a546573743a312e3000000000010 +0000000000000b2000000010102cd0a0000006c6f63616c686f7374004e052300000014010f004e5 +354790af039d4650c000100000001000000010000000100000002000000cd0400000000000000080 +0000001cdcdcd004f4154010000001400000001cdcdcd01000100000000000901010000000000024 +f41541a00000001cdcdcd010000000a0000006c6f63616c686f7374004e050500cdcd020000001a0 +0000001cdcdcd01000000020041540a00000001cdcdcd010000000500> + +BAD_PARAM exception is caught as expected. +Server_Declared priority: 3 Servant thread priority: 3 +Server_Declared priority: 5 Servant thread priority: 5 +Server_Declared priority: 3 Servant thread priority: 3 +Server_Declared priority: 5 Servant thread priority: 5 +Server_Declared priority: 3 Servant thread priority: 3 +Server_Declared priority: 5 Servant thread priority: 5 +Server_Declared priority: 3 Servant thread priority: 3 +Server_Declared priority: 5 Servant thread priority: 5 +Server_Declared priority: 3 Servant thread priority: 3 +Server_Declared priority: 5 Servant thread priority: 5 +Server ORB event loop finished + diff --git a/TAO/tests/RTCORBA/Banded_Connections/client.bor b/TAO/tests/RTCORBA/Banded_Connections/client.bor new file mode 100644 index 00000000000..d00bc36eac5 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/client.bor @@ -0,0 +1,34 @@ +# +# Makefile for building the Server_Protocol client +# + +NAME = client + +TAO_IDL = $(CORE_BINDIR)\tao_idl -g $(CORE_BINDIR)\gperf.exe -Ge 1 + +OBJFILES = \ + $(OBJDIR)\testC.obj \ + $(OBJDIR)\client.obj + +CFLAGS = \ + $(ACE_CFLAGS) \ + $(TAO_CFLAGS) \ + $(TAO_PORTABLESERVER_CFLAGS) + +LIBFILES = \ + $(ACE_LIB) \ + $(TAO_LIB) \ + $(TAO_PORTABLESERVER_LIB) + +CPPDIR = . + +IDLDIR = . + +!include <$(ACE_ROOT)\include\makeinclude\build_exe.bor> + +# +# IDL Build rules +# + +$(IDLDIR)\testS.cpp $(IDLDIR)\testC.cpp: $(IDLDIR)\test.idl + $(TAO_IDL) $** diff --git a/TAO/tests/RTCORBA/Banded_Connections/client.cpp b/TAO/tests/RTCORBA/Banded_Connections/client.cpp new file mode 100644 index 00000000000..9c33cc38d59 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/client.cpp @@ -0,0 +1,363 @@ +// $Id$ + +#include "testC.h" +#include "ace/Get_Opt.h" +#include "ace/Sched_Params.h" + +#if (TAO_HAS_RT_CORBA == 1) + +const char *ior1 = "file://test1.ior"; +const char *ior2 = "file://test2.ior"; +CORBA::Short client_priority1 = -1; +CORBA::Short client_priority2 = -1; +CORBA::Short client_priority3 = -1; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "n:o:a:b:c:"); + int c, result; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'n': + ior1 = get_opts.optarg; + break; + case 'o': + ior2 = get_opts.optarg; + break; + case 'a': + result = ::sscanf (get_opts.optarg, + "%hd", + &client_priority1); + if (result == 0 || result == EOF) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to process <-a> option"), + -1); + break; + + case 'b': + result = ::sscanf (get_opts.optarg, + "%hd", + &client_priority2); + if (result == 0 || result == EOF) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to process <-b> option"), + -1); + break; + + case 'c': + result = ::sscanf (get_opts.optarg, + "%hd", + &client_priority3); + if (result == 0 || result == EOF) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to process <-c> option"), + -1); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-n <ior> " + "-o <ior> " + "-a <client_priority1>" + "-b <client_priority2>" + "-c <client_priority3>" + "\n", + argv [0]), + -1); + } + + if (client_priority1 < 0 + || client_priority2 < 0 + || client_priority3 < 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Valid client priorities must be" + " specified.\nSee README file for more info\n"), + -1); + + return 0; +} + +int +check_for_nil (CORBA::Object_ptr obj, const char *msg) +{ + if (CORBA::is_nil (obj)) + ACE_ERROR_RETURN ((LM_ERROR, + "ERROR: Object reference <%s> is nil\n", + msg), + -1); + else + return 0; +} + +CORBA::Short +get_server_priority (Test_ptr server, + CORBA::Environment &ACE_TRY_ENV) +{ + CORBA::Policy_var policy = + server->_get_policy (RTCORBA::PRIORITY_MODEL_POLICY_TYPE, + ACE_TRY_ENV); + ACE_CHECK_RETURN (-1); + + RTCORBA::PriorityModelPolicy_var priority_policy = + RTCORBA::PriorityModelPolicy::_narrow (policy.in (), ACE_TRY_ENV); + ACE_CHECK_RETURN (-1); + + if (check_for_nil (priority_policy.in (), "PriorityModelPolicy") == -1) + return -1; + + RTCORBA::PriorityModel priority_model = + priority_policy->priority_model (ACE_TRY_ENV); + ACE_CHECK_RETURN (-1); + if (priority_model != RTCORBA::SERVER_DECLARED) + ACE_ERROR_RETURN ((LM_ERROR, + "ERROR: priority_model != " + "RTCORBA::SERVER_DECLARED!\n"), + -1); + + return priority_policy->server_priority (ACE_TRY_ENV); +} + +void +invocation_exception_test (Test_ptr obj, + CORBA::Short priority, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + obj->test_method (priority, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Test failed: no exception caught\n")); + } + ACE_CATCH (CORBA::INV_POLICY, ex) + { + ACE_DEBUG ((LM_DEBUG, + "INV_POLICY exception is caught as expected.\n")); + } + ACE_CATCHANY + { + ACE_DEBUG ((LM_DEBUG, "Test failed: unexpected exception caught\n")); + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; +} + +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + // First check that we have sufficient priority range to run the + // test, i.e., more than 1 priority level. + int max_priority = + ACE_Sched_Params::priority_max (ACE_SCHED_OTHER); + int min_priority = + ACE_Sched_Params::priority_min (ACE_SCHED_OTHER); + + if (max_priority == min_priority) + { + ACE_DEBUG ((LM_DEBUG, + "Not enough priority levels on this platform" + "to run the test, aborting\n")); + return 0; + } + + // Initialize the ORB, resolve references and parse arguments. + + // ORB. + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Parse arguments. + if (parse_args (argc, argv) != 0) + return 1; + + // RTORB. + CORBA::Object_var object = + orb->resolve_initial_references ("RTORB", ACE_TRY_ENV); + ACE_TRY_CHECK; + RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + if (check_for_nil (rt_orb.in (), "RTORB") == -1) + return 1; + + // RTCurrent. + object = + orb->resolve_initial_references ("RTCurrent", ACE_TRY_ENV); + ACE_TRY_CHECK; + RTCORBA::Current_var current = + RTCORBA::Current::_narrow (object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Test object 1 (with CLIENT_PROPAGATED priority model). + object = + orb->string_to_object (ior1, ACE_TRY_ENV); + ACE_TRY_CHECK; + + Test_var client_propagated_obj = + Test::_narrow (object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + if (check_for_nil (client_propagated_obj.in (), + "client_propagated_obj") + == -1) + return 1; + + // Test object 2 (with SERVER_DECLARED priority model). + object = orb->string_to_object (ior2, ACE_TRY_ENV); + ACE_TRY_CHECK; + + Test_var server_declared_obj = + Test::_narrow (object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + if (check_for_nil (server_declared_obj.in (), + "server_declared_obj") + == -1) + return 1; + + // Set client thread's priority. + current->the_priority (client_priority1, ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Test 4: Attempt to set priority bands that do not match + // server resource configuration on the <client_propagated_obj>. + // Should get INV_POLICY exception. + ACE_DEBUG ((LM_DEBUG, + "\n Test 4\n")); + + RTCORBA::PriorityBands false_bands; + false_bands.length (2); + false_bands[0].low = 10000; + false_bands[0].high = 10005; + false_bands[1].low = 26; + false_bands[1].high = 30; + CORBA::PolicyList policies; + policies.length (1); + policies[0] = + rt_orb->create_priority_banded_connection_policy + (false_bands, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + object = + client_propagated_obj->_set_policy_overrides (policies, + CORBA::SET_OVERRIDE, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + client_propagated_obj = + Test::_narrow (object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + if (check_for_nil (client_propagated_obj.in (), + "client_propagated_obj") + == -1) + return 1; + + invocation_exception_test (client_propagated_obj.in (), + client_priority1, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Now set the priority bands that match server resource + // configuration on the <client_propagated_obj>. + CORBA::Policy_var policy = + server_declared_obj->_get_policy (RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + policies[0] = policy; + + object = + client_propagated_obj->_set_policy_overrides (policies, + CORBA::SET_OVERRIDE, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + client_propagated_obj = + Test::_narrow (object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + if (check_for_nil (client_propagated_obj.in (), + "client_propagated_obj") + == -1) + return 1; + + // Test 5: Make invocations on the <client_propagated_obj>, + // changing the priority of the invoking thread. + ACE_DEBUG ((LM_DEBUG, + "\n Test 5\n")); + + client_propagated_obj->test_method (client_priority1, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + current->the_priority (client_priority2, ACE_TRY_ENV); + ACE_TRY_CHECK; + + client_propagated_obj->test_method (client_priority2, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Test 6: Attempt invocation on <client_propagated_obj> with + // client thread priority not matching any of the bands. Should + // get INV_POLICY exception. + ACE_DEBUG ((LM_DEBUG, + "\n Test 6\n")); + + current->the_priority (client_priority3, ACE_TRY_ENV); + ACE_TRY_CHECK; + + invocation_exception_test (client_propagated_obj.in (), + client_priority1, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Test 7: Attempt invocation with the same thread priority, but + // now on the <server_declared_obj>. This should succeed. + ACE_DEBUG ((LM_DEBUG, + "\n Test 7\n")); + + CORBA::Short server_priority = + get_server_priority (server_declared_obj.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + server_declared_obj->test_method (server_priority, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Testing over. Shut down Server ORB. + server_declared_obj->shutdown (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Unexpected exception in Banded_Connections test client:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} + +#else /* TAO_HAS_RT_CORBA == 1 */ + +int +main (int argc, char *argv[]) +{ + ACE_UNUSED_ARG (argc); + ACE_UNUSED_ARG (argv); + ACE_ERROR_RETURN ((LM_ERROR, + "\nRTCORBA must be enabled to run this test!\n"), + 1); +} + +#endif /* TAO_HAS_RT_CORBA == 1 */ diff --git a/TAO/tests/RTCORBA/Banded_Connections/client.dsp b/TAO/tests/RTCORBA/Banded_Connections/client.dsp new file mode 100644 index 00000000000..7b89774cb0c --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/client.dsp @@ -0,0 +1,204 @@ +# Microsoft Developer Studio Project File - Name="Banded_Connections Client" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Banded_Connections Client - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "client.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "client.mak" CFG="Banded_Connections Client - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Banded_Connections Client - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Banded_Connections Client - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Banded_Connections Client - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\\" /I "..\..\..\\" /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib TAO.lib TAO_Strategies.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\tao\Strategies" /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+
+!ELSEIF "$(CFG)" == "Banded_Connections Client - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\\" /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 TAO_Strategiesd.lib TAOd.lib aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\tao\Strategies" /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+
+!ENDIF
+
+# Begin Target
+
+# Name "Banded_Connections Client - Win32 Release"
+# Name "Banded_Connections Client - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\client.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\testC.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\testC.h
+# End Source File
+# End Group
+# Begin Group "Inline Files"
+
+# PROP Default_Filter "i"
+# Begin Source File
+
+SOURCE=.\testC.i
+# End Source File
+# End Group
+# Begin Group "IDL Files"
+
+# PROP Default_Filter "idl"
+# Begin Source File
+
+SOURCE=.\test.idl
+
+!IF "$(CFG)" == "Banded_Connections Client - Win32 Release"
+
+USERDEP__TEST_="..\..\..\..\bin\Release\tao_idl.exe"
+# Begin Custom Build
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\Release\tao_idl.exe -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "Banded_Connections Client - Win32 Debug"
+
+# PROP Ignore_Default_Tool 1
+USERDEP__TEST_="..\..\..\..\bin\tao_idl.exe"
+# Begin Custom Build - Invoking TAO_IDL on $(InputName)
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\tao_idl -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/TAO/tests/RTCORBA/Banded_Connections/run_test.pl b/TAO/tests/RTCORBA/Banded_Connections/run_test.pl new file mode 100755 index 00000000000..a2c4e48a50b --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/run_test.pl @@ -0,0 +1,76 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +unshift @INC, '../../../../bin'; +require ACEutils; +use Cwd; + +$cwd = getcwd(); +$iorfile1 = "$cwd$DIR_SEPARATOR" . "test1.ior"; +$iorfile2 = "$cwd$DIR_SEPARATOR" . "test2.ior"; + +ACE::checkForTarget($cwd); + +print STDERR "\n********** RTCORBA SERVER_DECLARED Priority Unit Test\n\n"; + +unlink $iorfile1; +unlink $iorfile2; + +# CORBA priorities 65, 70 and 75 are for the SCHED_OTHER class on +# Solaris. May need to use different values for other platforms +# depending on their native priorities scheme, i.e., based on the +# available range. + +$server_args = + "-p $iorfile1 -o $iorfile2 -a 65 -b 75 -c 70 -ORBSvcConf server.conf " + ."-ORBendpoint iiop://$TARGETHOSTNAME:0/priority=65 " + ."-ORBendpoint iiop://$TARGETHOSTNAME:0/priority=75 " + ."-ORBendpoint iiop://$TARGETHOSTNAME:0/priority=73 "; + +if ($^O eq "MSWin32") +{ + $server_args = + "-p $iorfile1 -o $iorfile2 -a 3 -b 5 -c 2 -ORBSvcConf server.conf " + ."-ORBendpoint iiop://$TARGETHOSTNAME:0/priority=3 " + ."-ORBendpoint iiop://$TARGETHOSTNAME:0/priority=5 " + ."-ORBendpoint iiop://$TARGETHOSTNAME:0/priority=1 "; +} + +$client_args = "-p file://$iorfile1 -o file://$iorfile2"; + +$SV = Process::Create ($EXEPREFIX."server$EXE_EXT ", + $server_args); + +if (ACE::waitforfile_timed ($iorfile2, 10) == -1) { + print STDERR "ERROR: cannot find file <$iorfile2>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$CL = Process::Create ($EXEPREFIX."client$EXE_EXT ", + $client_args); + +$client = $CL->TimedWait (60); +if ($client == -1) { + print STDERR "ERROR: client timedout\n"; + $CL->Kill (); $CL->TimedWait (1); +} + +$server = $SV->TimedWait (60); +if ($server == -1) { + print STDERR "ERROR: server timedout\n"; + $SV->Kill (); $SV->TimedWait (1); +} + +unlink $iorfile1; +unlink $iorfile2; + +if ($server != 0 || $client != 0) { + exit 1; +} + +exit 0; diff --git a/TAO/tests/RTCORBA/Banded_Connections/server.bor b/TAO/tests/RTCORBA/Banded_Connections/server.bor new file mode 100644 index 00000000000..8c0820f9f96 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/server.bor @@ -0,0 +1,35 @@ +# +# Makefile for building the Server_Protocol server +# + +NAME = server + +TAO_IDL = $(CORE_BINDIR)\tao_idl -g $(CORE_BINDIR)\gperf.exe -Ge 1 + +OBJFILES = \ + $(OBJDIR)\testS.obj \ + $(OBJDIR)\testC.obj \ + $(OBJDIR)\server.obj + +CFLAGS = \ + $(ACE_CFLAGS) \ + $(TAO_CFLAGS) \ + $(TAO_PORTABLESERVER_CFLAGS) + +LIBFILES = \ + $(ACE_LIB) \ + $(TAO_LIB) \ + $(TAO_PORTABLESERVER_LIB) + +CPPDIR = . + +IDLDIR = . + +!include <$(ACE_ROOT)\include\makeinclude\build_exe.bor> + +# +# IDL Build rules +# + +$(IDLDIR)\testS.cpp $(IDLDIR)\testC.cpp: $(IDLDIR)\test.idl + $(TAO_IDL) $** diff --git a/TAO/tests/RTCORBA/Banded_Connections/server.conf b/TAO/tests/RTCORBA/Banded_Connections/server.conf new file mode 100644 index 00000000000..246d3798be1 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/server.conf @@ -0,0 +1,9 @@ +# $Id$ +# +<<<<<<< server.conf +dynamic Resource_Factory Service_Object +*TAO_Strategies:_make_TAO_Advanced_Resource_Factory () "-ORBReactorType tp -ORBReactorRegistry per-priority -ORBPriorityMapping direct -ORBSchedPolicy sched_other" +======= +static Resource_Factory "-ORBReactorType tp" +dynamic Resource_Factory Service_Object *TAO_Strategies:_make_TAO_Advanced_Resource_Factory () "-ORBReactorRegistry per-priority -ORBPriorityMapping direct -ORBSchedPolicy sched_other" +>>>>>>> 1.4 diff --git a/TAO/tests/RTCORBA/Banded_Connections/server.cpp b/TAO/tests/RTCORBA/Banded_Connections/server.cpp new file mode 100644 index 00000000000..e4426f71d75 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/server.cpp @@ -0,0 +1,557 @@ +// $Id$ + +#include "testS.h" +#include "ace/Get_Opt.h" +#include "ace/Read_Buffer.h" +#include "tao/RTCORBAC.h" +#include "tao/Pool_Per_Endpoint.h" + +#if (TAO_HAS_RT_CORBA == 1) + +class Test_i : public POA_Test +{ + // = TITLE + // An implementation for the Test interface in test.idl + // +public: + Test_i (CORBA::ORB_ptr orb, + RTCORBA::PriorityBands &bands); + // ctor + + void test_method (CORBA::Short priority, + CORBA::Environment&) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void shutdown (CORBA::Environment&) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + CORBA::ORB_var orb_; + // The ORB + RTCORBA::PriorityBands &bands_; + // Priority bands. +}; + +Test_i::Test_i (CORBA::ORB_ptr orb, + RTCORBA::PriorityBands & bands) + : orb_ (CORBA::ORB::_duplicate (orb)), + bands_ (bands) +{ +} + +void +Test_i::test_method (CORBA::Short priority, + CORBA::Environment& ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Use RTCurrent to find out the CORBA priority of the current + // thread. + + CORBA::Object_var obj = + this->orb_->resolve_initial_references ("RTCurrent", ACE_TRY_ENV); + ACE_CHECK; + + RTCORBA::Current_var current = + RTCORBA::Current::_narrow (obj.in (), ACE_TRY_ENV); + ACE_CHECK; + + if (CORBA::is_nil (obj.in ())) + ACE_THROW (CORBA::INTERNAL ()); + + CORBA::Short servant_thread_priority = + current->the_priority (ACE_TRY_ENV); + ACE_CHECK; + + // Print out the info. + int index = -1; + ACE_DEBUG ((LM_DEBUG, + "Object bands: \n")); + for (CORBA::ULong i = 0; i < this->bands_.length (); ++i) + { + ACE_DEBUG ((LM_DEBUG, + "%ld) %d %d\n", + (i + 1), this->bands_[i].low, this->bands_[i].high)); + + if (priority <= this->bands_[i].high + && priority >= this->bands_[i].low + && servant_thread_priority <= this->bands_[i].high + && servant_thread_priority >= this->bands_[i].low) + index = i + 1; + } + + ACE_DEBUG ((LM_DEBUG, + "Object priority: %d " + "Servant thread priority: %d\n", + priority, servant_thread_priority)); + + if (index == -1) + ACE_DEBUG ((LM_DEBUG, + "ERROR: object and thread priorities do not" + "match the same band.\n")); + else + ACE_DEBUG ((LM_DEBUG, + "Band %d was used for this invocation\n", index)); +} + +void +Test_i::shutdown (CORBA::Environment& ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->orb_->shutdown (0, ACE_TRY_ENV); +} + +//************************************************************************* + +const char *bands_file = "bands"; +const char *ior_output_file1 = "test1.ior"; +const char *ior_output_file2 = "test2.ior"; +CORBA::Short poa_priority = -1; +CORBA::Short wrong_priority = -1; + +// Parse command-line arguments. +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "p:w:b:o:n:"); + int c, result; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'n': + ior_output_file1 = get_opts.optarg; + break; + + case 'o': + ior_output_file2 = get_opts.optarg; + break; + + case 'b': + bands_file = get_opts.optarg; + break; + + case 'p': + result = ::sscanf (get_opts.optarg, + "%hd", + &poa_priority); + if (result == 0 || result == EOF) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to process <-a> option"), + -1); + break; + + case 'w': + result = ::sscanf (get_opts.optarg, + "%hd", + &wrong_priority); + if (result == 0 || result == EOF) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to process <-c> option"), + -1); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-n <iorfile1> " + "-o <iorfile2> " + "-b <bands_file> " + "-p <poa_priority> " + "-w <wrong_priority> " + "\n", + argv [0]), + -1); + } + + if (poa_priority < 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Valid poa priority must be" + " specified.\nSee README file for more info\n"), + -1); + + return 0; +} + +int +get_priority_bands (RTCORBA::PriorityBands &bands) +{ + FILE* file = ACE_OS::fopen (bands_file, "r"); + + if (file == 0) + return -1; + + ACE_Read_Buffer reader (file, 1); + + char* string = reader.read (EOF, ' ', '\0'); + + if (string == 0) + return -1; + + CORBA::ULong bands_length = (reader.replaced () + 1) / 2; + bands.length (bands_length); + + int result = 1; + char* working_string = string; + for (CORBA::ULong i = 0; i < bands_length; ++i) + { + result = ::sscanf (working_string, + "%hd", + &bands[i].low); + if (result == 0 || result == EOF) + break; + + working_string += ACE_OS::strlen (working_string); + working_string += 1; + + result = ::sscanf (working_string, + "%hd", + &bands[i].high); + if (result == 0 || result == EOF) + break; + + working_string += ACE_OS::strlen (working_string); + working_string += 1; + + if (bands[i].low > bands[i].high) + { + result = 0; + break; + } + } + + reader.alloc ()->free (string); + + if (result == 0 || result == EOF) + return -1; + else + return 0; +} + +int +check_for_nil (CORBA::Object_ptr obj, const char *msg) +{ + if (CORBA::is_nil (obj)) + ACE_ERROR_RETURN ((LM_ERROR, + "ERROR: Object reference <%s> is nil\n", + msg), + -1); + else + return 0; +} + +int +create_object (PortableServer::POA_ptr poa, + CORBA::ORB_ptr orb, + Test_i *server_impl, + const char *filename, + CORBA::Environment &ACE_TRY_ENV) +{ + // Register with poa. + PortableServer::ObjectId_var id; + + id = poa->activate_object (server_impl, ACE_TRY_ENV); + ACE_CHECK_RETURN (-1); + + CORBA::Object_var server = + poa->id_to_reference (id.in (), ACE_TRY_ENV); + ACE_CHECK_RETURN (-1); + + // Print out the IOR. + CORBA::String_var ior = + orb->object_to_string (server.in (), ACE_TRY_ENV); + ACE_CHECK_RETURN (-1); + + ACE_DEBUG ((LM_DEBUG, "<%s>\n\n", ior.in ())); + + // Print ior to the file. + if (filename != 0) + { + FILE *output_file= ACE_OS::fopen (filename, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + filename), + -1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + } + + return 0; +} + +void +object_activation_exception_test (RTPortableServer::POA_ptr poa, + Test_i *server_impl, + CORBA::Short priority, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + // Register with poa. + PortableServer::ObjectId_var id = + poa->activate_object_with_priority (server_impl, + priority, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::Object_var server = + poa->id_to_reference (id.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Test failed: no exception caught\n")); + } + ACE_CATCH (CORBA::BAD_PARAM, ex) + { + ACE_DEBUG ((LM_DEBUG, + "BAD_PARAM exception is caught as expected.\n")); + } + ACE_CATCHANY + { + ACE_DEBUG ((LM_DEBUG, "Test failed: unexpected exception caught\n")); + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; +} + +void +poa_creation_exception_test (PortableServer::POA_ptr root_poa, + PortableServer::POAManager_ptr manager, + CORBA::PolicyList &policies, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + PortableServer::POA_var child_poa = + root_poa->create_POA ("Child_POA", + manager, + policies, + ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_DEBUG ((LM_DEBUG, "Test failed: no exception caught\n")); + } + ACE_CATCH (PortableServer::POA::InvalidPolicy, ex) + { + ACE_DEBUG ((LM_DEBUG, + "InvalidPolicy exception is caught as expected.\n")); + } + ACE_CATCHANY + { + ACE_DEBUG ((LM_DEBUG, "Test failed: unexpected exception\n")); + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; +} + +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + // ORB. + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Parse arguments. + if (parse_args (argc, argv) != 0) + return 1; + + // RTORB. + CORBA::Object_var object = + orb->resolve_initial_references ("RTORB", ACE_TRY_ENV); + ACE_TRY_CHECK; + RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + if (check_for_nil (rt_orb.in (), "RTORB") == -1) + return 1; + + // RootPOA. + object = + orb->resolve_initial_references("RootPOA", ACE_TRY_ENV); + ACE_TRY_CHECK; + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + if (check_for_nil (root_poa.in (), "RootPOA") == -1) + return 1; + + // POAManager. + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Obtain priority bands to be used in this test from the file + // specified by the user. + RTCORBA::PriorityBands bands; + if (get_priority_bands (bands) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "Error reading priority bands from file\n"), + 1); + + // Servant. + Test_i server_impl (orb.in (), bands); + + // Test 1: Attempt to create a POA with priority bands but + // without the priority model. Should get POA::InvalidPolicy + // exception. + ACE_DEBUG ((LM_DEBUG, + "\n Test 1\n")); + + CORBA::PolicyList poa_policy_list; + poa_policy_list.length (1); + poa_policy_list[0] = + rt_orb->create_priority_banded_connection_policy + (bands, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + poa_creation_exception_test (root_poa.in (), + poa_manager.in (), + poa_policy_list, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Test 2: Attempt to create a POA with priority bands that do + // not match the resources (i.e., endpoints/lanes). Should get + // POA::InvalidPolicy exception. + ACE_DEBUG ((LM_DEBUG, + "\n Test 2\n")); + + RTCORBA::PriorityBands false_bands; + false_bands.length (2); + false_bands[0].low = 10000; + false_bands[0].high = 10005; + false_bands[1].low = 26; + false_bands[1].high = 30; + + poa_policy_list[0] = + rt_orb->create_priority_banded_connection_policy + (false_bands, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + poa_creation_exception_test (root_poa.in (), + poa_manager.in (), + poa_policy_list, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Create POA with CLIENT_PROPAGATED priority model, no bands. + poa_policy_list[0] = + rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, + 0, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableServer::POA_var client_propagated_poa = + root_poa->create_POA ("client_propagated_poa", + poa_manager.in (), + poa_policy_list, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Create POA with SERVER_DECLARED priority model, with bands. + poa_policy_list.length (2); + poa_policy_list[0] = + rt_orb->create_priority_model_policy (RTCORBA::SERVER_DECLARED, + poa_priority, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + poa_policy_list[1] = + rt_orb->create_priority_banded_connection_policy + (bands, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableServer::POA_var server_declared_poa = + root_poa->create_POA ("server_declared_poa", + poa_manager.in (), + poa_policy_list, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Test 3: Attempt to register an object with priority that + // doesn't match POA resources (i.e., endpoints/lanes). Should + // get BAD_PARAM exception. + ACE_DEBUG ((LM_DEBUG, + "\n Test 3\n")); + + RTPortableServer::POA_var rt_server_declared_poa = + RTPortableServer::POA::_narrow (server_declared_poa.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + if (check_for_nil (rt_server_declared_poa.in (), "RTPOA") == -1) + return 1; + + object_activation_exception_test (rt_server_declared_poa.in (), + &server_impl, + wrong_priority, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + + // Create object 1 and register with <client_propagated_poa>. + int result; + ACE_DEBUG ((LM_DEBUG, "\nActivated object one as ")); + result = create_object (client_propagated_poa.in (), + orb.in (), + &server_impl, + ior_output_file1, + ACE_TRY_ENV); + ACE_TRY_CHECK; + if (result == -1) + return 1; + + // Create object 2 and register with <server_declared_poa>. + ACE_DEBUG ((LM_DEBUG, "\nActivated object two as ")); + result = create_object (server_declared_poa.in (), + orb.in (), + &server_impl, + ior_output_file2, + ACE_TRY_ENV); + ACE_TRY_CHECK; + if (result == -1) + return 1; + + // Activate POA manager. + poa_manager->activate (ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Start ORB event loop. + // @@ Currently we are using Reactor per priority to emulate + // threadpool with lanes. Once POA threadpools are implemented, + // this code should be replaced with standard threadpool apis. + TAO_Pool_Per_Endpoint pool (orb.in ()); + pool.run (ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Server ORB event loop finished\n\n")); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Unexpected exception caught in Banded_Connections test server:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} + +#else /* TAO_HAS_RT_CORBA == 1 */ + +int +main (int argc, char *argv[]) +{ + ACE_UNUSED_ARG (argc); + ACE_UNUSED_ARG (argv); + ACE_ERROR_RETURN ((LM_ERROR, + "\nRTCORBA must be enabled to run this test!\n"), + 1); +} +#endif /* TAO_HAS_RT_CORBA == 1 */ diff --git a/TAO/tests/RTCORBA/Banded_Connections/server.dsp b/TAO/tests/RTCORBA/Banded_Connections/server.dsp new file mode 100644 index 00000000000..fae160eb1a1 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/server.dsp @@ -0,0 +1,216 @@ +# Microsoft Developer Studio Project File - Name="Banded_Connections Server" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Banded_Connections Server - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "server.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "server.mak" CFG="Banded_Connections Server - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Banded_Connections Server - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Banded_Connections Server - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Banded_Connections Server - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\\" /I "..\..\..\\" /I "..\..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib TAO.lib TAO_PortableServer.lib TAO_Strategies.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\tao\Strategies" /libpath:"..\..\..\tao\PortableServer" /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+
+!ELSEIF "$(CFG)" == "Banded_Connections Server - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\\" /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 TAO_Strategiesd.lib TAO_PortableServerd.lib TAOd.lib aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\tao\Strategies" /libpath:"..\..\..\tao\PortableServer" /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+
+!ENDIF
+
+# Begin Target
+
+# Name "Banded_Connections Server - Win32 Release"
+# Name "Banded_Connections Server - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\server.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\testC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\testS.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\testC.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\testS.h
+# End Source File
+# End Group
+# Begin Group "Inline Files"
+
+# PROP Default_Filter "i"
+# Begin Source File
+
+SOURCE=.\testC.i
+# End Source File
+# Begin Source File
+
+SOURCE=.\testS.i
+# End Source File
+# End Group
+# Begin Group "IDL Files"
+
+# PROP Default_Filter "idl"
+# Begin Source File
+
+SOURCE=.\test.idl
+
+!IF "$(CFG)" == "Banded_Connections Server - Win32 Release"
+
+USERDEP__TEST_="..\..\..\..\bin\Release\tao_idl.exe"
+# Begin Custom Build
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\Release\tao_idl.exe -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "Banded_Connections Server - Win32 Debug"
+
+# PROP Ignore_Default_Tool 1
+USERDEP__TEST_="..\..\..\..\bin\tao_idl.exe"
+# Begin Custom Build - Invoking TAO_IDL on $(InputName)
+InputPath=.\test.idl
+InputName=test
+
+BuildCmds= \
+ ..\..\..\..\bin\tao_idl -Ge 1 $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S_T.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/TAO/tests/RTCORBA/Banded_Connections/test.idl b/TAO/tests/RTCORBA/Banded_Connections/test.idl new file mode 100644 index 00000000000..f7d88246a75 --- /dev/null +++ b/TAO/tests/RTCORBA/Banded_Connections/test.idl @@ -0,0 +1,16 @@ +// +// $Id$ +// + +interface Test +{ + void test_method (in short priority); + // Takes target object priority in effect for this invocation. + // Prints out object priority, priority bands in effect, and the + // priority of the server thread servicing the request. Checks that + // object and server thread priorities match one of the + // priority bands. + + oneway void shutdown (); + // Shut down the ORB. +}; diff --git a/TAO/tests/RTCORBA/Makefile b/TAO/tests/RTCORBA/Makefile index 44c2927918a..dcc700259d6 100644 --- a/TAO/tests/RTCORBA/Makefile +++ b/TAO/tests/RTCORBA/Makefile @@ -10,7 +10,8 @@ # Local macros #---------------------------------------------------------------------------- -DIRS = Client_Propagated \ +DIRS = Banded_Connections \ + Client_Propagated \ Client_Protocol \ Server_Declared \ Server_Protocol \ diff --git a/TAO/tests/RTCORBA/Makefile.bor b/TAO/tests/RTCORBA/Makefile.bor index c71d9cda261..04bc90cd609 100644 --- a/TAO/tests/RTCORBA/Makefile.bor +++ b/TAO/tests/RTCORBA/Makefile.bor @@ -3,6 +3,7 @@ # DIRS = \ + Banded_Connections \ Client_Propagated \ Client_Protocol \ Server_Declared \ diff --git a/TAO/tests/RTCORBA/RTCORBA_tests.dsw b/TAO/tests/RTCORBA/RTCORBA_tests.dsw index 0a9b0c10758..dba11a7b34a 100644 --- a/TAO/tests/RTCORBA/RTCORBA_tests.dsw +++ b/TAO/tests/RTCORBA/RTCORBA_tests.dsw @@ -3,6 +3,30 @@ Microsoft Developer Studio Workspace File, Format Version 6.00 ###############################################################################
+Project: "Banded_Connections Client"=.\Banded_Connections\client.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "Banded_Connections Server"=.\Banded_Connections\server.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Project: "Client_Propagated Client"=.\Client_Propagated\client.dsp - Package Owner=<4>
Package=<5>
|