aboutsummaryrefslogtreecommitdiffstats
path: root/lib/cosTime
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cosTime')
-rw-r--r--lib/cosTime/test/Makefile135
-rw-r--r--lib/cosTime/test/cosTime.spec19
-rw-r--r--lib/cosTime/test/generated_SUITE.erl288
-rw-r--r--lib/cosTime/test/time_SUITE.erl295
4 files changed, 737 insertions, 0 deletions
diff --git a/lib/cosTime/test/Makefile b/lib/cosTime/test/Makefile
new file mode 100644
index 0000000000..fde5c4facc
--- /dev/null
+++ b/lib/cosTime/test/Makefile
@@ -0,0 +1,135 @@
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 2000-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
+
+# ----------------------------------------------------
+# Application version
+# ----------------------------------------------------
+include ../vsn.mk
+VSN=$(COSTIME_VSN)
+# ----------------------------------------------------
+# Release directory specification
+# ----------------------------------------------------
+RELSYSDIR = $(RELEASE_PATH)/cosTime_test
+
+# ----------------------------------------------------
+# Target Specs
+# ----------------------------------------------------
+TEST_SPEC_FILE = cosTime.spec
+
+
+IDL_FILES =
+
+IDLOUTDIR = idl_output
+
+MODULES = \
+ time_SUITE \
+ generated_SUITE
+
+GEN_MODULES = \
+
+GEN_HRL_FILES = \
+
+ERL_FILES = $(MODULES:%=%.erl)
+
+HRL_FILES =
+
+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/cosTime/priv:$(ERL_TOP)lib/cosTime/test
+# ----------------------------------------------------
+# FLAGS
+# ----------------------------------------------------
+ERL_IDL_FLAGS += -pa $(ERL_TOP)/lib/cosTime/ebin \
+ -pa $(ERL_TOP)/lib/cosTime/src \
+ -pa $(ERL_TOP)/lib/cosTime/include \
+ -pa $(ERL_TOP)/lib/cosNotification/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/cosNotification/include \
+ -pa $(ERL_TOP)/internal_tools/test_server/ebin \
+ -pa $(ERL_TOP)/lib/cosTime/ebin \
+ -pa $(ERL_TOP)/lib/cosTime/include \
+ -pa $(ERL_TOP)/lib/cosTime/test/idl_output \
+ -I$(ERL_TOP)/lib/orber/include \
+ -I$(ERL_TOP)/lib/cosNotification/include \
+ -I$(ERL_TOP)/lib/cosTime/src \
+ -I$(ERL_TOP)/lib/cosTime/include \
+ -I$(ERL_TOP)/lib/cosTime \
+ -I$(ERL_TOP)/lib/cosTime/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 *~
+
+docs:
+
+# ----------------------------------------------------
+# Special Targets
+# ----------------------------------------------------
+
+# ----------------------------------------------------
+# 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) $(RELSYSDIR)
+ $(INSTALL_DATA) $(SUITE_TARGET_FILES) $(RELSYSDIR)
+# $(INSTALL_DIR) $(RELSYSDIR)/$(IDLOUTDIR)
+# $(INSTALL_DATA) $(GEN_TARGET_FILES) $(GEN_FILES) \
+# $(RELSYSDIR)/$(IDLOUTDIR)
+
diff --git a/lib/cosTime/test/cosTime.spec b/lib/cosTime/test/cosTime.spec
new file mode 100644
index 0000000000..3f50946043
--- /dev/null
+++ b/lib/cosTime/test/cosTime.spec
@@ -0,0 +1,19 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2000-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, "../cosTime_test"}}.
diff --git a/lib/cosTime/test/generated_SUITE.erl b/lib/cosTime/test/generated_SUITE.erl
new file mode 100644
index 0000000000..3a2153528f
--- /dev/null
+++ b/lib/cosTime/test/generated_SUITE.erl
@@ -0,0 +1,288 @@
+%%-----------------------------------------------------------------
+%%
+%% %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 :
+%%-----------------------------------------------------------------
+
+-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) ->
+ ['TimeBase_IntervalT', 'TimeBase_UtcT', 'CosTime_TimeUnavailable',
+ 'CosTimerEvent_TimerEventT', 'CosTime_TIO', 'CosTime_TimeService',
+ 'CosTime_UTO', 'CosTimerEvent_TimerEventHandler',
+ 'CosTimerEvent_TimerEventService'].
+
+%%-----------------------------------------------------------------
+%% 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: 'TimeBase_IntervalT'
+%% Description:
+%%-----------------------------------------------------------------
+'TimeBase_IntervalT'(doc) -> ["TimeBase_IntervalT"];
+'TimeBase_IntervalT'(suite) -> [];
+'TimeBase_IntervalT'(_) ->
+ ?match(true, orber_tc:check_tc('TimeBase_IntervalT':tc())),
+ ?match("IDL:omg.org/TimeBase/IntervalT:1.0",
+ 'TimeBase_IntervalT':id()),
+ ?match("TimeBase_IntervalT",
+ 'TimeBase_IntervalT':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'TimeBase_UtcT'
+%% Description:
+%%-----------------------------------------------------------------
+'TimeBase_UtcT'(doc) -> ["TimeBase_UtcT"];
+'TimeBase_UtcT'(suite) -> [];
+'TimeBase_UtcT'(_) ->
+ ?match(true, orber_tc:check_tc('TimeBase_UtcT':tc())),
+ ?match("IDL:omg.org/TimeBase/UtcT:1.0",
+ 'TimeBase_UtcT':id()),
+ ?match("TimeBase_UtcT",
+ 'TimeBase_UtcT':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTime_TimeUnavailable'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTime_TimeUnavailable'(doc) -> ["CosTime_TimeUnavailable"];
+'CosTime_TimeUnavailable'(suite) -> [];
+'CosTime_TimeUnavailable'(_) ->
+ ?match(true, orber_tc:check_tc('CosTime_TimeUnavailable':tc())),
+ ?match("IDL:omg.org/CosTime/TimeUnavailable:1.0",
+ 'CosTime_TimeUnavailable':id()),
+ ?match("CosTime_TimeUnavailable",
+ 'CosTime_TimeUnavailable':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTimerEvent_TimerEventT'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTimerEvent_TimerEventT'(doc) -> ["CosTimerEvent_TimerEventT"];
+'CosTimerEvent_TimerEventT'(suite) -> [];
+'CosTimerEvent_TimerEventT'(_) ->
+ ?match(true, orber_tc:check_tc('CosTimerEvent_TimerEventT':tc())),
+ ?match("IDL:omg.org/CosTimerEvent/TimerEventT:1.0",
+ 'CosTimerEvent_TimerEventT':id()),
+ ?match("CosTimerEvent_TimerEventT",
+ 'CosTimerEvent_TimerEventT':name()),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTime_TIO'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTime_TIO'(doc) -> ["CosTime_TIO"];
+'CosTime_TIO'(suite) -> [];
+'CosTime_TIO'(_) ->
+ ?nomatch(undefined, 'CosTime_TIO':oe_tc('_get_time_interval')),
+ ?nomatch(undefined, 'CosTime_TIO':oe_tc(spans)),
+ ?nomatch(undefined, 'CosTime_TIO':oe_tc(overlaps)),
+ ?nomatch(undefined, 'CosTime_TIO':oe_tc(time)),
+ ?match(undefined, 'CosTime_TIO':oe_tc(undefined)),
+ ?match([_|_], 'CosTime_TIO':oe_get_interface()),
+ ?match("IDL:omg.org/CosTime/TIO:1.0", 'CosTime_TIO':typeID()),
+ check_tc('CosTime_TIO':oe_get_interface()),
+ ?match(true, 'CosTime_TIO':oe_is_a('CosTime_TIO':typeID())),
+ ?match(false, 'CosTime_TIO':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTime_TimeService'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTime_TimeService'(doc) -> ["CosTime_TimeService"];
+'CosTime_TimeService'(suite) -> [];
+'CosTime_TimeService'(_) ->
+ ?nomatch(undefined, 'CosTime_TimeService':oe_tc(universal_time)),
+ ?nomatch(undefined, 'CosTime_TimeService':oe_tc(secure_universal_time)),
+ ?nomatch(undefined, 'CosTime_TimeService':oe_tc(new_universal_time)),
+ ?nomatch(undefined, 'CosTime_TimeService':oe_tc(uto_from_utc)),
+ ?nomatch(undefined, 'CosTime_TimeService':oe_tc(new_interval)),
+ ?match(undefined, 'CosTime_TimeService':oe_tc(undefined)),
+ ?match([_|_], 'CosTime_TimeService':oe_get_interface()),
+ ?match("IDL:omg.org/CosTime/TimeService:1.0",
+ 'CosTime_TimeService':typeID()),
+ check_tc('CosTime_TimeService':oe_get_interface()),
+ ?match(true, 'CosTime_TimeService':oe_is_a('CosTime_TimeService':typeID())),
+ ?match(false, 'CosTime_TimeService':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTime_UTO'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTime_UTO'(doc) -> ["CosTime_UTO"];
+'CosTime_UTO'(suite) -> [];
+'CosTime_UTO'(_) ->
+ ?nomatch(undefined, 'CosTime_UTO':oe_tc('_get_time')),
+ ?nomatch(undefined, 'CosTime_UTO':oe_tc('_get_inaccuracy')),
+ ?nomatch(undefined, 'CosTime_UTO':oe_tc('_get_tdf')),
+ ?nomatch(undefined, 'CosTime_UTO':oe_tc('_get_utc_time')),
+ ?nomatch(undefined, 'CosTime_UTO':oe_tc(absolute_time)),
+ ?nomatch(undefined, 'CosTime_UTO':oe_tc(compare_time)),
+ ?nomatch(undefined, 'CosTime_UTO':oe_tc(time_to_interval)),
+ ?nomatch(undefined, 'CosTime_UTO':oe_tc(interval)),
+ ?match(undefined, 'CosTime_UTO':oe_tc(undefined)),
+ ?match([_|_], 'CosTime_UTO':oe_get_interface()),
+ ?match("IDL:omg.org/CosTime/UTO:1.0", 'CosTime_UTO':typeID()),
+ check_tc('CosTime_UTO':oe_get_interface()),
+ ?match(true, 'CosTime_UTO':oe_is_a('CosTime_UTO':typeID())),
+ ?match(false, 'CosTime_UTO':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTimerEvent_TimerEventHandler'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTimerEvent_TimerEventHandler'(doc) -> ["CosTimerEvent_TimerEventHandler"];
+'CosTimerEvent_TimerEventHandler'(suite) -> [];
+'CosTimerEvent_TimerEventHandler'(_) ->
+ ?nomatch(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc('_get_status')),
+ ?nomatch(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc(time_set)),
+ ?nomatch(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc(set_timer)),
+ ?nomatch(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc(cancel_timer)),
+ ?nomatch(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc(set_data)),
+ ?match(undefined, 'CosTimerEvent_TimerEventHandler':oe_tc(undefined)),
+ ?match([_|_], 'CosTimerEvent_TimerEventHandler':oe_get_interface()),
+ ?match("IDL:omg.org/CosTimerEvent/TimerEventHandler:1.0",
+ 'CosTimerEvent_TimerEventHandler':typeID()),
+ check_tc('CosTimerEvent_TimerEventHandler':oe_get_interface()),
+ ?match(true, 'CosTimerEvent_TimerEventHandler':oe_is_a('CosTimerEvent_TimerEventHandler':typeID())),
+ ?match(false, 'CosTimerEvent_TimerEventHandler':oe_is_a("wrong")),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% Test Case: 'CosTimerEvent_TimerEventService'
+%% Description:
+%%-----------------------------------------------------------------
+'CosTimerEvent_TimerEventService'(doc) -> ["CosTimerEvent_TimerEventService"];
+'CosTimerEvent_TimerEventService'(suite) -> [];
+'CosTimerEvent_TimerEventService'(_) ->
+ ?nomatch(undefined, 'CosTimerEvent_TimerEventService':oe_tc(register)),
+ ?nomatch(undefined, 'CosTimerEvent_TimerEventService':oe_tc(unregister)),
+ ?nomatch(undefined, 'CosTimerEvent_TimerEventService':oe_tc(event_time)),
+ ?match(undefined, 'CosTimerEvent_TimerEventService':oe_tc(undefined)),
+ ?match([_|_], 'CosTimerEvent_TimerEventService':oe_get_interface()),
+ ?match("IDL:omg.org/CosTimerEvent/TimerEventService:1.0",
+ 'CosTimerEvent_TimerEventService':typeID()),
+ check_tc('CosTimerEvent_TimerEventService':oe_get_interface()),
+ ?match(true, 'CosTimerEvent_TimerEventService':oe_is_a('CosTimerEvent_TimerEventService':typeID())),
+ ?match(false, 'CosTimerEvent_TimerEventService':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/cosTime/test/time_SUITE.erl b/lib/cosTime/test/time_SUITE.erl
new file mode 100644
index 0000000000..bb00395885
--- /dev/null
+++ b/lib/cosTime/test/time_SUITE.erl
@@ -0,0 +1,295 @@
+%%--------------------------------------------------------------------
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2000-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 : time_SUITE.erl
+%% Purpose :
+%%----------------------------------------------------------------------
+
+-module(time_SUITE).
+
+
+%%--------------- INCLUDES -----------------------------------
+-include("../src/cosTimeApp.hrl").
+
+-include("test_server.hrl").
+
+%%--------------- DEFINES ------------------------------------
+-define(default_timeout, ?t:minutes(20)).
+-define(match(ExpectedRes, Expr),
+ fun() ->
+ AcTuAlReS = (catch (Expr)),
+ case AcTuAlReS of
+ ExpectedRes ->
+ io:format("------ CORRECT RESULT ------~n~p~n",
+ [AcTuAlReS]),
+ AcTuAlReS;
+ _ ->
+ io:format("###### ERROR ERROR ######~n~p~n",
+ [AcTuAlReS]),
+ exit(AcTuAlReS)
+ end
+ end()).
+
+-define(match_inverse(NotExpectedRes, Expr),
+ fun() ->
+ AcTuAlReS = (catch (Expr)),
+ case AcTuAlReS of
+ NotExpectedRes ->
+ io:format("###### ERROR ERROR ######~n ~p~n",
+ [AcTuAlReS]),
+ exit(AcTuAlReS);
+ _ ->
+ io:format("------ CORRECT RESULT ------~n~p~n",
+ [AcTuAlReS]),
+ AcTuAlReS
+ end
+ end()).
+
+
+%%-----------------------------------------------------------------
+%% External exports
+%%-----------------------------------------------------------------
+-export([all/1, cases/0, init_all/1, finish_all/1, time_api/1, timerevent_api/1,
+ init_per_testcase/2, fin_per_testcase/2,
+ app_test/1]).
+
+%%-----------------------------------------------------------------
+%% Func: all/1
+%% Args:
+%% Returns:
+%%-----------------------------------------------------------------
+all(doc) -> ["API tests for the cosTime interfaces", ""];
+all(suite) -> {req,
+ [mnesia, orber],
+ {conf, init_all, cases(), finish_all}}.
+
+cases() ->
+ [time_api, timerevent_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")),
+ ?line Dog=test_server:timetrap(?default_timeout),
+ [{watchdog, Dog}|Config].
+
+
+fin_per_testcase(_Case, Config) ->
+ 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) ->
+ Path = code:which(?MODULE),
+ code:add_pathz(filename:join(filename:dirname(Path), "idl_output")),
+ mnesia:delete_schema([node()]),
+ mnesia:create_schema([node()]),
+ orber:install([node()]),
+ application:start(mnesia),
+ application:start(orber),
+ cosNotificationApp:install_event(),
+ cosNotificationApp:install(),
+ cosTime:install_time(),
+ cosTime:install_timerevent(),
+ if
+ is_list(Config) ->
+ Config;
+ true ->
+ exit("Config not a list")
+ end.
+
+finish_all(Config) ->
+ Path = code:which(?MODULE),
+ code:del_path(filename:join(filename:dirname(Path), "idl_output")),
+ cosTime:uninstall_time(),
+ cosTime:uninstall_timerevent(),
+ cosNotificationApp:uninstall(),
+ cosNotificationApp:uninstall_event(),
+ 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(cosTime),
+ ok.
+
+%%-----------------------------------------------------------------
+%% CosTime API tests
+%%-----------------------------------------------------------------
+time_api(doc) -> ["CosTime API tests.", ""];
+time_api(suite) -> [];
+time_api(_Config) ->
+ ?line ?match(ok, application:start(cosTime)),
+ TS=cosTime:start_time_service(0, 500),
+ Time=calendar:datetime_to_gregorian_seconds({{1582,1,1},{0,0,0}}),
+ Inaccuracy = 1000,
+ Tdf =1,
+ Utc = #'TimeBase_UtcT'{time=Time, inacclo = ?low_TimeT(Inaccuracy),
+ inacchi = ?high_TimeT(Inaccuracy), tdf = Tdf},
+ ?line UTO1='CosTime_TimeService':new_universal_time(TS, Time, Inaccuracy, Tdf),
+ ?line UTO2='CosTime_TimeService':uto_from_utc(TS, Utc),
+ ?line ?match(Time, 'CosTime_UTO':'_get_time'(UTO1)),
+ ?line ?match(Inaccuracy, 'CosTime_UTO':'_get_inaccuracy'(UTO1)),
+ ?line ?match(Tdf, 'CosTime_UTO':'_get_tdf'(UTO1)),
+ ?line ?match(Utc, 'CosTime_UTO':'_get_utc_time'(UTO1)),
+
+ ?line ?match(Time, 'CosTime_UTO':'_get_time'(UTO2)),
+ ?line ?match(Inaccuracy, 'CosTime_UTO':'_get_inaccuracy'(UTO2)),
+ ?line ?match(Tdf, 'CosTime_UTO':'_get_tdf'(UTO2)),
+ ?line ?match(Utc, 'CosTime_UTO':'_get_utc_time'(UTO2)),
+
+ TIO1='CosTime_TimeService':new_interval(TS, 2, 5),
+ _TIO2='CosTime_TimeService':new_interval(TS, 3, 6),
+ TIO3='CosTime_TimeService':new_interval(TS, 1, 3),
+ TIO4='CosTime_TimeService':new_interval(TS, 3, 4),
+ TIO5='CosTime_TimeService':new_interval(TS, 7, 8),
+ TIO6='CosTime_TimeService':new_interval(TS, 2, 6),
+ TIO7='CosTime_TimeService':new_interval(TS, 3, 7),
+
+ ?line {_,TIO8} = ?match({'OTContained', _}, 'CosTime_TIO':overlaps(TIO1, TIO6)),
+ ?line {_,TIO9} = ?match({'OTContainer', _}, 'CosTime_TIO':overlaps(TIO1, TIO1)),
+ ?line {_,TIO10} = ?match({'OTContainer', _}, 'CosTime_TIO':overlaps(TIO1, TIO4)),
+ ?line {_,TIO11} = ?match({'OTOverlap', _}, 'CosTime_TIO':overlaps(TIO1, TIO3)),
+ ?line {_,TIO12} = ?match({'OTOverlap', _}, 'CosTime_TIO':overlaps(TIO1, TIO7)),
+ ?line {_,TIO13} = ?match({'OTNoOverlap', _}, 'CosTime_TIO':overlaps(TIO1, TIO5)),
+
+ ?line ?match({'TimeBase_IntervalT',2,5},'CosTime_TIO':'_get_time_interval'(TIO8)),
+ ?line ?match({'TimeBase_IntervalT',2,5},'CosTime_TIO':'_get_time_interval'(TIO9)),
+ ?line ?match({'TimeBase_IntervalT',3,4},'CosTime_TIO':'_get_time_interval'(TIO10)),
+ ?line ?match({'TimeBase_IntervalT',2,3},'CosTime_TIO':'_get_time_interval'(TIO11)),
+ ?line ?match({'TimeBase_IntervalT',3,5},'CosTime_TIO':'_get_time_interval'(TIO12)),
+ ?line ?match({'TimeBase_IntervalT',5,7},'CosTime_TIO':'_get_time_interval'(TIO13)),
+
+ ?line UTO3='CosTime_TimeService':new_universal_time(TS, 4, 2, 0), %% 2-6
+ ?line UTO4='CosTime_TimeService':new_universal_time(TS, 2, 1, 0), %% 1-3
+ ?line UTO5='CosTime_TimeService':new_universal_time(TS, 3, 0, 0), %% 3-3
+ ?line UTO6='CosTime_TimeService':new_universal_time(TS, 9, 1, 0), %% 8-10
+ ?line UTO7='CosTime_TimeService':new_universal_time(TS, 4, 3, 0), %% 1-7
+ ?line UTO8='CosTime_TimeService':new_universal_time(TS, 5, 2, 0), %% 3-7
+
+ ?line {_,TIO14} = ?match({'OTContained', _}, 'CosTime_TIO':spans(TIO1, UTO7)),
+ ?line {_,TIO15} = ?match({'OTContainer', _}, 'CosTime_TIO':spans(TIO1, UTO5)),
+ ?line {_,TIO16} = ?match({'OTOverlap', _}, 'CosTime_TIO':spans(TIO1, UTO4)),
+ ?line {_,TIO17} = ?match({'OTOverlap', _}, 'CosTime_TIO':spans(TIO1, UTO8)),
+ ?line {_,TIO18} = ?match({'OTNoOverlap', _}, 'CosTime_TIO':spans(TIO1, UTO6)),
+ ?line {_,TIO19} = ?match({'OTContained', _}, 'CosTime_TIO':spans(TIO1, UTO3)),
+
+ ?line ?match({'TimeBase_IntervalT',2,5},'CosTime_TIO':'_get_time_interval'(TIO14)),
+ ?line ?match({'TimeBase_IntervalT',3,3},'CosTime_TIO':'_get_time_interval'(TIO15)),
+ ?line ?match({'TimeBase_IntervalT',2,3},'CosTime_TIO':'_get_time_interval'(TIO16)),
+ ?line ?match({'TimeBase_IntervalT',3,5},'CosTime_TIO':'_get_time_interval'(TIO17)),
+ ?line ?match({'TimeBase_IntervalT',5,8},'CosTime_TIO':'_get_time_interval'(TIO18)),
+ ?line ?match({'TimeBase_IntervalT',2,5},'CosTime_TIO':'_get_time_interval'(TIO19)),
+
+
+ cosTime:stop_time_service(TS),
+ application:stop(cosTime),
+ ok.
+
+
+%%-----------------------------------------------------------------
+%% CosTimerEvent API tests
+%%-----------------------------------------------------------------
+timerevent_api(doc) -> ["CosTimerEvent API tests.", ""];
+timerevent_api(suite) -> [];
+timerevent_api(_Config) ->
+ %% Init cosTime apps.
+ ?line ?match(ok, application:start(cosTime)),
+ ?line TS=cosTime:start_time_service(0, 500),
+ ?line TES=cosTime:start_timerevent_service(TS),
+
+ %%----- Initialize the cosNotification application. -----
+ ?line cosNotificationApp:start(),
+ ?line Fac = (catch cosNotificationApp:start_factory([])),
+ ?line {Ch, _Id1} = (catch 'CosNotifyChannelAdmin_EventChannelFactory':create_channel(Fac, [], [])),
+ %% Create the Admin objects
+ ?line {AdminSupplier, _ASID}= ?match({{_,key,_,_,_,_},_},
+ 'CosNotifyChannelAdmin_EventChannel':new_for_suppliers(Ch,'OR_OP')),
+ ?line {AdminConsumer, _ACID}= ?match({{_,key,_,_,_,_},_},
+ 'CosNotifyChannelAdmin_EventChannel':new_for_consumers(Ch,'OR_OP')),
+
+ %% Create a push consumer TimerEventService will push events to.
+ ?line {ProxyPushConsumer,_ID10}= ?match({{_,key,_,_,_,_},_},
+ 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(AdminSupplier, 'ANY_EVENT')),
+
+ %% Create a pull suppliers so we can check we actually got the event.
+ ?line {ProxyPullSupplier,_ID1} = ?match({{_,key,_,_,_,_},_},
+ 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(AdminConsumer, 'ANY_EVENT')),
+
+ AnyEvent = any:create(orber_tc:long(), 100),
+ ?line UTO=?match({_,pseudo,_,_,_,_}, 'CosTime_TimeService':new_universal_time(TS, 10*10000000,1,1)),
+ ?line EH=?match({_,key,_,_,_,_}, 'CosTimerEvent_TimerEventService':register(TES, ProxyPushConsumer, AnyEvent)),
+
+ ?line ?match('ESTimeCleared','CosTimerEvent_TimerEventHandler':'_get_status'(EH)),
+ ?line ?match({false,_},'CosTimerEvent_TimerEventHandler':time_set(EH)),
+ ?line ?match(ok,'CosTimerEvent_TimerEventHandler':set_timer(EH, 'TTRelative', UTO)),
+ ?line ?match({true,_},'CosTimerEvent_TimerEventHandler':time_set(EH)),
+ ?line ?match('ESTimeSet','CosTimerEvent_TimerEventHandler':'_get_status'(EH)),
+
+ ?line ?match({{any,tk_null,null}, false},
+ 'CosNotifyChannelAdmin_ProxyPullSupplier':try_pull(ProxyPullSupplier)),
+
+ ?line ?match(AnyEvent, 'CosNotifyChannelAdmin_ProxyPullSupplier':pull(ProxyPullSupplier)),
+ ?line ?match('ESTriggered','CosTimerEvent_TimerEventHandler':'_get_status'(EH)),
+
+ %% It's allowed to send an UTO with time eq. to 0 if the server is TTRelative.
+ %% When TTAbsolute BAD_PARAM is raised.
+ ?line UTO2=?match({_,pseudo,_,_,_,_}, 'CosTime_TimeService':new_universal_time(TS, 0,1,1)),
+ ?line ?match({'EXCEPTION',_},'CosTimerEvent_TimerEventHandler':set_timer(EH, 'TTAbsolute', UTO2)),
+ ?line ?match(ok,'CosTimerEvent_TimerEventHandler':set_timer(EH, 'TTRelative', UTO2)),
+ ?line ?match(AnyEvent, 'CosNotifyChannelAdmin_ProxyPullSupplier':pull(ProxyPullSupplier)),
+
+ %% TTPeriodic is defined to be relative, i.e., we can use the tactic as above.
+ ?line ?match(ok,'CosTimerEvent_TimerEventHandler':set_timer(EH, 'TTPeriodic', UTO2)),
+
+ %% Sleep for UTO*2+4 secs. At this point the Timer should have delivered 2 events.
+ timer:sleep(24000),
+ %% Cancel the timer so no more events will be delivered.
+ ?line ?match(true,'CosTimerEvent_TimerEventHandler':cancel_timer(EH)),
+
+ ?line ?match({AnyEvent, true}, 'CosNotifyChannelAdmin_ProxyPullSupplier':try_pull(ProxyPullSupplier)),
+ ?line ?match({AnyEvent, true}, 'CosNotifyChannelAdmin_ProxyPullSupplier':try_pull(ProxyPullSupplier)),
+ ?line ?match({{any,tk_null,null}, false},
+ 'CosNotifyChannelAdmin_ProxyPullSupplier':try_pull(ProxyPullSupplier)),
+
+
+
+ %% Clean up.
+ cosNotificationApp:stop(),
+ cosTime:stop_timerevent_service(TES),
+ cosTime:stop_time_service(TS),
+ application:stop(cosTime),
+ ok.
+
+