From 0df8de4fa21d650b3f2795e3aa6d29952e4b08de Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 23 Jan 2013 14:44:21 +0100 Subject: [common_test] Update common test modules to handle unicode * Use UTF-8 encoding for all HTML files, except the HTML version of the test suite generated with erl2html2:convert, which will have the same encoding as the original test suite (.erl) file. * Encode link targets in HTML files with test_server_ctrl:uri_encode/1. * Use unicode modifier 't' with ~s when appropriate. * Use unicode:characters_to_list and unicode:characters_to_binary for conversion between binaries and strings instead of binary_to_list and list_to_binary. --- lib/common_test/src/ct_master_logs.erl | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'lib/common_test/src/ct_master_logs.erl') diff --git a/lib/common_test/src/ct_master_logs.erl b/lib/common_test/src/ct_master_logs.erl index 84f175c0a9..5393097f57 100644 --- a/lib/common_test/src/ct_master_logs.erl +++ b/lib/common_test/src/ct_master_logs.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2006-2012. All Rights Reserved. +%% Copyright Ericsson AB 2006-2013. 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 @@ -133,7 +133,7 @@ init(Parent,LogDir,Nodes) -> end,Nodes)), io:format(CtLogFd,int_header(),[log_timestamp(now()),"Test Nodes\n"]), - io:format(CtLogFd,"~s\n",[NodeStr]), + io:format(CtLogFd,"~ts\n",[NodeStr]), io:put_chars(CtLogFd,[int_footer(),"\n"]), NodeDirIxFd = open_nodedir_index(RunDirAbs,Time), @@ -201,7 +201,7 @@ loop(State) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%% open_ct_master_log(Dir) -> FullName = filename:join(Dir,?ct_master_log_name), - {ok,Fd} = file:open(FullName,[write]), + {ok,Fd} = file:open(FullName,[write,{encoding,utf8}]), io:put_chars(Fd,header("Common Test Master Log", {[],[1,2],[]})), %% maybe add config info here later io:put_chars(Fd,config_table([])), @@ -235,7 +235,7 @@ config_table1([]) -> ["\n\n"]. int_header() -> - "
*** CT MASTER ~s *** ~s". + "
*** CT MASTER ~s *** ~ts". int_footer() -> "
". @@ -244,7 +244,7 @@ int_footer() -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% open_nodedir_index(Dir,StartTime) -> FullName = filename:join(Dir,?nodedir_index_name), - {ok,Fd} = file:open(FullName,[write]), + {ok,Fd} = file:open(FullName,[write,{encoding,utf8}]), io:put_chars(Fd,nodedir_index_header(StartTime)), Fd. @@ -253,7 +253,8 @@ print_nodedir(Node,RunDir,Fd) -> io:put_chars(Fd, ["\n" "",atom_to_list(Node),"\n", - "",Index,"\n", + "",Index, + "\n", "\n"]), ok. @@ -283,7 +284,9 @@ make_all_runs_index(LogDir) -> DirsSorted = (catch sort_all_runs(Dirs)), Header = all_runs_header(), Index = [runentry(Dir) || Dir <- DirsSorted], - Result = file:write_file(FullName,Header++Index++index_footer()), + Result = file:write_file(FullName, + unicode:characters_to_binary( + Header++Index++index_footer())), Result. sort_all_runs(Dirs) -> @@ -323,7 +326,8 @@ runentry(Dir) -> end, Index = filename:join(Dir,?nodedir_index_name), ["\n" - "",timestamp(Dir),"\n", + "", + timestamp(Dir),"\n", "",MasterStr,"\n", "",NodesStr,"\n", "\n"]. @@ -381,8 +385,10 @@ header(Title, TableCols) -> "\n", "" ++ Title ++ "\n", "\n", + "\n", xhtml("", - [""]), + [""]), xhtml("", ["\n"]), -- cgit v1.2.3