diff options
author | Björn Gustavsson <[email protected]> | 2012-10-22 12:24:04 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-10-23 15:45:58 +0200 |
commit | ce61065fbef0cc634e656bb1eb926c42023c9201 (patch) | |
tree | 264159e0e77da3e6889df64b495ef7692aa2f5f2 /lib | |
parent | e08930d8c8ec17f3a1d9bfdf24498aa5aceac2cc (diff) | |
download | otp-ce61065fbef0cc634e656bb1eb926c42023c9201.tar.gz otp-ce61065fbef0cc634e656bb1eb926c42023c9201.tar.bz2 otp-ce61065fbef0cc634e656bb1eb926c42023c9201.zip |
Test ct:capture/start/stop/get
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common_test/test/ct_group_leader_SUITE.erl | 6 | ||||
-rw-r--r-- | lib/common_test/test/ct_group_leader_SUITE_data/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]). |