From afbd6fa341f89211697a3c3f59f888b8247aa7f4 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Thu, 1 Jul 2010 15:46:13 +0200 Subject: Add textured backgound to html log files The overview html log files now have a textured background. This default new look can be switched off with the 'basic_html' option. --- lib/common_test/Makefile | 6 ++-- lib/common_test/priv/Makefile.in | 20 +++++------ lib/common_test/priv/tile1.jpg | Bin 0 -> 34734 bytes lib/common_test/src/ct_framework.erl | 30 ++++++++++++++++ lib/common_test/src/ct_logs.erl | 68 +++++++++++++++++++++-------------- lib/common_test/src/ct_testspec.erl | 2 ++ lib/common_test/src/ct_util.erl | 9 ++++- 7 files changed, 94 insertions(+), 41 deletions(-) create mode 100644 lib/common_test/priv/tile1.jpg (limited to 'lib/common_test') diff --git a/lib/common_test/Makefile b/lib/common_test/Makefile index e16efd0c9d..aecec1a50d 100644 --- a/lib/common_test/Makefile +++ b/lib/common_test/Makefile @@ -25,12 +25,12 @@ include $(ERL_TOP)/make/$(TARGET)/otp.mk # ifeq ($(findstring linux,$(TARGET)),linux) -SUB_DIRECTORIES = doc/src src +SUB_DIRECTORIES = doc/src src priv else ifeq ($(findstring solaris,$(TARGET)),solaris) -SUB_DIRECTORIES = doc/src src +SUB_DIRECTORIES = doc/src src priv else -SUB_DIRECTORIES = doc/src src +SUB_DIRECTORIES = doc/src src priv endif endif diff --git a/lib/common_test/priv/Makefile.in b/lib/common_test/priv/Makefile.in index f144847a29..6372bbc8d5 100644 --- a/lib/common_test/priv/Makefile.in +++ b/lib/common_test/priv/Makefile.in @@ -56,8 +56,9 @@ ifneq ($(findstring win32,$(TARGET)),win32) # # Files # -FILES = vts.tool run_test.in -SCRIPTS = install.sh +FILES = +SCRIPTS = +IMAGES = tile1.jpg # # Rules @@ -83,14 +84,12 @@ include $(ERL_TOP)/make/otp_release_targets.mk ifeq ($(XNIX),true) release_spec: opt - $(INSTALL_DIR) $(RELSYSDIR)/priv/bin - $(INSTALL_SCRIPT) $(SCRIPTS) $(RELSYSDIR) - $(INSTALL_DATA) $(FILES) $(RELSYSDIR)/priv + $(INSTALL_DIR) $(RELSYSDIR)/priv + $(INSTALL_DATA) $(FILES) $(IMAGES) $(RELSYSDIR)/priv else release_spec: opt - $(INSTALL_DIR) $(RELSYSDIR)/priv/bin - $(INSTALL_SCRIPT) $(SCRIPTS) $(RELSYSDIR) - $(INSTALL_DATA) $(FILES) $(RELSYSDIR)/priv + $(INSTALL_DIR) $(RELSYSDIR)/priv + $(INSTALL_DATA) $(FILES) $(IMAGES) $(RELSYSDIR)/priv endif release_docs_spec: @@ -105,6 +104,7 @@ else # Files # FILES = vts.tool +IMAGES = tile1.jpg # # Rules @@ -123,8 +123,8 @@ clean: include $(ERL_TOP)/make/otp_release_targets.mk release_spec: opt - $(INSTALL_DIR) $(RELSYSDIR)/priv/bin - $(INSTALL_DATA) $(FILES) $(RELSYSDIR)/priv + $(INSTALL_DIR) $(RELSYSDIR)/priv + $(INSTALL_DATA) $(FILES) $(IMAGES) $(RELSYSDIR)/priv release_docs_spec: diff --git a/lib/common_test/priv/tile1.jpg b/lib/common_test/priv/tile1.jpg new file mode 100644 index 0000000000..8749383716 Binary files /dev/null and b/lib/common_test/priv/tile1.jpg differ diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index 1c8a14574f..17215e5eb5 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -27,6 +27,8 @@ -export([init_tc/3, end_tc/3, get_suite/2, report/2, warn/1]). -export([error_notification/4]). +-export([overview_html_header/1]). + -export([error_in_suite/1, ct_init_per_group/2, ct_end_per_group/2]). -export([make_all_conf/3, make_conf/5]). @@ -1218,4 +1220,32 @@ add_data_dir(File,Config) when is_list(File) -> File end. +%%%----------------------------------------------------------------- +%%% @spec overview_html_header(TestName) -> Header +overview_html_header(TestName) -> + TestName1 = lists:flatten(io_lib:format("~p", [TestName])), + Label = case application:get_env(common_test, test_label) of + {ok,Lbl} when Lbl =/= undefined -> + "

" ++ Lbl ++ "

