diff options
author | HÃ¥kan Mattsson <[email protected]> | 2010-02-03 08:59:06 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-02-03 08:59:06 +0000 |
commit | 43f3482adf5eee657e5ba922733dfff6600c4e14 (patch) | |
tree | 7ea7b32a171de1a7690102c403a8a946e8a382a8 /lib/et/test/ett.erl | |
parent | 768da5a5f6312496b9b8a09cca5ea1d6b89a2c1c (diff) | |
download | otp-43f3482adf5eee657e5ba922733dfff6600c4e14.tar.gz otp-43f3482adf5eee657e5ba922733dfff6600c4e14.tar.bz2 otp-43f3482adf5eee657e5ba922733dfff6600c4e14.zip |
OTP-8058 The GUI parts are rewritten to use wxWidgets. Thanks Olle
Mattsson!
For the time being it is still possible to use the old GS based
version of the tool, but it is deprecated. The wxWidgets based
version is started by default.
A new tutorial has been added to the documentation. It is based
on Jayson Vantuyl's article
http://souja.net/2009/04/making-sense-of-erlangs-event-tracer.htm
l.
The functions et:trace_me/4 and et:trace_me/5 has been introduced
in order to replace the deprecated functions et:report_event/4
and et:report_event/5. Hopefully the new names makes it a little
more obvious what the intended usage of the functions are.
A print function has been added to the GUI, in order to enable
printing of sequence charts.
More functionality for hiding unwanted events has been added to
the GUI.
The max_events, hide_unknown and display_mode configuration
parameters to et_viewer is not used any more. Now the event cache
in the Viewer only contains those events that actually are
displayed in the GUI.
Diffstat (limited to 'lib/et/test/ett.erl')
-rw-r--r-- | lib/et/test/ett.erl | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/lib/et/test/ett.erl b/lib/et/test/ett.erl new file mode 100644 index 0000000000..1896e65842 --- /dev/null +++ b/lib/et/test/ett.erl @@ -0,0 +1,154 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2009-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(ett). +-compile(export_all). + +%% Modules or suites can be shortcuts, for example wx expands to et_wx_SUITE. +%% +%% t(Tests) run et testcases. +%% Tests can be module, {module, test_case} or [module|{module,test_case}] + +t() -> + t(read_test_case()). +t(Test) -> + t(Test, []). + +t(Mod, TC) when is_atom(Mod), is_atom(TC) -> + t({Mod,TC}, []); +t(all, Config) when is_list(Config) -> + Fs = filelib:wildcard("et_*_SUITE.erl"), + t([list_to_atom(filename:rootname(File)) || File <- Fs], Config); +t(Test,Config) when is_list(Config) -> + Tests = resolve(Test), + write_test_case(Test), + Res = et_test_lib:run_test(Tests, Config), + append_test_case_info(Test, Res). + +user() -> + user(read_test_case()). +user(Mod) -> + t(Mod, [{user,step}]). +user(Mod,Tc) when is_atom(Tc) -> + t({Mod,Tc}, [{user,step}]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Resolves the name of test suites and test cases +%% according to the alias definitions. Single atoms +%% are assumed to be the name of a test suite. + +resolve(Suite0) when is_atom(Suite0) -> + case alias(Suite0) of + Suite when is_atom(Suite) -> + {Suite, all}; + {Suite, Case} -> + {Suite, Case} + end; +resolve({Suite0, Case}) when is_atom(Suite0), is_atom(Case) -> + case alias(Suite0) of + Suite when is_atom(Suite) -> + {Suite, Case}; + {Suite, Case2} -> + {Suite, Case2} + end; +resolve(List) when is_list(List) -> + [resolve(Case) || Case <- List]. + +alias(Suite) when is_atom(Suite) -> + Str = atom_to_list(Suite), + case {Str, lists:reverse(Str)} of + {"et" ++ _, "ETIUS" ++ _} -> + Suite; + _ -> + list_to_atom("et_" ++ Str ++ "_SUITE") + end. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +config_fname() -> + "et_test_case_config". + +%% Read default config file +read_config() -> + Fname = config_fname(), + et_test_lib:log("Consulting file ~s...~n", [Fname]), + case file:consult(Fname) of + {ok, Config} -> + et_test_lib:log("Read config ~w~n", [Config]), + Config; + _Error -> + Config = et_test_lib:default_config(), + et_test_lib:log("<>WARNING<> Using default config: ~w~n", [Config]), + Config + end. + +%% Write new default config file +write_config(Config) when is_list(Config) -> + Fname = config_fname(), + {ok, Fd} = file:open(Fname, write), + write_list(Fd, Config), + file:close(Fd). + +write_list(Fd, [H | T]) -> + ok = io:format(Fd, "~p.~n",[H]), + write_list(Fd, T); +write_list(_, []) -> + ok. + +test_case_fname() -> + "et_test_case_info". + +%% Read name of test case +read_test_case() -> + Fname = test_case_fname(), + case file:open(Fname, [read]) of + {ok, Fd} -> + Res = io:read(Fd, []), + file:close(Fd), + case Res of + {ok, TestCase} -> + et_test_lib:log("Using test case ~w from file ~s~n", + [TestCase, Fname]), + TestCase; + {error, _} -> + default_test_case(Fname) + end; + {error, _} -> + default_test_case(Fname) + end. + +default_test_case(Fname) -> + TestCase = all, + et_test_lib:log("<>WARNING<> Cannot read file ~s, " + "using default test case: ~w~n", + [Fname, TestCase]), + TestCase. + +write_test_case(TestCase) -> + Fname = test_case_fname(), + {ok, Fd} = file:open(Fname, write), + ok = io:format(Fd, "~p.~n",[TestCase]), + file:close(Fd). + +append_test_case_info(TestCase, TestCaseInfo) -> + Fname = test_case_fname(), + {ok, Fd} = file:open(Fname, [read, write]), + ok = io:format(Fd, "~p.~n",[TestCase]), + ok = io:format(Fd, "~p.~n",[TestCaseInfo]), + file:close(Fd), + TestCaseInfo. |