aboutsummaryrefslogtreecommitdiffstats
path: root/lib/cosTransactions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cosTransactions')
-rw-r--r--lib/cosTransactions/test/Makefile150
-rw-r--r--lib/cosTransactions/test/cosTransactions.spec19
-rw-r--r--lib/cosTransactions/test/etrap_test.cfg20
-rw-r--r--lib/cosTransactions/test/etrap_test.idl38
-rw-r--r--lib/cosTransactions/test/etrap_test_lib.erl125
-rw-r--r--lib/cosTransactions/test/etrap_test_lib.hrl100
-rw-r--r--lib/cosTransactions/test/etrap_test_server_impl.erl210
-rw-r--r--lib/cosTransactions/test/generated_SUITE.erl564
-rw-r--r--lib/cosTransactions/test/transactions_SUITE.erl395
9 files changed, 1621 insertions, 0 deletions
diff --git a/lib/cosTransactions/test/Makefile b/lib/cosTransactions/test/Makefile
new file mode 100644
index 0000000000..8b1264d404
--- /dev/null
+++ b/lib/cosTransactions/test/Makefile
@@ -0,0 +1,150 @@
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 1999-2009. All Rights Reserved.
+#
+# The contents of this file are subject to the Erlang Public License,
+# Version 1.1, (the "License"); you may not use this file except in
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved online at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# %CopyrightEnd%
+#
+#
+include $(ERL_TOP)/make/target.mk
+include $(ERL_TOP)/make/$(TARGET)/otp.mk
+
+#ifeq ($(TYPE),debug)
+#ERL_COMPILE_FLAGS += -Ddebug -W
+#endif
+
+# ----------------------------------------------------
+# Application version
+# ----------------------------------------------------
+include ../vsn.mk
+VSN=$(COSTRANSACTIONS_VSN)
+# ----------------------------------------------------
+# Release directory specification
+# ----------------------------------------------------
+RELSYSDIR = $(RELEASE_PATH)/cosTransactions_test
+
+# ----------------------------------------------------
+# Target Specs
+# ----------------------------------------------------
+TEST_SPEC_FILE = cosTransactions.spec
+
+
+IDL_FILES = \
+ etrap_test.idl
+
+IDLOUTDIR = idl_output
+
+MODULES = \
+ transactions_SUITE \
+ etrap_test_server_impl \
+ etrap_test_lib \
+ generated_SUITE
+
+GEN_MODULES = \
+ oe_etrap_test \
+ etrap_test_server
+
+GEN_HRL_FILES = \
+ oe_etrap_test.hrl \
+ etrap_test_server.hrl
+
+ERL_FILES = $(MODULES:%=%.erl)
+
+HRL_FILES = \
+ etrap_test_lib.hrl
+
+GEN_FILES = \
+ $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \
+ $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl)
+
+GEN_TARGET_FILES = $(GEN_MODULES:%=$(IDLOUTDIR)/%.$(EMULATOR))
+
+SUITE_TARGET_FILES = $(MODULES:%=%.$(EMULATOR))
+
+TARGET_FILES = \
+ $(GEN_TARGET_FILES) \
+ $(SUITE_TARGET_FILES)
+
+
+# ----------------------------------------------------
+# PROGRAMS
+# ----------------------------------------------------
+LOCAL_CLASSPATH = $(ERL_TOP)/lib/cosTransactions/priv:$(ERL_TOP)/lib/cosTransactions/test
+# ----------------------------------------------------
+# FLAGS
+# ----------------------------------------------------
+ERL_IDL_FLAGS += -pa $(ERL_TOP)/lib/cosTransactions/ebin\
+ -pa $(ERL_TOP)/lib/orber/ebin \
+ -pa $(ERL_TOP)/lib/ic/ebin
+
+ERL_COMPILE_FLAGS += \
+ $(ERL_IDL_FLAGS) \
+ -pa $(ERL_TOP)/lib/orber/include \
+ -pa $(ERL_TOP)/lib/test_server/ebin \
+ -pa $(ERL_TOP)/lib/cosTransactions/ebin \
+ -pa $(ERL_TOP)/lib/cosTransactions/test/idl_output \
+ -I$(ERL_TOP)/lib/orber/include \
+ -I$(ERL_TOP)/lib/cosTransactions \
+ -I$(ERL_TOP)/lib/cosTransactions/test/$(IDLOUTDIR) \
+ -I$(ERL_TOP)/lib/test_server/include
+
+# ----------------------------------------------------
+# Targets
+# ----------------------------------------------------
+
+
+tests debug opt: $(TARGET_FILES)
+
+clean:
+ rm -f idl_output/*
+ rm -f $(TARGET_FILES)
+ rm -f errs core *~
+
+#debug:
+# @${MAKE} TYPE=debug
+
+docs:
+
+# ----------------------------------------------------
+# Special Targets
+# ----------------------------------------------------
+
+TGT_TEST = \
+ $(GEN_HRL_FILES:%=$(IDLOUTDIR)/%) \
+ $(GEN_MODULES:%=$(IDLOUTDIR)/%.erl)
+
+$(TGT_TEST): etrap_test.idl
+ erlc $(ERL_IDL_FLAGS) -o$(IDLOUTDIR) \
+ +'{cfgfile,"etrap_test.cfg"}' etrap_test.idl
+
+# ----------------------------------------------------
+# Release Targets
+# ----------------------------------------------------
+# We don't copy generated intermediate erlang and hrl files
+
+include $(ERL_TOP)/make/otp_release_targets.mk
+
+release_spec:
+
+release_docs_spec:
+
+release_tests_spec: tests
+ $(INSTALL_DIR) $(RELSYSDIR)
+ $(INSTALL_DATA) $(IDL_FILES) $(TEST_SPEC_FILE) \
+ $(ERL_FILES) $(HRL_FILES) $(RELSYSDIR)
+ $(INSTALL_DATA) $(SUITE_TARGET_FILES) $(RELSYSDIR)
+ $(INSTALL_DIR) $(RELSYSDIR)/$(IDLOUTDIR)
+ $(INSTALL_DATA) $(GEN_TARGET_FILES) $(GEN_FILES) \
+ $(RELSYSDIR)/$(IDLOUTDIR)
+
diff --git a/lib/cosTransactions/test/cosTransactions.spec b/lib/cosTransactions/test/cosTransactions.spec
new file mode 100644
index 0000000000..8ad9259964
--- /dev/null
+++ b/lib/cosTransactions/test/cosTransactions.spec
@@ -0,0 +1,19 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+{topcase, {dir, "../cosTransactions_test"}}.
diff --git a/lib/cosTransactions/test/etrap_test.cfg b/lib/cosTransactions/test/etrap_test.cfg
new file mode 100644
index 0000000000..4f2b9e125d
--- /dev/null
+++ b/lib/cosTransactions/test/etrap_test.cfg
@@ -0,0 +1,20 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+{this, "etrap_test::server"}.
+{{handle_info, "etrap_test::server"}, true}.
diff --git a/lib/cosTransactions/test/etrap_test.idl b/lib/cosTransactions/test/etrap_test.idl
new file mode 100644
index 0000000000..7573cc1a36
--- /dev/null
+++ b/lib/cosTransactions/test/etrap_test.idl
@@ -0,0 +1,38 @@
+//
+// %CopyrightBegin%
+//
+// Copyright Ericsson AB 1999-2010. All Rights Reserved.
+//
+// The contents of this file are subject to the Erlang Public License,
+// Version 1.1, (the "License"); you may not use this file except in
+// compliance with the License. You should have received a copy of the
+// Erlang Public License along with this software. If not, it can be
+// retrieved online at http://www.erlang.org/.
+//
+// Software distributed under the License is distributed on an "AS IS"
+// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+// the License for the specific language governing rights and limitations
+// under the License.
+//
+// %CopyrightEnd%
+//
+
+#ifndef _TEST_IDL
+#define _TEST_IDL
+#include <../src/CosTransactions.idl>
+module etrap_test {
+
+ // interface server
+ interface server :
+ CosTransactions::Coordinator, CosTransactions::SubtransactionAwareResource,
+ CosTransactions::RecoveryCoordinator, CosTransactions::Control {
+ };
+// interface Server :
+// CosTransactions::Coordinator, CosTransactions::SubtransactionAwareResource,
+// CosTransactions::RecoveryCoordinator, CosTransactions::Control,
+// CosTransactions::Synchronization {
+// };
+
+}; // End of test Module
+
+#endif
diff --git a/lib/cosTransactions/test/etrap_test_lib.erl b/lib/cosTransactions/test/etrap_test_lib.erl
new file mode 100644
index 0000000000..913a94510f
--- /dev/null
+++ b/lib/cosTransactions/test/etrap_test_lib.erl
@@ -0,0 +1,125 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1999-2009. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+
+-module(etrap_test_lib).
+
+%%--------------- INCLUDES ---------------------------------------------
+-include("etrap_test_lib.hrl").
+-include_lib("cosTransactions/src/ETraP_Common.hrl").
+
+%%--------------- EXPORTS ----------------------------------------------
+-export([scratch_debug_fun/0,
+ activate_debug_fun/5,
+ update_debug_info/1,
+ deactivate_debug_fun/3,
+ eval_debug_fun/4,
+ set_debug_context/4]).
+
+%%--------------- CONSTANTS/DEFINITIONS --------------------------------
+-define(DEBUG_TAB, etrap_debug).
+-record(debug_info, {id, function, type, file, line}).
+
+%%--------------- DEBUG FUNCTIONS --------------------------------------
+%% Managing conditional debug functions
+%%
+%% The main idea with the debug_fun's is to allow test programs
+%% to control the internal behaviour of CosTransactions.
+%%
+%% First should calls to ?eval_debug_fun be inserted at well
+%% defined places in CosTransaction's code. E.g. in critical situations
+%% of startup, transaction commit, backups etc.
+%%
+%% Then compile CosTransactions with the compiler option 'debug'.
+%%
+%% In test programs ?activate_debug_fun should be called
+%% in order to bind a fun to the debug identifier stated
+%% in the call to ?eval_debug_fun.
+
+scratch_debug_fun() ->
+ catch ets:delete(?DEBUG_TAB),
+ ets:new(?DEBUG_TAB,
+ [set, public, named_table, {keypos, 2}]).
+
+activate_debug_fun(FunId, Fun, Type, File, Line) ->
+ io:format("Activiating ~p RETRIES: ~p WAIT: ~p~n",
+ [FunId, ?tr_max_retries, ?tr_comm_failure_wait]),
+ Info = #debug_info{id = FunId,
+ function = Fun,
+ type = Type,
+ file = File,
+ line = Line},
+ update_debug_info(Info).
+
+update_debug_info(Info) ->
+ case catch ets:insert(?DEBUG_TAB, Info) of
+ {'EXIT', _} ->
+ scratch_debug_fun(),
+ ets:insert(?DEBUG_TAB, Info);
+ _ ->
+ ok
+ end,
+ ok.
+
+deactivate_debug_fun(FunId, _File, _Line) ->
+ catch ets:delete(?DEBUG_TAB, FunId),
+ ok.
+
+eval_debug_fun(FunId, Env, File, Line) ->
+ case catch ets:lookup(?DEBUG_TAB, FunId) of
+ [] ->
+ ok;
+ [Info] ->
+ Fun = Info#debug_info.function,
+ case Info#debug_info.type of
+ transient ->
+ deactivate_debug_fun(FunId, File, Line);
+ _->
+ ok
+ end,
+ io:format("Running debug fun ~p:~p (LINE: ~p)~n", [File, FunId, Line]),
+ Fun(Env);
+ {'EXIT', _R} ->
+ ok
+ end.
+
+
+set_debug_context([], [], _, _)-> ok;
+set_debug_context([], _, _, _)->
+ ets:delete(?DEBUG_TAB),
+ exit("failed transactions_SUITE. Bad configuration.");
+set_debug_context(_, [], _, _)->
+ ets:delete(?DEBUG_TAB),
+ exit("failed transactions_SUITE Bad configuration.");
+set_debug_context([RHead|RTail], [CHead|CTail], File, Line)->
+ write_context(RHead, CHead, File, Line),
+ set_debug_context(RTail, CTail, File, Line).
+
+write_context(_Resource, [], _, _)-> ok;
+write_context(Resource, [{Func, Fun, Type}|PTail], File, Line)->
+ etrap_test_lib:activate_debug_fun({Resource, Func},
+ Fun, Type,
+ File, Line),
+ write_context(Resource, PTail, File, Line);
+write_context(_,_, _, _) ->
+ ets:delete(?DEBUG_TAB),
+ exit("failed transactions_SUITE. Bad configuration.").
+
+
+%%--------------- END OF MODULE ----------------------------------------
diff --git a/lib/cosTransactions/test/etrap_test_lib.hrl b/lib/cosTransactions/test/etrap_test_lib.hrl
new file mode 100644
index 0000000000..d488bf9d12
--- /dev/null
+++ b/lib/cosTransactions/test/etrap_test_lib.hrl
@@ -0,0 +1,100 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1999-2009. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+
+-ifndef(ETRAP_TEST_LIB_HRL).
+-define(ETRAP_TEST_LIB_HRL, true).
+
+-define(match(ExpectedRes, Expr, Msg),
+ fun() ->
+ AcTuAlReS = (catch (Expr)),
+ case AcTuAlReS of
+ ExpectedRes ->
+ io:format("~n------ CORRECT RESULT ------~n~p~n~p~n",
+ [AcTuAlReS, Msg]),
+ ok;
+ _ ->
+ io:format("~n###### ERROR ERROR ######~n~p~n~p~n",
+ [AcTuAlReS, Msg]),
+ exit(AcTuAlReS)
+ end
+ end()).
+
+-define(match_inverse(NotExpectedRes, Expr, Msg),
+ fun() ->
+ AcTuAlReS = (catch (Expr)),
+ case AcTuAlReS of
+ NotExpectedRes ->
+ io:format("~n###### ERROR ERROR ######~n ~p~n~p~n",
+ [AcTuAlReS, Msg]),
+ exit(AcTuAlReS);
+ _ ->
+ io:format("~n------ CORRECT RESULT ------~n~p~n~p~n",
+ [AcTuAlReS, Msg]),
+ ok
+ end
+ end()).
+
+
+-define(crash_and_recover, fun(_Env)-> exit(crash_and_burn) end).
+
+-define(crash_no_recovery, fun(Env)-> throw({stop,normal,{Env,state}}) end).
+
+-define(delay(Time), fun(_Id) -> timer:sleep(Time*1000) end).
+
+-define(TIMEOUT, 4).
+-define(SUP_TEST(Env, Name),
+ ['etrap_test_server', Env,
+ [{sup_child, true}, {persistent, true},
+ {regname, {global, Name}}]]).
+
+-define(no_context, [[],[],[], []]).
+-define(nop, []).
+-define(delay_transient(Tag, Ti),
+ [{Tag, ?delay(Ti), transient}]).
+-define(crash_transient(Tag),
+ [{Tag, ?crash_and_recover, transient}]).
+-define(crash_permanent(Tag),
+ [{Tag, ?crash_no_recovery, permanent}]).
+
+%%-----------------------------------------------------------
+%% Definition of 'Resource' action.
+%% function action reply
+%%-----------------------------------------------------------
+%% raise #'CosTransactions_HeuristicMixed' {}
+-define(rollback_mix, [{rollback, exc, ?tr_mixed}]).
+-define(commit_mix, [{commit, exc, ?tr_mixed}]).
+-define(prepare_mix, [{prepare, exc, ?tr_mixed}]).
+%% raise #'CosTransactions_HeuristicRollback' {}
+-define(rollback_rb, [{rollback, exc, ?tr_rollback}]).
+-define(commit_rb, [{commit, exc, ?tr_rollback}]).
+%% raise #'CosTransactions_HeuristicCommit' {}
+-define(rollback_cm, [{rollback, exc, ?tr_commit}]).
+-define(commit_cm, [{commit, exc, ?tr_commit}]).
+%% delay reply
+-define(rollback_delay, [{rollback, delay, ?TIMEOUT*2}]).
+-define(commit_delay, [{commit, delay, ?TIMEOUT*2}]).
+-define(prepare_delay, [{prepare, delay, ?TIMEOUT*2}]).
+%% other reply than default
+-define(prepare_commit, [{prepare, reply, 'VoteCommit'}]).
+-define(prepare_rollback, [{prepare, stop_reply, 'VoteRollback'}]).
+
+-endif.
+
+%%-------------- EOF ---------------------------------------------------
diff --git a/lib/cosTransactions/test/etrap_test_server_impl.erl b/lib/cosTransactions/test/etrap_test_server_impl.erl
new file mode 100644
index 0000000000..69c823f3ca
--- /dev/null
+++ b/lib/cosTransactions/test/etrap_test_server_impl.erl
@@ -0,0 +1,210 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+-module(etrap_test_server_impl).
+
+%%--------------- INCLUDES -----------------------------------
+-include_lib("orber/include/corba.hrl").
+-include_lib("orber/include/ifr_types.hrl").
+%% Local
+-include_lib("cosTransactions/src/ETraP_Common.hrl").
+-include_lib("cosTransactions/include/CosTransactions.hrl").
+%%--------------- IMPORTS-------------------------------------
+%%--------------- EXPORTS-------------------------------------
+-export([prepare/2,
+ rollback/2,
+ commit/2,
+ commit_one_phase/2,
+ forget/2,
+% before_completion/2,
+% after_completion/3,
+ commit_subtransaction/3,
+ rollback_subtransaction/2]).
+
+
+%%--------------- gen_server specific ------------------------
+-export([init/1, terminate/2]).
+-export([handle_call/3, handle_cast/2, handle_info/2, code_change/3]).
+
+%%------------------------------------------------------------
+%% function : init, terminate
+%%------------------------------------------------------------
+init(State) ->
+ process_flag(trap_exit,true),
+ io:format("etrap_test_server:init ~p~n", [State]),
+ ?debug_print("STARTING etrap_test_server( ~p )~n", [State]),
+ {ok, State}.
+
+terminate(Reason, _State) ->
+ io:format("etrap_test_server:terminate ~p~n", [Reason]),
+ ?debug_print("STOPREASON etrap_test_server( ~p )~n", [Reason]),
+ ok.
+
+code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
+handle_call(_,_, State) ->
+ {noreply, State}.
+handle_cast(_, State) ->
+ {noreply, State}.
+handle_info(_Info, State) ->
+ {noreply, State}.
+
+%%-- Inherit from CosTransactions::SubtransactionAwareResource --
+prepare(_Self, State) ->
+ case ?is_debug_compiled of
+ true ->
+ io:format("etrap_test_server:prepare ~p~n", [State]);
+ _->
+ ok
+ end,
+% ?debug_print("etrap_test_server:prepare ~p~n", [State]),
+ action(prepare, State, {reply, 'VoteCommit', State}).
+
+rollback(_Self, State) ->
+ case ?is_debug_compiled of
+ true ->
+ io:format("etrap_test_server:rollback ~p~n", [State]);
+ _->
+ ok
+ end,
+% ?debug_print("etrap_test_server:rollback ~p~n", [State]),
+ case sync_test(State) of
+ true ->
+ action(rollback, State, {reply, ok, State});
+ _->
+ action(rollback, State, {stop, normal, ok, State})
+ end.
+
+commit(_Self, State) ->
+ case ?is_debug_compiled of
+ true ->
+ io:format("etrap_test_server:commit ~p~n", [State]);
+ _->
+ ok
+ end,
+% ?debug_print("etrap_test_server:commit ~p~n", [State]),
+ case sync_test(State) of
+ true ->
+ action(commit, State, {reply, ok, State});
+ _->
+ action(commit, State, {stop, normal, ok, State})
+ end.
+
+commit_one_phase(_Self, State) ->
+ case ?is_debug_compiled of
+ true ->
+ io:format("etrap_test_server:commit_one_phase ~p~n", [State]);
+ _->
+ ok
+ end,
+% ?debug_print("etrap_test_server:commit_one_phase ~p~n", [State]),
+ case sync_test(State) of
+ true ->
+ {reply, ok, State};
+ _->
+ {stop, normal, ok, State}
+ end.
+
+forget(_Self, State) ->
+ case ?is_debug_compiled of
+ true ->
+ io:format("etrap_test_server:forget ~p~n", [State]);
+ _->
+ ok
+ end,
+% ?debug_print("etrap_test_server:forget ~p~n", [State]),
+ case sync_test(State) of
+ true ->
+ {reply, ok, State};
+ _->
+ {stop, normal, ok, State}
+ end.
+
+commit_subtransaction(_Self, State, Parent) ->
+ case ?is_debug_compiled of
+ true ->
+ io:format("etrap_test_server:commit_subtransaction( ~p )~n", [Parent]);
+ _->
+ ok
+ end,
+% ?debug_print("etrap_test_server:commit_subtransaction( ~p )~n", [Parent]),
+ {reply, ok, State}.
+rollback_subtransaction(_Self, State) ->
+ case ?is_debug_compiled of
+ true ->
+ io:format("etrap_test_server:rollback_subtransaction()~n", []);
+ _->
+ ok
+ end,
+% ?debug_print("etrap_test_server:rollback_subtransaction()~n", []),
+ {reply, ok, State}.
+
+%before_completion(_Self, State) ->
+% case ?is_debug_compiled of
+% true ->
+% io:format("etrap_test_server:before_completion()~n", []);
+% _->
+% ok
+% end,
+%% ?debug_print("etrap_test_server:before_completion()~n", []),
+% {reply, ok, State}.
+%after_completion(_Self, State, Status) ->
+% case ?is_debug_compiled of
+% true ->
+% io:format("etrap_test_server:after_completion( ~p )~n", [Status]);
+% _->
+% ok
+% end,
+%% ?debug_print("etrap_test_server:after_completion( ~p )~n", [Status]),
+% {stop, normal, ok, State}.
+
+%%--------------- LOCAL FUNCTIONS ----------------------------
+action(Key, State, Default) ->
+ case catch lists:keysearch(Key, 1, State) of
+ {value,{Key, stop_reply, R}} ->
+ case sync_test(State) of
+ true ->
+ {reply, R, State};
+ _->
+ {stop, normal, R, State}
+ end;
+ {value,{Key, reply, R}} ->
+ {reply, R, State};
+ {value,{Key, exc, E}} ->
+ corba:raise(E);
+ {value,{Key, delay, Time}} ->
+ timer:sleep(Time*1000),
+ Default;
+ {value,{Key,Value}} ->
+ Value;
+ _ ->
+ Default
+ end.
+
+sync_test(State) ->
+ case catch lists:keysearch(sync, 1, State) of
+ {value,{sync, true}} ->
+ true;
+ _ ->
+ false
+ end.
+
+
+%%--------------- END OF MODULE ------------------------------
+
diff --git a/lib/cosTransactions/test/generated_SUITE.erl b/lib/cosTransactions/test/generated_SUITE.erl
new file mode 100644
index 0000000000..cc54eb168e
--- /dev/null
+++ b/lib/cosTransactions/test/generated_SUITE.erl
@@ -0,0 +1,564 @@
+%%-----------------------------------------------------------------
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2004-2009. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+%%-----------------------------------------------------------------
+%% File : generated_SUITE.erl
+%% Purpose :
+%% Created : 27 Jan 2004
+%%-----------------------------------------------------------------
+
+-module(generated_SUITE).
+
+-include("test_server.hrl").
+-include_lib("orber/include/corba.hrl").
+
+-define(default_timeout, ?t:minutes(3)).
+
+-define(match(ExpectedRes, Expr),
+ fun() ->
+ AcTuAlReS = (catch (Expr)),
+ case AcTuAlReS of
+ ExpectedRes ->
+ AcTuAlReS;
+ _ ->
+ io:format("###### ERROR ERROR ######~n~p~n",
+ [AcTuAlReS]),
+ ?line exit(AcTuAlReS)
+ end
+ end()).
+
+-define(nomatch(Not, Expr),
+ fun() ->
+ AcTuAlReS = (catch (Expr)),
+ case AcTuAlReS of
+ Not ->
+ io:format("###### ERROR ERROR ######~n~p~n",
+ [AcTuAlReS]),
+ ?line exit(AcTuAlReS);
+ _ ->
+ AcTuAlReS
+ end
+ end()).
+
+
+-define(checktc(_Op),
+ fun(TC) ->
+ case orber_tc:check_tc(TC) of
+ false ->
+ io:format("###### ERROR ERROR ######~n~p - ~p~n", [Op, TC]),
+ ?line exit(TC);
+ true ->
+ true
+ end
+ end).
+
+%%-----------------------------------------------------------------
+%% External exports
+%%-----------------------------------------------------------------
+-export([all/1]).
+
+%%-----------------------------------------------------------------
+%% Internal exports
+%%-----------------------------------------------------------------
+-export([]).
+-compile(export_all).
+
+%%-----------------------------------------------------------------
+%% Func: all/1
+%% Args:
+%% Returns:
+%%-----------------------------------------------------------------
+all(doc) -> ["This suite is for testing IC generated files"];
+all(suite) ->
+ ['CosTransactions_Control', 'CosTransactions_Coordinator',
+ 'CosTransactions_HeuristicCommit', 'CosTransactions_HeuristicHazard',
+ 'CosTransactions_HeuristicMixed', 'CosTransactions_HeuristicRollback',
+ 'CosTransactions_Inactive', 'CosTransactions_InvalidControl',
+ 'CosTransactions_NoTransaction', 'CosTransactions_NotPrepared',
+ 'CosTransactions_NotSubtransaction', 'CosTransactions_RecoveryCoordinator',
+ 'CosTransactions_Resource', 'CosTransactions_SubtransactionAwareResource',
+ 'CosTransactions_SubtransactionsUnavailable', 'CosTransactions_Terminator',
+ 'CosTransactions_TransactionFactory', 'CosTransactions_Unavailable',
+ 'CosTransactions_SynchronizationUnavailable', 'CosTransactions_TransIdentity',
+ 'CosTransactions_PropagationContext', 'CosTransactions_otid_t',
+ 'CosTransactions_WrongTransaction', 'ETraP_Server'].
+
+%%-----------------------------------------------------------------
+%% Init and cleanup functions.
+%%-----------------------------------------------------------------
+init_per_testcase(_Case, Config) ->
+ ?line Dog=test_server:timetrap(?default_timeout),
+ [{watchdog, Dog}|Config].
+
+
+fin_per_testcase(_Case, Config) ->
+ Dog = ?config(watchdog, Config),
+ test_server:timetrap_cancel(Dog),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_HeuristicCommit'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_HeuristicCommit'(doc) -> ["CosTransactions_HeuristicCommit"];
+'CosTransactions_HeuristicCommit'(suite) -> [];
+'CosTransactions_HeuristicCommit'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_HeuristicCommit':tc())),
+ ?match("IDL:omg.org/CosTransactions/HeuristicCommit:1.0",
+ 'CosTransactions_HeuristicCommit':id()),
+ ?match("CosTransactions_HeuristicCommit",
+ 'CosTransactions_HeuristicCommit':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_HeuristicHazard'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_HeuristicHazard'(doc) -> ["CosTransactions_HeuristicHazard"];
+'CosTransactions_HeuristicHazard'(suite) -> [];
+'CosTransactions_HeuristicHazard'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_HeuristicHazard':tc())),
+ ?match("IDL:omg.org/CosTransactions/HeuristicHazard:1.0",
+ 'CosTransactions_HeuristicHazard':id()),
+ ?match("CosTransactions_HeuristicHazard",
+ 'CosTransactions_HeuristicHazard':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_HeuristicMixed'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_HeuristicMixed'(doc) -> ["CosTransactions_HeuristicMixed"];
+'CosTransactions_HeuristicMixed'(suite) -> [];
+'CosTransactions_HeuristicMixed'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_HeuristicMixed':tc())),
+ ?match("IDL:omg.org/CosTransactions/HeuristicMixed:1.0",
+ 'CosTransactions_HeuristicMixed':id()),
+ ?match("CosTransactions_HeuristicMixed",
+ 'CosTransactions_HeuristicMixed':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_HeuristicRollback'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_HeuristicRollback'(doc) -> ["CosTransactions_HeuristicRollback"];
+'CosTransactions_HeuristicRollback'(suite) -> [];
+'CosTransactions_HeuristicRollback'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_HeuristicRollback':tc())),
+ ?match("IDL:omg.org/CosTransactions/HeuristicRollback:1.0",
+ 'CosTransactions_HeuristicRollback':id()),
+ ?match("CosTransactions_HeuristicRollback",
+ 'CosTransactions_HeuristicRollback':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_Inactive'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_Inactive'(doc) -> ["CosTransactions_Inactive"];
+'CosTransactions_Inactive'(suite) -> [];
+'CosTransactions_Inactive'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_Inactive':tc())),
+ ?match("IDL:omg.org/CosTransactions/Inactive:1.0",
+ 'CosTransactions_Inactive':id()),
+ ?match("CosTransactions_Inactive",
+ 'CosTransactions_Inactive':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_InvalidControl'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_InvalidControl'(doc) -> ["CosTransactions_InvalidControl"];
+'CosTransactions_InvalidControl'(suite) -> [];
+'CosTransactions_InvalidControl'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_InvalidControl':tc())),
+ ?match("IDL:omg.org/CosTransactions/InvalidControl:1.0",
+ 'CosTransactions_InvalidControl':id()),
+ ?match("CosTransactions_InvalidControl",
+ 'CosTransactions_InvalidControl':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_NoTransaction'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_NoTransaction'(doc) -> ["CosTransactions_NoTransaction"];
+'CosTransactions_NoTransaction'(suite) -> [];
+'CosTransactions_NoTransaction'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_NoTransaction':tc())),
+ ?match("IDL:omg.org/CosTransactions/NoTransaction:1.0",
+ 'CosTransactions_NoTransaction':id()),
+ ?match("CosTransactions_NoTransaction",
+ 'CosTransactions_NoTransaction':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_NotPrepared'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_NotPrepared'(doc) -> ["CosTransactions_NotPrepared"];
+'CosTransactions_NotPrepared'(suite) -> [];
+'CosTransactions_NotPrepared'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_NotPrepared':tc())),
+ ?match("IDL:omg.org/CosTransactions/NotPrepared:1.0",
+ 'CosTransactions_NotPrepared':id()),
+ ?match("CosTransactions_NotPrepared",
+ 'CosTransactions_NotPrepared':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_NotSubtransaction'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_NotSubtransaction'(doc) -> ["CosTransactions_NotSubtransaction"];
+'CosTransactions_NotSubtransaction'(suite) -> [];
+'CosTransactions_NotSubtransaction'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_NotSubtransaction':tc())),
+ ?match("IDL:omg.org/CosTransactions/NotSubtransaction:1.0",
+ 'CosTransactions_NotSubtransaction':id()),
+ ?match("CosTransactions_NotSubtransaction",
+ 'CosTransactions_NotSubtransaction':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_SubtransactionsUnavailable'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_SubtransactionsUnavailable'(doc) -> ["CosTransactions_SubtransactionsUnavailable"];
+'CosTransactions_SubtransactionsUnavailable'(suite) -> [];
+'CosTransactions_SubtransactionsUnavailable'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_SubtransactionsUnavailable':tc())),
+ ?match("IDL:omg.org/CosTransactions/SubtransactionsUnavailable:1.0",
+ 'CosTransactions_SubtransactionsUnavailable':id()),
+ ?match("CosTransactions_SubtransactionsUnavailable",
+ 'CosTransactions_SubtransactionsUnavailable':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_Unavailable'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_Unavailable'(doc) -> ["CosTransactions_Unavailable"];
+'CosTransactions_Unavailable'(suite) -> [];
+'CosTransactions_Unavailable'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_Unavailable':tc())),
+ ?match("IDL:omg.org/CosTransactions/Unavailable:1.0",
+ 'CosTransactions_Unavailable':id()),
+ ?match("CosTransactions_Unavailable",
+ 'CosTransactions_Unavailable':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_SynchronizationUnavailable'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_SynchronizationUnavailable'(doc) -> ["CosTransactions_SynchronizationUnavailable"];
+'CosTransactions_SynchronizationUnavailable'(suite) -> [];
+'CosTransactions_SynchronizationUnavailable'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_SynchronizationUnavailable':tc())),
+ ?match("IDL:omg.org/CosTransactions/SynchronizationUnavailable:1.0",
+ 'CosTransactions_SynchronizationUnavailable':id()),
+ ?match("CosTransactions_SynchronizationUnavailable",
+ 'CosTransactions_SynchronizationUnavailable':name()),
+ ok.
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_TransIdentity'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_TransIdentity'(doc) -> ["CosTransactions_TransIdentity"];
+'CosTransactions_TransIdentity'(suite) -> [];
+'CosTransactions_TransIdentity'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_TransIdentity':tc())),
+ ?match("IDL:omg.org/CosTransactions/TransIdentity:1.0",
+ 'CosTransactions_TransIdentity':id()),
+ ?match("CosTransactions_TransIdentity",
+ 'CosTransactions_TransIdentity':name()),
+ ok.
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_PropagationContext'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_PropagationContext'(doc) -> ["CosTransactions_PropagationContext"];
+'CosTransactions_PropagationContext'(suite) -> [];
+'CosTransactions_PropagationContext'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_PropagationContext':tc())),
+ ?match("IDL:omg.org/CosTransactions/PropagationContext:1.0",
+ 'CosTransactions_PropagationContext':id()),
+ ?match("CosTransactions_PropagationContext",
+ 'CosTransactions_PropagationContext':name()),
+ ok.
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_otid_t'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_otid_t'(doc) -> ["CosTransactions_otid_t"];
+'CosTransactions_otid_t'(suite) -> [];
+'CosTransactions_otid_t'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_otid_t':tc())),
+ ?match("IDL:omg.org/CosTransactions/otid_t:1.0",
+ 'CosTransactions_otid_t':id()),
+ ?match("CosTransactions_otid_t",
+ 'CosTransactions_otid_t':name()),
+ ok.
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_WrongTransaction'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_WrongTransaction'(doc) -> ["CosTransactions_WrongTransaction"];
+'CosTransactions_WrongTransaction'(suite) -> [];
+'CosTransactions_WrongTransaction'(_) ->
+ ?match(true, orber_tc:check_tc('CosTransactions_WrongTransaction':tc())),
+ ?match("IDL:omg.org/CosTransactions/WrongTransaction:1.0",
+ 'CosTransactions_WrongTransaction':id()),
+ ?match("CosTransactions_WrongTransaction",
+ 'CosTransactions_WrongTransaction':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_Control'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_Control'(doc) -> ["CosTransactions_Control"];
+'CosTransactions_Control'(suite) -> [];
+'CosTransactions_Control'(_) ->
+ ?nomatch(undefined, 'CosTransactions_Control':oe_tc(get_terminator)),
+ ?nomatch(undefined, 'CosTransactions_Control':oe_tc(get_coordinator)),
+ ?match(undefined, 'CosTransactions_Control':oe_tc(undefined)),
+ ?match([_|_], 'CosTransactions_Control':oe_get_interface()),
+ ?match("IDL:omg.org/CosTransactions/Control:1.0",
+ 'CosTransactions_Control':typeID()),
+ check_tc('CosTransactions_Control':oe_get_interface()),
+ ?match(true, 'CosTransactions_Control':oe_is_a('CosTransactions_Control':typeID())),
+ ?match(false, 'CosTransactions_Control':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_Coordinator'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_Coordinator'(doc) -> ["CosTransactions_Coordinator"];
+'CosTransactions_Coordinator'(suite) -> [];
+'CosTransactions_Coordinator'(_) ->
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(get_status)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(get_parent_status)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(get_top_level_status)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(is_same_transaction)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(is_related_transaction)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(is_ancestor_transaction)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(is_descendant_transaction)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(is_top_level_transaction)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(hash_transaction)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(hash_top_level_tran)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(register_resource)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(register_subtran_aware)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(rollback_only)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(get_transaction_name)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(create_subtransaction)),
+ ?nomatch(undefined, 'CosTransactions_Coordinator':oe_tc(get_txcontext)),
+ ?match(undefined, 'CosTransactions_Coordinator':oe_tc(undefined)),
+ ?match([_|_], 'CosTransactions_Coordinator':oe_get_interface()),
+ ?match("IDL:omg.org/CosTransactions/Coordinator:1.0",
+ 'CosTransactions_Coordinator':typeID()),
+ check_tc('CosTransactions_Coordinator':oe_get_interface()),
+ ?match(true, 'CosTransactions_Coordinator':oe_is_a('CosTransactions_Coordinator':typeID())),
+ ?match(false, 'CosTransactions_Coordinator':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_RecoveryCoordinator'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_RecoveryCoordinator'(doc) -> ["CosTransactions_RecoveryCoordinator"];
+'CosTransactions_RecoveryCoordinator'(suite) -> [];
+'CosTransactions_RecoveryCoordinator'(_) ->
+ ?nomatch(undefined, 'CosTransactions_RecoveryCoordinator':oe_tc(replay_completion)),
+ ?match(undefined, 'CosTransactions_RecoveryCoordinator':oe_tc(undefined)),
+ ?match([_|_], 'CosTransactions_RecoveryCoordinator':oe_get_interface()),
+ ?match("IDL:omg.org/CosTransactions/RecoveryCoordinator:1.0",
+ 'CosTransactions_RecoveryCoordinator':typeID()),
+ check_tc('CosTransactions_RecoveryCoordinator':oe_get_interface()),
+ ?match(true, 'CosTransactions_RecoveryCoordinator':oe_is_a('CosTransactions_RecoveryCoordinator':typeID())),
+ ?match(false, 'CosTransactions_RecoveryCoordinator':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_Resource'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_Resource'(doc) -> ["CosTransactions_Resource"];
+'CosTransactions_Resource'(suite) -> [];
+'CosTransactions_Resource'(_) ->
+ ?nomatch(undefined, 'CosTransactions_Resource':oe_tc(prepare)),
+ ?nomatch(undefined, 'CosTransactions_Resource':oe_tc(rollback)),
+ ?nomatch(undefined, 'CosTransactions_Resource':oe_tc(commit)),
+ ?nomatch(undefined, 'CosTransactions_Resource':oe_tc(commit_one_phase)),
+ ?nomatch(undefined, 'CosTransactions_Resource':oe_tc(forget)),
+ ?match(undefined, 'CosTransactions_Resource':oe_tc(undefined)),
+ ?match([_|_], 'CosTransactions_Resource':oe_get_interface()),
+ ?match("IDL:omg.org/CosTransactions/Resource:1.0",
+ 'CosTransactions_Resource':typeID()),
+ check_tc('CosTransactions_Resource':oe_get_interface()),
+ ?match(true, 'CosTransactions_Resource':oe_is_a('CosTransactions_Resource':typeID())),
+ ?match(false, 'CosTransactions_Resource':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_SubtransactionAwareResource'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_SubtransactionAwareResource'(doc) -> ["CosTransactions_SubtransactionAwareResource"];
+'CosTransactions_SubtransactionAwareResource'(suite) -> [];
+'CosTransactions_SubtransactionAwareResource'(_) ->
+ ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(commit_subtransaction)),
+ ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(rollback_subtransaction)),
+ ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(prepare)),
+ ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(rollback)),
+ ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(commit)),
+ ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(commit_one_phase)),
+ ?nomatch(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(forget)),
+ ?match(undefined, 'CosTransactions_SubtransactionAwareResource':oe_tc(undefined)),
+ ?match([_|_], 'CosTransactions_SubtransactionAwareResource':oe_get_interface()),
+ ?match("IDL:omg.org/CosTransactions/SubtransactionAwareResource:1.0",
+ 'CosTransactions_SubtransactionAwareResource':typeID()),
+ check_tc('CosTransactions_SubtransactionAwareResource':oe_get_interface()),
+ ?match(true, 'CosTransactions_SubtransactionAwareResource':oe_is_a('CosTransactions_SubtransactionAwareResource':typeID())),
+ ?match(true, 'CosTransactions_SubtransactionAwareResource':oe_is_a('CosTransactions_Resource':typeID())),
+ ?match(false, 'CosTransactions_SubtransactionAwareResource':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_Terminator'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_Terminator'(doc) -> ["CosTransactions_Terminator"];
+'CosTransactions_Terminator'(suite) -> [];
+'CosTransactions_Terminator'(_) ->
+ ?nomatch(undefined, 'CosTransactions_Terminator':oe_tc(commit)),
+ ?nomatch(undefined, 'CosTransactions_Terminator':oe_tc(rollback)),
+ ?match(undefined, 'CosTransactions_Terminator':oe_tc(undefined)),
+ ?match([_|_], 'CosTransactions_Terminator':oe_get_interface()),
+ ?match("IDL:omg.org/CosTransactions/Terminator:1.0",
+ 'CosTransactions_Terminator':typeID()),
+ check_tc('CosTransactions_Terminator':oe_get_interface()),
+ ?match(true, 'CosTransactions_Terminator':oe_is_a('CosTransactions_Terminator':typeID())),
+ ?match(false, 'CosTransactions_Terminator':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTransactions_TransactionFactory'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTransactions_TransactionFactory'(doc) -> ["CosTransactions_TransactionFactory"];
+'CosTransactions_TransactionFactory'(suite) -> [];
+'CosTransactions_TransactionFactory'(_) ->
+ ?nomatch(undefined, 'CosTransactions_TransactionFactory':oe_tc(create)),
+ ?nomatch(undefined, 'CosTransactions_TransactionFactory':oe_tc(recreate)),
+ ?match(undefined, 'CosTransactions_TransactionFactory':oe_tc(undefined)),
+ ?match([_|_], 'CosTransactions_TransactionFactory':oe_get_interface()),
+ ?match("IDL:omg.org/CosTransactions/TransactionFactory:1.0",
+ 'CosTransactions_TransactionFactory':typeID()),
+ check_tc('CosTransactions_TransactionFactory':oe_get_interface()),
+ ?match(true, 'CosTransactions_TransactionFactory':oe_is_a('CosTransactions_TransactionFactory':typeID())),
+ ?match(false, 'CosTransactions_TransactionFactory':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'ETraP_Server'
+%% Description:
+%%-----------------------------------------------------------------
+'ETraP_Server'(doc) -> ["ETraP_Server"];
+'ETraP_Server'(suite) -> [];
+'ETraP_Server'(_) ->
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(get_status)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(get_parent_status)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(get_top_level_status)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(is_same_transaction)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(is_related_transaction)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(is_ancestor_transaction)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(is_descendant_transaction)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(is_top_level_transaction)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(hash_transaction)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(hash_top_level_tran)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(register_resource)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(register_subtran_aware)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(rollback_only)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(get_transaction_name)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(create_subtransaction)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(get_txcontext)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(prepare)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(rollback)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(commit)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(commit_one_phase)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(forget)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(replay_completion)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(get_terminator)),
+ ?nomatch(undefined, 'ETraP_Server':oe_tc(get_coordinator)),
+ ?match(undefined, 'ETraP_Server':oe_tc(undefined)),
+ ?match([_|_], 'ETraP_Server':oe_get_interface()),
+ ?match("IDL:omg.org/ETraP/Server:1.0",
+ 'ETraP_Server':typeID()),
+ check_tc('ETraP_Server':oe_get_interface()),
+ ?match(true, 'ETraP_Server':oe_is_a('ETraP_Server':typeID())),
+ ?match(true, 'ETraP_Server':oe_is_a('CosTransactions_Coordinator':typeID())),
+ ?match(true, 'ETraP_Server':oe_is_a('CosTransactions_Resource':typeID())),
+ ?match(true, 'ETraP_Server':oe_is_a('CosTransactions_RecoveryCoordinator':typeID())),
+ ?match(true, 'ETraP_Server':oe_is_a('CosTransactions_Control':typeID())),
+ ?match(false, 'ETraP_Server':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% MISC functions
+%%-----------------------------------------------------------------
+check_tc([]) ->
+ ok;
+check_tc([{Op, {RetType, InParameters, OutParameters}}|T]) ->
+ io:format("checked - ~s~n", [Op]),
+ lists:all(?checktc(Op), [RetType|InParameters]),
+ lists:all(?checktc(Op), OutParameters),
+ check_tc(T).
+
+
diff --git a/lib/cosTransactions/test/transactions_SUITE.erl b/lib/cosTransactions/test/transactions_SUITE.erl
new file mode 100644
index 0000000000..8385d5a0fb
--- /dev/null
+++ b/lib/cosTransactions/test/transactions_SUITE.erl
@@ -0,0 +1,395 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1999-2009. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+-module(transactions_SUITE).
+
+%%--------------- INCLUDES -----------------------------------
+-include_lib("orber/include/corba.hrl").
+-include_lib("orber/include/ifr_types.hrl").
+
+%% Local
+-include_lib("cosTransactions/src/ETraP_Common.hrl").
+-include_lib("cosTransactions/include/CosTransactions.hrl").
+-include("etrap_test_lib.hrl").
+
+-include("test_server.hrl").
+
+-define(default_timeout, ?t:minutes(20)).
+
+
+%%-----------------------------------------------------------------
+%% External exports
+%%-----------------------------------------------------------------
+-export([all/1, cases/0, init_all/1, finish_all/1, resource_api/1, etrap_api/1,
+ init_per_testcase/2, fin_per_testcase/2, app_test/1]).
+
+%%-----------------------------------------------------------------
+%% Func: all/1
+%% Args:
+%% Returns:
+%%-----------------------------------------------------------------
+all(doc) -> ["API tests for the cosTransactions interfaces", ""];
+all(suite) -> {req,
+ [mnesia, orber],
+ {conf, init_all, cases(), finish_all}}.
+
+cases() ->
+ [etrap_api, resource_api, app_test].
+
+
+
+%%-----------------------------------------------------------------
+%% Init and cleanup functions.
+%%-----------------------------------------------------------------
+
+init_per_testcase(_Case, Config) ->
+ Path = code:which(?MODULE),
+ code:add_pathz(filename:join(filename:dirname(Path), "idl_output")),
+ 'oe_CosTransactions':'oe_register'(),
+ 'oe_etrap_test':'oe_register'(),
+ ?line Dog=test_server:timetrap(?default_timeout),
+ [{watchdog, Dog}|Config].
+
+
+fin_per_testcase(_Case, Config) ->
+ 'oe_etrap_test':'oe_unregister'(),
+ 'oe_CosTransactions':'oe_unregister'(),
+ Path = code:which(?MODULE),
+ code:del_path(filename:join(filename:dirname(Path), "idl_output")),
+ Dog = ?config(watchdog, Config),
+ test_server:timetrap_cancel(Dog),
+ ok.
+
+init_all(Config) ->
+ mnesia:delete_schema([node()]),
+ mnesia:create_schema([node()]),
+ orber:install([node()]),
+ application:start(mnesia),
+ application:start(orber),
+ if
+ is_list(Config) ->
+ Config;
+ true ->
+ exit("Config not a list")
+ end.
+
+finish_all(Config) ->
+ application:stop(orber),
+ application:stop(mnesia),
+ mnesia:delete_schema([node()]),
+ Config.
+
+%%-----------------------------------------------------------------
+%% Tests app file
+%%-----------------------------------------------------------------
+app_test(doc) -> [];
+app_test(suite) -> [];
+app_test(_Config) ->
+ ok=test_server:app_test(cosTransactions),
+ ok.
+
+%%-----------------------------------------------------------------
+%% API tests
+%%-----------------------------------------------------------------
+etrap_api(doc) -> ["ETraP_Server tests", ""];
+etrap_api(suite) -> [];
+etrap_api(_Config) ->
+ ?line ?match(ok, application:start(cosTransactions),
+ "Starting the cosTransactions application"),
+ ?line TrFac = cosTransactions:start_factory(),
+ %% Start a new transaction:
+ %% RootCoord
+ %% / \
+ %% SubCoord1 SubCoord2
+ Control = 'CosTransactions_TransactionFactory':create(TrFac, 0),
+ Term = 'CosTransactions_Control':get_terminator(Control),
+ Coord = 'CosTransactions_Control':get_coordinator(Control),
+ SubCont1 = 'CosTransactions_Coordinator':create_subtransaction(Coord),
+ SubCont2 = 'CosTransactions_Coordinator':create_subtransaction(Coord),
+ SubCoord1 = 'CosTransactions_Control':get_coordinator(SubCont1),
+ SubCoord2 = 'CosTransactions_Control':get_coordinator(SubCont2),
+
+
+ %%------ Test CosTransactions::Coordinator ------
+ ?line ?match(true,
+ 'CosTransactions_Coordinator':is_same_transaction(Coord, Coord),
+ "'CosTransactions_Coordinator':is_same_transaction"),
+ ?line ?match(false,
+ 'CosTransactions_Coordinator':is_same_transaction(Coord, SubCoord1),
+ "'CosTransactions_Coordinator':is_same_transaction"),
+ ?line ?match(true,
+ 'CosTransactions_Coordinator':is_descendant_transaction(Coord, Coord),
+ "'CosTransactions_Coordinator':is_descendant_transaction"),
+ ?line ?match(false,
+ 'CosTransactions_Coordinator':is_descendant_transaction(Coord, SubCoord1),
+ "'CosTransactions_Coordinator':is_descendant_transaction"),
+ ?line ?match(true,
+ 'CosTransactions_Coordinator':is_descendant_transaction(SubCoord1, Coord),
+ "'CosTransactions_Coordinator':is_descendant_transaction"),
+ ?line ?match(false,
+ 'CosTransactions_Coordinator':is_descendant_transaction(SubCoord1, SubCoord2),
+ "'CosTransactions_Coordinator':is_descendant_transaction"),
+ ?line ?match(true,
+ 'CosTransactions_Coordinator':is_top_level_transaction(Coord),
+ "'CosTransactions_Coordinator':is_top_level_transaction"),
+ ?line ?match(false,
+ 'CosTransactions_Coordinator':is_top_level_transaction(SubCoord2),
+ "'CosTransactions_Coordinator':is_top_level_transaction"),
+
+ RootHash = 'CosTransactions_Coordinator':hash_transaction(Coord),
+ RepeatHash= 'CosTransactions_Coordinator':hash_transaction(Coord),
+ RootHash2 = 'CosTransactions_Coordinator':hash_top_level_tran(SubCoord1),
+ RootHash3 = 'CosTransactions_Coordinator':hash_top_level_tran(Coord),
+ _SubHash = 'CosTransactions_Coordinator':hash_transaction(SubCoord2),
+ ?line ?match(RootHash, RepeatHash,
+ "'CosTransactions_Coordinator':hash_transaction"),
+ ?line ?match(RootHash, RootHash2,
+ "'CosTransactions_Coordinator':hash_top_level_tran"),
+ ?line ?match(RootHash, RootHash3,
+ "'CosTransactions_Coordinator':hash_top_level_tran"),
+% ?line ?match_inverse(RootHash, SubHash,
+% "'CosTransactions_Coordinator':hash_transaction"),
+
+ ?line ?match('StatusActive',
+ 'CosTransactions_Coordinator':get_status(Coord),
+ "'CosTransactions_Coordinator':get_status"),
+ ?line ?match('StatusActive',
+ 'CosTransactions_Coordinator':get_status(SubCoord1),
+ "'CosTransactions_Coordinator':get_status"),
+ ?line ?match('StatusActive',
+ 'CosTransactions_Coordinator':get_parent_status(Coord),
+ "'CosTransactions_Coordinator':get_parent_status"),
+ ?line ?match('StatusActive',
+ 'CosTransactions_Coordinator':get_parent_status(SubCoord1),
+ "'CosTransactions_Coordinator':get_parent_status"),
+ ?line ?match('StatusActive',
+ 'CosTransactions_Coordinator':get_top_level_status(Coord),
+ "'CosTransactions_Coordinator':get_top_level_status"),
+ ?line ?match('StatusActive',
+ 'CosTransactions_Coordinator':get_top_level_status(SubCoord1),
+ "'CosTransactions_Coordinator':get_top_level_status"),
+
+ %% Create a CosTransactions::Resource to experiments with.
+ %% Start a new transaction:
+ %% RootCoord
+ %% / \
+ %% SubCoord1 SubCoord2
+ %% /
+ %% Resource
+ N1 = 'ETraP_Common':create_name("test"),
+ O1 = etrap_test_server:oe_create(?nop, {global, N1}),
+ _RC1 = 'CosTransactions_Coordinator':register_resource(SubCoord1, O1),
+% 'CosTransactions_Coordinator':register_synchronization(SubCoord1, O1),
+
+ ?line ?match('VoteCommit',
+ 'CosTransactions_Resource':prepare(SubCoord1),
+ "'CosTransactions_Coordinator':prepare"),
+ %% The Transaction are no longer in 'StatusActive' state. No new
+ %% "members" allowed.
+ ?line ?match('StatusPrepared',
+ 'CosTransactions_Coordinator':get_status(SubCoord1),
+ "'CosTransactions_Coordinator':get_status"),
+% ?line ?match({'EXCEPTION', ?tr_inactive},
+% 'CosTransactions_Coordinator':register_synchronization(SubCoord1, O1),
+% "'CosTransactions_Coordinator':register_synchronization"),
+ ?line ?match({'EXCEPTION', ?tr_inactive},
+ 'CosTransactions_Coordinator':register_resource(SubCoord1, O1),
+ "'CosTransactions_Coordinator':register_resource"),
+ ?line ?match({'EXCEPTION', ?tr_inactive},
+ 'CosTransactions_Coordinator':create_subtransaction(SubCoord1),
+ "'CosTransactions_Coordinator':create_subtransaction"),
+
+ catch corba:dispose(SubCoord1),
+ catch corba:dispose(SubCoord2),
+ catch corba:dispose(SubCont1),
+ catch corba:dispose(SubCont2),
+ catch corba:dispose(Term),
+ catch corba:dispose(Control),
+ catch corba:dispose(Coord),
+ catch corba:dispose(O1),
+
+ ?line cosTransactions:stop_factory(TrFac),
+ ?line application:stop(cosTransactions),
+ ok.
+
+%%-----------------------------------------------------------------
+%% API tests
+%%-----------------------------------------------------------------
+resource_api(doc) -> ["cosTransactions API tests", ""];
+resource_api(suite) -> [];
+resource_api(_Config) ->
+ ?line ?match(ok, application:start(cosTransactions),
+ "Starting the cosTransactions application"),
+ ?line TrFac = cosTransactions:start_factory([{typecheck, true}]),
+
+ ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}},
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?prepare_rollback}),
+ "TESTCASE #1: Prepare rollback Resource 4"),
+ ?line ?match({'EXCEPTION', ?tr_mixed},
+ run(TrFac, 0, {?nop, ?nop, ?commit_mix, ?nop}),
+ "TESTCASE #2: Heuristic Mixed exception Resource 3"),
+ ?line ?match(ok,
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?nop}),
+ "TESTCASE #3: Normal completion. No errors."),
+ ?line ?match(ok,
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?commit_cm}),
+ "TESTCASE #4: Heuristic Commit Exception Resource 4"),
+ ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}},
+ run(TrFac, 0, {?nop, ?rollback_rb, ?nop, ?prepare_rollback}),
+ "TESTCASE #5: Heuristic Rollbac Resource 2, Resource 4 reply 'VoteRollback'"),
+ ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}},
+ run(TrFac, 0, {?nop, ?nop, ?prepare_rollback, ?rollback_rb}),
+ "TESTCASE #6: Heuristic Rollbac Resource 4, Resource 3 reply 'VoteRollback'"),
+ ?line ?match(ok,
+ run(TrFac, 0, {?nop, ?nop, ?commit_delay, ?nop}),
+ "TESTCASE #7: Resource 3 delay during commit. No timeout."),
+ ?line ?match(ok,
+ run(TrFac, 0, {?nop, ?nop, ?prepare_delay, ?nop}),
+ "TESTCASE #8: Resource 3 delay during prepare. No timeout."),
+ ?line ?match(ok,
+ run(TrFac, ?TIMEOUT, {?nop, ?commit_delay, ?nop, ?nop}),
+ "TESTCASE #9: Resource 3 delay during commit. Timeout."),
+ ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}},
+ run(TrFac, ?TIMEOUT, {?nop, ?prepare_delay, ?nop, ?nop}),
+ "TESTCASE #10: Resource 3 delay during prepare. Timeout."),
+ case ?is_debug_compiled of
+ true ->
+ %% Testing the Coordinators (root and sub).
+ ?line ?match(ok,
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?nop,?crash_transient(commit), ?nop]}),
+ "TESTCASE #11: SubCoord 3 crash transient during commit."),
+ ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{}},
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?nop,?crash_transient(send_prepare), ?nop]}),
+ "TESTCASE #12: SubCoord 3 crash transient during send prepare."),
+ ?line ?match({'EXCEPTION', ?tr_hazard},
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?nop,?crash_permanent(commit), ?nop]}),
+ "TESTCASE #13: SubCoord 3 crash permanent during commit."),
+ ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{}},
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?nop,?crash_permanent(send_prepare), ?nop]}),
+ "TESTCASE #14: SubCoord 3 crash permanent during prepare."),
+ ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{}},
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?crash_transient(send_prepare), ?crash_transient(commit), ?nop]}),
+ "TESTCASE #15: SubCoord 2 crash transient during prepare. SubCoord 3 crash transient during commit"),
+ ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}},
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?crash_transient(send_prepare), ?nop, ?nop, ?nop]}),
+ "TESTCASE #16: RootCoord crash transient during send prepare."),
+ ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{}},
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?nop, [?nop, ?crash_transient(prepare1), ?nop, ?nop]}),
+ "TESTCASE #17: SubCoord 1 crash transient during prepare1."),
+ ?line ?match({'EXCEPTION', ?tr_mixed},
+ run(TrFac, 0, {?nop, ?prepare_mix, ?nop, ?nop, [?nop, ?nop, ?crash_transient(prepare2), ?nop]}),
+ "TESTCASE #18: SubCoord 3 crash transient during prepare2. Resource 2 raise Heuristic Mixed during prepare"),
+ ?line ?match({'EXCEPTION', ?tr_mixed},
+ run(TrFac, 0, {?nop, ?commit_mix, ?nop, ?nop, [?nop, ?nop, ?crash_transient(commit2), ?nop]}),
+ "TESTCASE #19: Resource 2 raise Heurist mixed during commit. SubCoord crash transient commit2"),
+ ?line ?match({'EXCEPTION', ?tr_mixed},
+ run(TrFac, 0, {?nop, ?rollback_cm, ?nop, ?prepare_rollback, [?nop, ?crash_transient(rollback2), ?nop, ?nop]}),
+ "TESTCASE #20: Resource 2 raise Heuristic Commit during rollback. Resource 4 'VoteRollback'. SubCoord 2 crash transient rollback2."),
+ ?line ?match({'EXCEPTION', ?tr_mixed},
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?commit_mix, [?nop, ?nop, ?crash_transient(send_forget1), ?nop]}),
+ "TESTCASE #21: Resource 4 raise Heuristic Mixed during commit. SubCoord 2 crash transient send_forget1."),
+ ?line ?match({'EXCEPTION', ?tr_mixed},
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?commit_mix, [?crash_transient(send_forget1), ?nop, ?nop, ?nop]}),
+ "TESTCASE #22: Resource 4 raise Heuristic Mixed during commit. Root Coord crash transient send_forget1."),
+ ?line ?match({'EXCEPTION', ?tr_mixed},
+ run(TrFac, 0, {?nop, ?nop, ?nop, ?commit_mix, [?crash_transient(send_forget3), ?nop, ?crash_transient(send_forget1), ?nop]}),
+ "TESTCASE #23: Resource 4 raise Heuristic Mixed during commit. Root Coord crash transient send_forget3. SubCoord 3 crash transient send_forget1."),
+ ?line ?match({'EXCEPTION', #'TRANSACTION_ROLLEDBACK'{completion_status=?COMPLETED_YES}},
+ run(TrFac, ?TIMEOUT, {?nop, ?nop, ?nop, ?nop, [?delay_transient(root_delay, ?TIMEOUT*2), ?nop, ?nop, ?nop]}),
+ "TESTCASE #24: Delay RootCoord. Timeout."),
+ %% Testing the Terminator.
+ ?line ?match({'EXCEPTION', ?tr_mixed},
+ run(TrFac, ?TIMEOUT, {?nop, ?prepare_mix, ?nop, ?nop, [?nop, ?nop, ?nop, ?crash_transient(commit_heuristic1)]}),
+ "TESTCASE #25: Terminator crash transient after received and logged Heuristic mix."),
+ ?line ?match(ok,
+ run(TrFac, ?TIMEOUT, {?nop, ?nop, ?nop, ?nop, [?nop, ?nop, ?nop, ?crash_transient(commit_ok2)]}),
+ "TESTCASE #26: Terminator crash transient after received and logged 'ok'.");
+ _ ->
+ ok
+ end,
+
+ ?line cosTransactions:stop_factory(TrFac),
+ ?line application:stop(cosTransactions),
+ ok.
+
+%%-----------------------------------------------------------------
+%% Internal functions
+%%-----------------------------------------------------------------
+
+run(TrFac, Time, Spec) ->
+ Control = 'CosTransactions_TransactionFactory':create(TrFac, Time),
+ Term = 'CosTransactions_Control':get_terminator(Control),
+ Coord = 'CosTransactions_Control':get_coordinator(Control),
+ SubCont1 = 'CosTransactions_Coordinator':create_subtransaction(Coord),
+ SubCont2 = 'CosTransactions_Coordinator':create_subtransaction(Coord),
+ SubCoord1 = 'CosTransactions_Control':get_coordinator(SubCont1),
+ SubCoord2 = 'CosTransactions_Control':get_coordinator(SubCont2),
+ %% Start resources/participants.
+ {O1, O2, O3, O4, Ctx} = start_resources(Spec),
+
+ %% Get generated names to use for debugging.
+ CoordN = 'CosTransactions_Coordinator':get_transaction_name(Coord),
+ SubC1N = 'CosTransactions_Coordinator':get_transaction_name(SubCoord1),
+ SubC2N = 'CosTransactions_Coordinator':get_transaction_name(SubCoord2),
+
+ ?set_debug_context([CoordN, SubC1N, SubC2N, Term], Ctx),
+
+ %% Register the resources as participants.
+ _RC1 = 'CosTransactions_Coordinator':register_resource(SubCoord1, O1),
+ _RC2 = 'CosTransactions_Coordinator':register_resource(SubCoord1, O2),
+ _RC3 = 'CosTransactions_Coordinator':register_resource(SubCoord2, O3),
+ _RC4 = 'CosTransactions_Coordinator':register_resource(SubCoord2, O4),
+
+ 'CosTransactions_Coordinator':register_subtran_aware(SubCoord1, O4),
+% 'CosTransactions_Coordinator':register_synchronization(SubCoord1, O2),
+
+% Reply = (catch 'CosTransactions_Terminator':commit(Term, true)),
+ Reply = (catch 'ETraP_Common':send_stubborn('CosTransactions_Terminator',
+ commit, [Term, true],
+ ?tr_max_retries,
+ ?tr_comm_failure_wait)),
+
+ catch corba:dispose(SubCoord1),
+ catch corba:dispose(SubCoord2),
+ catch corba:dispose(SubCont1),
+ catch corba:dispose(SubCont2),
+ catch corba:dispose(Term),
+ catch corba:dispose(Control),
+ catch corba:dispose(Coord),
+ catch corba:dispose(O1),
+ catch corba:dispose(O2),
+ catch corba:dispose(O3),
+ catch corba:dispose(O4),
+ Reply.
+
+
+
+start_resources({A1, A2, A3, A4})->
+ start_resources({A1, A2, A3, A4, ?no_context});
+start_resources({A1, A2, A3, A4, Ctx})->
+ N1 = 'ETraP_Common':create_name("test"),
+ N2 = 'ETraP_Common':create_name("test"),
+ N3 = 'ETraP_Common':create_name("test"),
+ N4 = 'ETraP_Common':create_name("test"),
+ {_,_,O1} = supervisor:start_child(?SUPERVISOR_NAME, ?SUP_TEST(A1, N1)),
+ {_,_,O2} = supervisor:start_child(?SUPERVISOR_NAME, ?SUP_TEST(A2, N2)),
+% {_,_,O2} = supervisor:start_child(?SUPERVISOR_NAME, ?SUP_TEST([{sync,true}|A2], N2)),
+ {_,_,O3} = supervisor:start_child(?SUPERVISOR_NAME, ?SUP_TEST(A3, N3)),
+ {_,_,O4} = supervisor:start_child(?SUPERVISOR_NAME, ?SUP_TEST(A4, N4)),
+ {O1, O2, O3, O4, Ctx}.