\n"; + _ -> + "" + end, + Bgr = case ct_logs:basic_html() of + true -> + ""; + false -> + CTPath = ct_util:get_ct_root(), + TileFile = filename:join(filename:join(filename:join(CTPath), + "priv"),"tile1.jpg"), + " background=\"" ++ TileFile ++ "\"" + end, + + ["\n", + "Test ", TestName1, " results\n", + "\n", + "\n", + "\n", + Label, + "

Results from test ", TestName1, "

\n"]. diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl index bb859d3b72..004d0d2540 100644 --- a/lib/common_test/src/ct_logs.erl +++ b/lib/common_test/src/ct_logs.erl @@ -36,7 +36,8 @@ -export([make_all_suites_index/1,make_all_runs_index/1]). %% Logging stuff directly from testcase --export([tc_log/3,tc_print/3,tc_pal/3]). +-export([tc_log/3,tc_print/3,tc_pal/3, + basic_html/0]). %% Simulate logger process for use without ct environment running -export([simulate/0]). @@ -57,7 +58,7 @@ -define(table_color2,"#E4F0FE"). -define(table_color3,"#F0F8FF"). --define(testname_width, 55). +-define(testname_width, 60). -define(abs(Name), filename:absname(Name)). @@ -808,7 +809,7 @@ make_one_index_entry1(SuiteName, Link, Label, Success, Fail, UserSkip, AutoSkip, false -> "" end, - {Timestamp,Node,AllInfo} = + {Lbl,Timestamp,Node,AllInfo} = case All of {true,OldRuns} -> [_Prefix,NodeOrDate|_] = string:tokens(Link,"."), @@ -816,20 +817,21 @@ make_one_index_entry1(SuiteName, Link, Label, Success, Fail, UserSkip, AutoSkip, 0 -> "-"; _ -> NodeOrDate end, - N = ["",Node1,"\n"], + N = ["",Node1,"\n"], CtRunDir = filename:dirname(filename:dirname(Link)), - T = ["",timestamp(CtRunDir),"\n"], + L = ["",Label,"\n"], + T = ["",timestamp(CtRunDir),"\n"], CtLogFile = filename:join(CtRunDir,?ct_log_name), OldRunsLink = case OldRuns of [] -> "none"; _ -> "Old Runs" end, - A=["CT Log\n", - "",OldRunsLink,"\n"], - {T,N,A}; + A=["CT Log\n", + "",OldRunsLink,"\n"], + {L,T,N,A}; false -> - {"","",""} + {"","","",""} end, NotBuiltStr = if NotBuilt == 0 -> @@ -856,8 +858,8 @@ make_one_index_entry1(SuiteName, Link, Label, Success, Fail, UserSkip, AutoSkip, {UserSkip+AutoSkip,integer_to_list(UserSkip),ASStr} end, ["\n", - "",SuiteName,"",CrashDumpLink,"\n", - Label, + "",SuiteName,"",CrashDumpLink,"\n", + Lbl, Timestamp, "",integer_to_list(Success),"\n", "",FailStr,"\n", @@ -868,12 +870,14 @@ make_one_index_entry1(SuiteName, Link, Label, Success, Fail, UserSkip, AutoSkip, AllInfo, "\n"]. total_row(Success, Fail, UserSkip, AutoSkip, NotBuilt, All) -> - {TimestampCell,AllInfo} = + {Label,TimestampCell,AllInfo} = case All of - true -> - {" \n"," \n \n"}; + true -> + {" \n", + " \n", + " \n \n"}; false -> - {"",""} + {"","",""} end, {AllSkip,UserSkipStr,AutoSkipStr} = @@ -883,6 +887,7 @@ total_row(Success, Fail, UserSkip, AutoSkip, NotBuilt, All) -> end, ["\n", "Total", + Label, TimestampCell, "",integer_to_list(Success),"\n", "",integer_to_list(Fail),"\n", @@ -1047,19 +1052,28 @@ index_footer() -> footer() -> ["

\n" - "
\n" - "

\n" - "Copyright © ", year(), - " Open Telecom Platform
\n" - "Updated: ", current_time(), "
\n" - "
\n" - "

\n" - "\n"]. + "

\n" + "
\n" + "

\n" + "Copyright © ", year(), + " Open Telecom Platform
\n" + "Updated: ", current_time(), "
\n" + "
\n" + "\n" + "\n"]. body_tag() -> - "\n". + case basic_html() of + true -> + "\n"; + false -> + CTPath = ct_util:get_ct_root(), + TileFile = filename:join(filename:join(filename:join(CTPath),"priv"),"tile1.jpg"), + "\n" + end. current_time() -> format_time(calendar:local_time()). @@ -1297,7 +1311,7 @@ runentry(Dir, BasicHtml) -> end, Total = TotSucc+TotFail+AllSkip, A = ["",Node,"\n", - "",Label,"\n", + "",Label,"\n", "",NoOfTests,"\n"], B = if BasicHtml -> ["",TestNamesTrunc,"\n"]; @@ -1318,7 +1332,7 @@ runentry(Dir, BasicHtml) -> end, Index = filename:join(Dir,?index_name), ["\n" - "",timestamp(Dir),"",TotalsStr,"\n" + "",timestamp(Dir),"",TotalsStr,"\n" "\n"]. write_totals_file(Name,Label,Logs,Totals) -> diff --git a/lib/common_test/src/ct_testspec.erl b/lib/common_test/src/ct_testspec.erl index 100e33a940..1ca60dc92c 100644 --- a/lib/common_test/src/ct_testspec.erl +++ b/lib/common_test/src/ct_testspec.erl @@ -1045,6 +1045,8 @@ valid_terms() -> {alias,3}, {logdir,2}, {logdir,3}, + {label,2}, + {label,3}, {event_handler,2}, {event_handler,3}, {event_handler,4}, diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index eddaf4c8b9..86e1482eb0 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -45,7 +45,7 @@ -export([get_mode/0, create_table/3, read_opts/0]). --export([set_cwd/1, reset_cwd/0]). +-export([set_cwd/1, reset_cwd/0, get_ct_root/0]). -export([parse_table/1]). @@ -619,6 +619,13 @@ get_testdir(Dir, Suite) when is_list(Suite) -> get_testdir(Dir, _) -> get_testdir(Dir, all). +%%%----------------------------------------------------------------- +%%% @spec +%%% +%%% @doc +get_ct_root() -> + [_Ebin|CTPath] = lists:reverse(filename:split(filename:dirname(code:which(?MODULE)))), + lists:reverse(CTPath). %%%----------------------------------------------------------------- %%% @spec -- cgit v1.2.3