From a0c65862e8beaca2d2c0b9d6d13eca862641994c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 19 Sep 2012 15:55:53 +0200 Subject: common_test: Don't use undocumented features of io:format() The Format string argument for io:format() is not documented to accept an iolist, so we should not depend on it. Also, it is bad practice to use an arbitrary string as a format string for io:format(), since it could contain a '~' character which could trigger a badarg exception. Fix both problems at the same time by using io:put_chars() to display the iolist. --- lib/common_test/src/ct_master.erl | 5 +++-- lib/common_test/src/ct_master_logs.erl | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/common_test/src') diff --git a/lib/common_test/src/ct_master.erl b/lib/common_test/src/ct_master.erl index 042c5ba267..99bec3ea09 100644 --- a/lib/common_test/src/ct_master.erl +++ b/lib/common_test/src/ct_master.erl @@ -696,8 +696,9 @@ status(MasterPid,Event) -> log(To,Heading,Str,Args) -> if To == all ; To == tty -> - Str1 = ["=== ",Heading," ===\n",io_lib:format(Str,Args),"\n"], - io:format(Str1,[]); + Chars = ["=== ",Heading," ===\n", + io_lib:format(Str,Args),"\n"], + io:put_chars(Chars); true -> ok end, diff --git a/lib/common_test/src/ct_master_logs.erl b/lib/common_test/src/ct_master_logs.erl index 9e61d5b16f..1e65337241 100644 --- a/lib/common_test/src/ct_master_logs.erl +++ b/lib/common_test/src/ct_master_logs.erl @@ -204,7 +204,7 @@ open_ct_master_log(Dir) -> {ok,Fd} = file:open(FullName,[write]), io:format(Fd,header("Common Test Master Log", {[],[1,2],[]}),[]), %% maybe add config info here later - io:format(Fd, config_table([]), []), + io:put_chars(config_table([])), io:format(Fd, "\n", - []), - io:format(Fd, - xhtml("

Progress Log

\n
\n",
-		    "

Progress Log

\n
\n"),
-	      []),
+    io:put_chars(Fd,
+		 "\n"),
+    io:put_chars(Fd, 
+		 xhtml("

Progress Log

\n
\n",
+		       "

Progress Log

\n
\n")),
     Fd.
 
 close_ct_master_log(Fd) ->
-    io:format(Fd,"
",[]), - io:format(Fd,footer(),[]), + io:put_chars(Fd,["
",footer()]), file:close(Fd). config_table(Vars) -> @@ -248,7 +245,7 @@ int_footer() -> open_nodedir_index(Dir,StartTime) -> FullName = filename:join(Dir,?nodedir_index_name), {ok,Fd} = file:open(FullName,[write]), - io:format(Fd,nodedir_index_header(StartTime),[]), + io:put_chars(Fd,nodedir_index_header(StartTime)), Fd. print_nodedir(Node,RunDir,Fd) -> @@ -261,7 +258,7 @@ print_nodedir(Node,RunDir,Fd) -> ok. close_nodedir_index(Fd) -> - io:format(Fd,index_footer(),[]), + io:put_chars(Fd,index_footer()), file:close(Fd). nodedir_index_header(StartTime) -> -- cgit v1.2.3