diff options
author | Peter Andersson <peppe@erlang.org> | 2012-08-23 17:23:08 +0200 |
---|---|---|
committer | Peter Andersson <peppe@erlang.org> | 2012-08-23 17:23:08 +0200 |
commit | c9b4ce74e68d25b762a22facdbfe8ab1b078815a (patch) | |
tree | a551663d2db938586272f0dbf6d2a86bab7f6f56 /lib/common_test/src | |
parent | ada34eeaa3e7f034a3c69ccc95e1bcf2226cb7eb (diff) | |
download | otp-c9b4ce74e68d25b762a22facdbfe8ab1b078815a.tar.gz otp-c9b4ce74e68d25b762a22facdbfe8ab1b078815a.tar.bz2 otp-c9b4ce74e68d25b762a22facdbfe8ab1b078815a.zip |
Fix IO bug causing CT Hooks to hang at startup
Diffstat (limited to 'lib/common_test/src')
-rw-r--r-- | lib/common_test/src/ct_logs.erl | 31 | ||||
-rw-r--r-- | lib/common_test/src/ct_run.erl | 6 | ||||
-rw-r--r-- | lib/common_test/src/ct_util.erl | 12 |
3 files changed, 31 insertions, 18 deletions
diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl index 4b01532863..0b7a8bb075 100644 --- a/lib/common_test/src/ct_logs.erl +++ b/lib/common_test/src/ct_logs.erl @@ -241,7 +241,7 @@ end_tc(TCPid) -> %%% activity it is. <code>Format</code> and <code>Args</code> is the %%% data to log (as in <code>io:format(Format,Args)</code>).</p> log(Heading,Format,Args) -> - cast({log,sync,self(),group_leader(), + cast({log,sync,self(),group_leader(),ct_internal,?MAX_IMPORTANCE, [{int_header(),[log_timestamp(now()),Heading]}, {Format,Args}, {int_footer(),[]}]}), @@ -263,7 +263,7 @@ log(Heading,Format,Args) -> %%% @see cont_log/2 %%% @see end_log/0 start_log(Heading) -> - cast({log,sync,self(),group_leader(), + cast({log,sync,self(),group_leader(),ct_internal,?MAX_IMPORTANCE, [{int_header(),[log_timestamp(now()),Heading]}]}), ok. @@ -278,7 +278,8 @@ cont_log([],[]) -> ok; cont_log(Format,Args) -> maybe_log_timestamp(), - cast({log,sync,self(),group_leader(),[{Format,Args}]}), + cast({log,sync,self(),group_leader(),ct_internal,?MAX_IMPORTANCE, + [{Format,Args}]}), ok. %%%----------------------------------------------------------------- @@ -289,7 +290,8 @@ cont_log(Format,Args) -> %%% @see start_log/1 %%% @see cont_log/2 end_log() -> - cast({log,sync,self(),group_leader(),[{int_footer(), []}]}), + cast({log,sync,self(),group_leader(),ct_internal,?MAX_IMPORTANCE, + [{int_footer(), []}]}), ok. @@ -397,6 +399,8 @@ tc_print(Category,Importance,Format,Args) -> VLvl = case ct_util:get_testdata({verbosity,Category}) of undefined -> ct_util:get_testdata({verbosity,'$unspecified'}); + {error,bad_invocation} -> + ?MAX_VERBOSITY; Val -> Val end, @@ -484,7 +488,7 @@ maybe_log_timestamp() -> {MS,S,_} -> ok; _ -> - cast({log,sync,self(),group_leader(), + cast({log,sync,self(),group_leader(),ct_internal,?MAX_IMPORTANCE, [{"<i>~s</i>",[log_timestamp({MS,S,US})]}]}) end. @@ -619,10 +623,15 @@ copy_priv_files([], []) -> logger_loop(State) -> receive {log,SyncOrAsync,Pid,GL,Category,Importance,List} -> - VLvl = case get({verbosity,Category}) of - undefined -> get({verbosity,'$unspecified'}); - Val -> Val - end, + VLvl = case Category of + ct_internal -> + ?MAX_VERBOSITY; + _ -> + case get({verbosity,Category}) of + undefined -> get({verbosity,'$unspecified'}); + Val -> Val + end + end, if Importance >= (100-VLvl) -> case get_groupleader(Pid, GL, State) of {tc_log,TCGL,TCGLs} -> @@ -754,7 +763,7 @@ print_to_log(async, FromPid, TCGL, List, State) -> true -> State#logger_state.ct_log_fd end, Printer = fun() -> - test_server:permit_io(TCGL, self()), + test_server:permit_io(IoProc, self()), io:format(IoProc, "~s", [lists:foldl(IoFun, [], List)]) end, case State#logger_state.async_print_jobs of @@ -2105,7 +2114,7 @@ simulate() -> simulate_logger_loop() -> receive - {log,_,_,_,List} -> + {log,_,_,_,_,_,List} -> S = [[io_lib:format(Str,Args),io_lib:nl()] || {Str,Args} <- List], io:format("~s",[S]), simulate_logger_loop(); diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl index 1dbd9973cf..a202ca15e2 100644 --- a/lib/common_test/src/ct_run.erl +++ b/lib/common_test/src/ct_run.erl @@ -1114,7 +1114,7 @@ run_spec_file(Relaxed, end. run_prepared(Run, Skip, Opts = #opts{logdir = LogDir, - config = CfgFiles }, + config = CfgFiles}, StartOpts) -> LogDir1 = which(logdir, LogDir), case check_and_install_configfiles(CfgFiles, LogDir1, Opts) of @@ -1619,7 +1619,8 @@ do_run(Tests, Skip, Opts, Args) when is_record(Opts, opts) -> "run ct:start_interactive()\n\n",[]), {error,interactive_mode}; _Pid -> - compile_and_run(Tests, Skip, Opts1, Args) + compile_and_run(Tests, Skip, + Opts1#opts{verbosity=Verbosity}, Args) end end. @@ -1786,7 +1787,6 @@ verify_suites(TestSuites) -> Beam = filename:join(TestDir, atom_to_list(Suite)++ ".beam"), - case filelib:is_regular(Beam) of true -> {[DS|Found],NotFound}; diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index 95072ebf58..efc85543ac 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -858,13 +858,17 @@ call(Msg) -> call(Msg, infinity). call(Msg, Timeout) -> - case whereis(ct_util_server) of - undefined -> + case {self(),whereis(ct_util_server)} of + {_,undefined} -> {error,ct_util_server_not_running}; - Pid -> + {Pid,Pid} -> + %% the caller is ct_util_server, which must + %% be a mistake + {error,bad_invocation}; + {Self,Pid} -> MRef = erlang:monitor(process, Pid), Ref = make_ref(), - ct_util_server ! {Msg,{self(),Ref}}, + ct_util_server ! {Msg,{Self,Ref}}, receive {Ref, Result} -> erlang:demonitor(MRef, [flush]), |