From ce61065fbef0cc634e656bb1eb926c42023c9201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 22 Oct 2012 12:24:04 +0200 Subject: Test ct:capture/start/stop/get --- lib/common_test/test/ct_group_leader_SUITE.erl | 6 ++++ .../group_leader_SUITE.erl | 33 ++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/common_test/test/ct_group_leader_SUITE.erl b/lib/common_test/test/ct_group_leader_SUITE.erl index 5f40eba826..cde3061d6a 100644 --- a/lib/common_test/test/ct_group_leader_SUITE.erl +++ b/lib/common_test/test/ct_group_leader_SUITE.erl @@ -170,6 +170,12 @@ events_to_check(_Test) -> {?eh,tc_done,{group_leader_SUITE,s5,ok}}], {?eh,tc_start,{group_leader_SUITE,p13}}, {?eh,tc_done,{group_leader_SUITE,p13,ok}} ]}, + {?eh,tc_done,{group_leader_SUITE,cap1,ok}}, + {?eh,tc_done,{group_leader_SUITE,cap2,ok}}, + {parallel,[{?eh,tc_start,{group_leader_SUITE,cap1}}, + {?eh,tc_done,{group_leader_SUITE,cap1,ok}}, + {?eh,tc_start,{group_leader_SUITE,cap2}}, + {?eh,tc_done,{group_leader_SUITE,cap2,ok}}]}, {?eh,test_done,{'DEF','STOP_TIME'}}, {?eh,stop_logging,[]} ]. diff --git a/lib/common_test/test/ct_group_leader_SUITE_data/group_leader_SUITE.erl b/lib/common_test/test/ct_group_leader_SUITE_data/group_leader_SUITE.erl index c405a82882..3f1844b4ae 100644 --- a/lib/common_test/test/ct_group_leader_SUITE_data/group_leader_SUITE.erl +++ b/lib/common_test/test/ct_group_leader_SUITE_data/group_leader_SUITE.erl @@ -111,7 +111,8 @@ groups() -> {p_restart,[parallel],[p_restart_my_io_server]}, {seq,[],[s1,s2,s3]}, {seq2,[],[s4,s5]}, - {seq_in_par,[parallel],[p10,p11,{group,seq},p12,{group,seq2},p13]}]. + {seq_in_par,[parallel],[p10,p11,{group,seq},p12,{group,seq2},p13]}, + {capture_io,[parallel],[cap1,cap2]}]. %%-------------------------------------------------------------------- %% @spec all() -> GroupsAndTestCases | {skip,Reason} @@ -123,7 +124,9 @@ groups() -> %%-------------------------------------------------------------------- all() -> [tc1,{group,p},{group,p_restart},p3, - {group,seq_in_par}]. + {group,seq_in_par}, + cap1,cap2, + {group,capture_io}]. tc1(_C) -> ok. @@ -221,3 +224,29 @@ s4(_) -> s5(_) -> ok. + +cap1(_) -> + ct:capture_start(), + IO = gen_io(cap1, 10, []), + ct:capture_stop(), + IO = ct:capture_get(), + ok. + +cap2(_) -> + ct:capture_start(), + {Pid,Ref} = spawn_monitor(fun() -> + exit(gen_io(cap2, 42, [])) + end), + receive + {'DOWN',Ref,process,Pid,IO} -> + ct:capture_stop(), + IO = ct:capture_get(), + ok + end. + +gen_io(_, 0, Acc) -> + lists:reverse(Acc); +gen_io(Label, N, Acc) -> + S = lists:flatten(io_lib:format("~s: ~p\n", [Label,N])), + io:put_chars(S), + gen_io(Label, N-1, [S|Acc]). -- cgit v1.2.3