aboutsummaryrefslogblamecommitdiffstats
path: root/lib/common_test/test/ct_testspec_1_SUITE.erl
blob: 616c2db869d622e53b0b170627417afe5ca8895f (plain) (tree)
1
2
3
4
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200


                   
                                                        


























                                                                         
                                           

























                                                                      
                                         
 
         







                                                            
                                                     









                                                       


                                                                
                      









                                     







                                                                      


                                                 

                                      
 
                                                    

                                               


                                                 

                                        
                                                      
 
                                                         




                                                                    


                                                 

                                                 
 
                                               

                                          




                                                                 
 
                                                    
 

                                                                    
 































































                                                                      
 











                                                                 
                                                                        













































                                                                                    
                                                    








                                                                    
 



                                                 

                                                               

















                                                                    
                                                                
                                                     
                                           

                                                       



                                                                    




                                                      


                                                




















                                                                     


                                                    












                                                                             
                                                                    

   














                                                                               









                                                                               

   


































































































                                                                                








                                                                

                                                       











                                                                    

                                                         












                                                                    

                                                        












                                                                    

                                                        











                                                                    














































                                                                                

                                                                    


                                                                    









                                                          


                                                                          








                                                                   









                                                                           


                                          


                                                          
                                                             



















                                                                    























































































































































































































































































































































































































































































































































                                                                              
 
                                                              









                                                                        
      
                                                                







                                                     
      
                                                               













                                                        
                                                               
                                          
     




                                                                            
      

                                                                            
 
                            
                                                                 
                                          
     




                                                                            
      

                                                                            
 
                            
                                                                          








                                                          


                                               


                                                  

                                                           

                                                  

                                                           


                                                   

                                                 


                                                     
 

                                                     
 


                                                   

                                                















                                                        
                                                
                                          
     









                                                                            
                                                  
                                          
     

                                                                            
 

                                                                            
 

                                                                            
 
                            

                                                           








                                                          



                                              





                                                       



                               




                                                               

      


                 
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2009-2011. 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
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%

%%%-------------------------------------------------------------------
%%% File: ct_testspec_1_SUITE
%%%
%%% Description:
%%% Test test specifications
%%%
%%% The suites used for the test are located in the data directory.
%%%-------------------------------------------------------------------
-module(ct_testspec_1_SUITE).

-compile(export_all).

-include_lib("common_test/include/ct.hrl").
-include_lib("common_test/include/ct_event.hrl").

-define(eh, ct_test_support_eh).

%%--------------------------------------------------------------------
%% TEST SERVER CALLBACK FUNCTIONS
%%--------------------------------------------------------------------

%%--------------------------------------------------------------------
%% Description: Since Common Test starts another Test Server
%% instance, the tests need to be performed on a separate node (or
%% there will be clashes with logging processes etc).
%%--------------------------------------------------------------------
init_per_suite(Config) ->
    Config1 = ct_test_support:init_per_suite(Config),
    Config1.

end_per_suite(Config) ->
    ct_test_support:end_per_suite(Config).

init_per_testcase(TestCase, Config) ->
    ct_test_support:init_per_testcase(TestCase, Config).

end_per_testcase(TestCase, Config) ->
    ct_test_support:end_per_testcase(TestCase, Config).

suite() -> [{ct_hooks,[ts_install_cth]}].

all() -> 
    [all_suites, skip_all_suites, suite, skip_suite,
     all_testcases, skip_all_testcases, testcase,
     skip_testcase, all_groups, skip_all_groups, group,
     skip_group, group_all_testcases,
     skip_group_all_testcases, group_testcase,
     skip_group_testcase, topgroup, subgroup, skip_subgroup,
     subgroup_all_testcases, skip_subgroup_all_testcases,
     subgroup_testcase, skip_subgroup_testcase,
     sub_skipped_by_top, testcase_in_multiple_groups,
     order_of_tests_in_multiple_dirs_no_merge_tests,
     order_of_tests_in_multiple_suites_no_merge_tests,
     order_of_suites_in_multiple_dirs_no_merge_tests,
     order_of_groups_in_multiple_dirs_no_merge_tests,
     order_of_groups_in_multiple_suites_no_merge_tests,
     order_of_tests_in_multiple_dirs,
     order_of_tests_in_multiple_suites,
     order_of_suites_in_multiple_dirs,
     order_of_groups_in_multiple_dirs,
     order_of_groups_in_multiple_suites,
     order_of_tests_in_multiple_suites_with_skip_no_merge_tests,
     order_of_tests_in_multiple_suites_with_skip,
     all_plus_one_tc_no_merge_tests,
     all_plus_one_tc].

groups() -> 
    [].

init_per_group(_GroupName, Config) ->
	Config.

end_per_group(_GroupName, Config) ->
	Config.

%%--------------------------------------------------------------------
%% TEST CASES
%%--------------------------------------------------------------------

%%%-----------------------------------------------------------------
%%%

all_suites(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "suites_1"),
    TestSpec = [{label,"all_suites"},
		{suites,TestDir,all}],

    setup_and_execute(all_suites, TestSpec, Config).

skip_all_suites(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "suites_1"),
    TestSpec = [{label,skip_all_suites},
		{suites,TestDir,all},
		{skip_suites,TestDir,all,"SKIPPED!"}],

    setup_and_execute(skip_all_suites, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

suite(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "suites_1"),
    TestSpec = [{label,undefined},
		{suites,TestDir,simple_1_SUITE}],

    setup_and_execute(suite, TestSpec, Config).

skip_suite(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "suites_1"),
    TestSpec = [{suites,TestDir,[simple_1_SUITE,simple_2_SUITE]},
		{skip_suites,TestDir,simple_1_SUITE,"SKIPPED!"}],

    setup_and_execute(skip_suite, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

all_testcases(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "suites_1"),
    TestSpec = [{cases,TestDir,simple_1_SUITE,all}],

    setup_and_execute(all_testcases, TestSpec, Config).

skip_all_testcases(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "suites_1"),
    TestSpec = [{suites,TestDir,[simple_1_SUITE]},
		{skip_cases,TestDir,simple_1_SUITE,all,"SKIPPED!"}],

    setup_and_execute(skip_all_testcases, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

testcase(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "suites_1"),
    TestSpec = [{cases,TestDir,simple_1_SUITE,tc1}],

    setup_and_execute(testcase, TestSpec, Config).

skip_testcase(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "suites_1"),
    TestSpec = [{cases,TestDir,simple_1_SUITE,[tc1,tc2]},
		{cases,TestDir,simple_2_SUITE,[tc2,tc1]},
		{skip_cases,TestDir,simple_1_SUITE,[tc1],"SKIPPED!"},
		{skip_cases,TestDir,simple_2_SUITE,tc2,"SKIPPED!"}],

    setup_and_execute(skip_testcase, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

all_groups(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_11_SUITE,all}],

    setup_and_execute(all_groups, TestSpec, Config).

skip_all_groups(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_11_SUITE,all},
		{skip_groups,TestDir,groups_11_SUITE,all,"SKIPPED!"}],

    setup_and_execute(skip_all_groups, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

group(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_11_SUITE,test_group_1a}],

    setup_and_execute(group, TestSpec, Config).

skip_group(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_11_SUITE,[test_group_1a,
						 test_group_1b]},
		{skip_groups,TestDir,groups_11_SUITE,
		 [test_group_1b,test_group_2,test_group_7],"SKIPPED!"}],

    setup_and_execute(skip_group, TestSpec, Config).


%%%-----------------------------------------------------------------
%%%

group_all_testcases(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_11_SUITE,test_group_1a,{cases,all}}],

    setup_and_execute(group_all_testcases, TestSpec, Config).

skip_group_all_testcases(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_11_SUITE,[test_group_1a,
						 test_group_1b]},
		{skip_groups,TestDir,groups_11_SUITE,
		 test_group_1b,{cases,all},"SKIPPED!"},
		{skip_groups,TestDir,groups_11_SUITE,
		 test_group_1a,{cases,all},"SKIPPED!"}],

    setup_and_execute(skip_group_all_testcases, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

group_testcase(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_11_SUITE,test_group_1a,{cases,testcase_1a}}],

    setup_and_execute(group_testcase, TestSpec, Config).

skip_group_testcase(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_11_SUITE,test_group_1a,
		 {cases,[testcase_1a,testcase_1b]}},
		{groups,TestDir,groups_11_SUITE,test_group_1b,
		 {cases,[testcase_1b,testcase_1a]}},
		{skip_groups,TestDir,groups_11_SUITE,
		 test_group_1a,{cases,testcase_1b},"SKIPPED!"},
		{skip_groups,TestDir,groups_11_SUITE,
		 test_group_1b,{cases,[testcase_1a]},"SKIPPED!"}],

    setup_and_execute(skip_group_testcase, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

topgroup(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_12_SUITE,test_group_2},
		{groups,TestDir,groups_12_SUITE,test_group_4}],

    setup_and_execute(topgroup, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

subgroup(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_12_SUITE,test_group_3}],

    setup_and_execute(subgroup, TestSpec, Config).

skip_subgroup(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_12_SUITE,[test_group_4]},
		{skip_groups,TestDir,groups_12_SUITE,
		 test_group_8,"SKIPPED!"}],

    setup_and_execute(skip_subgroup, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

subgroup_all_testcases(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_12_SUITE,
		 test_group_5,{cases,all}},
		{groups,TestDir,groups_12_SUITE,
		 test_group_3,{cases,all}}],

    setup_and_execute(subgroup_all_testcases, TestSpec, Config).

skip_subgroup_all_testcases(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_12_SUITE,test_group_4},
		{skip_groups,TestDir,groups_12_SUITE,
		 test_group_5,{cases,all},"SKIPPED!"}],

    setup_and_execute(skip_subgroup_all_testcases, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

subgroup_testcase(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_12_SUITE,
		 test_group_7,{cases,testcase_7a}},
		{groups,TestDir,groups_12_SUITE,
		 test_group_3,{cases,testcase_3b}}],

    setup_and_execute(subgroup_testcase, TestSpec, Config).

skip_subgroup_testcase(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_12_SUITE,test_group_5},
		{skip_groups,TestDir,groups_12_SUITE,
		 test_group_7,{cases,[testcase_7a,testcase_7b]},"SKIPPED!"}],

    setup_and_execute(skip_subgroup_testcase, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

%%!
%%! Somewhat weird result from this one:
%%!
sub_skipped_by_top(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir,groups_12_SUITE,test_group_5},
		{skip_groups,TestDir,groups_12_SUITE,test_group_4,"SKIPPED!"}],

    setup_and_execute(sub_skipped_by_top, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

testcase_in_multiple_groups(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir = filename:join(DataDir, "groups_1"),
    TestSpec = [{cases,TestDir,groups_12_SUITE,[testcase_1a,testcase_1b]},
		{skip_cases,TestDir,groups_12_SUITE,[testcase_1b],"SKIPPED!"}],

    setup_and_execute(testcase_in_multiple_groups, TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_tests_in_multiple_dirs_no_merge_tests(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestDir2 = filename:join(DataDir, "groups_2"),
    TestSpec = [{merge_tests, false},
		{cases,TestDir1,groups_12_SUITE,[testcase_1a]},
		{cases,TestDir2,groups_22_SUITE,[testcase_1]},
		{cases,TestDir1,groups_12_SUITE,[testcase_1b]}],

    setup_and_execute(order_of_tests_in_multiple_dirs_no_merge_tests, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_tests_in_multiple_suites_no_merge_tests(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestSpec = [{merge_tests, false},
		{cases,TestDir1,groups_12_SUITE,[testcase_1a]},
		{cases,TestDir1,groups_11_SUITE,[testcase_1]},
		{cases,TestDir1,groups_12_SUITE,[testcase_1b]}],

    setup_and_execute(order_of_tests_in_multiple_suites_no_merge_tests, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_suites_in_multiple_dirs_no_merge_tests(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestDir2 = filename:join(DataDir, "groups_2"),
    TestSpec = [{merge_tests, false},
		{suites,TestDir1,groups_12_SUITE},
		{suites,TestDir2,groups_22_SUITE},
		{suites,TestDir1,groups_11_SUITE}],

    setup_and_execute(order_of_suites_in_multiple_dirs_no_merge_tests, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_groups_in_multiple_dirs_no_merge_tests(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestDir2 = filename:join(DataDir, "groups_2"),
    TestSpec = [{merge_tests, false},
		{groups,TestDir1,groups_12_SUITE,test_group_1a},
		{groups,TestDir2,groups_22_SUITE,test_group_1a},
		{groups,TestDir1,groups_12_SUITE,test_group_1b}],

    setup_and_execute(order_of_groups_in_multiple_dirs_no_merge_tests, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_groups_in_multiple_suites_no_merge_tests(Config) 
  when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestSpec = [{merge_tests, false},
		{groups,TestDir1,groups_12_SUITE,test_group_1a},
		{groups,TestDir1,groups_11_SUITE,test_group_1a},
		{groups,TestDir1,groups_12_SUITE,test_group_1b}],

    setup_and_execute(order_of_groups_in_multiple_suites_no_merge_tests, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_tests_in_multiple_suites_with_skip_no_merge_tests(Config) 
  when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestSpec = [{merge_tests, false},
		{cases,TestDir1,groups_12_SUITE,[testcase_1a]},
		{cases,TestDir1,groups_11_SUITE,[testcase_1]},
		{cases,TestDir1,groups_12_SUITE,[testcase_1b]},
		{cases,TestDir1,groups_11_SUITE,[testcase_2]},
		{skip_cases,TestDir1,groups_12_SUITE,[testcase_1b],"Skip it"}],

    setup_and_execute(
      order_of_tests_in_multiple_suites_with_skip_no_merge_tests,
      TestSpec, Config).
     

%%%-----------------------------------------------------------------
%%%

order_of_tests_in_multiple_dirs(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestDir2 = filename:join(DataDir, "groups_2"),
    TestSpec = [{cases,TestDir1,groups_12_SUITE,[testcase_1a]},
		{cases,TestDir2,groups_22_SUITE,[testcase_1]},
		{cases,TestDir1,groups_12_SUITE,[testcase_1b]}],

    setup_and_execute(order_of_tests_in_multiple_dirs, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_tests_in_multiple_suites(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestSpec = [{cases,TestDir1,groups_12_SUITE,[testcase_1a]},
		{cases,TestDir1,groups_11_SUITE,[testcase_1]},
		{cases,TestDir1,groups_12_SUITE,[testcase_1b]}],

    setup_and_execute(order_of_tests_in_multiple_suites, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_suites_in_multiple_dirs(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestDir2 = filename:join(DataDir, "groups_2"),
    TestSpec = [{suites,TestDir1,groups_12_SUITE},
		{suites,TestDir2,groups_22_SUITE},
		{suites,TestDir1,groups_11_SUITE}],

    setup_and_execute(order_of_suites_in_multiple_dirs, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_groups_in_multiple_dirs(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestDir2 = filename:join(DataDir, "groups_2"),
    TestSpec = [{groups,TestDir1,groups_12_SUITE,test_group_1a},
		{groups,TestDir2,groups_22_SUITE,test_group_1a},
		{groups,TestDir1,groups_12_SUITE,test_group_1b}],

    setup_and_execute(order_of_groups_in_multiple_dirs, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_groups_in_multiple_suites(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestSpec = [{groups,TestDir1,groups_12_SUITE,test_group_1a},
		{groups,TestDir1,groups_11_SUITE,test_group_1a},
		{groups,TestDir1,groups_12_SUITE,test_group_1b}],

    setup_and_execute(order_of_groups_in_multiple_suites, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

order_of_tests_in_multiple_suites_with_skip(Config) when is_list(Config) ->
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestSpec = [{cases,TestDir1,groups_12_SUITE,[testcase_1a]},
		{cases,TestDir1,groups_11_SUITE,[testcase_1]},
		{cases,TestDir1,groups_12_SUITE,[testcase_1b]},
		{cases,TestDir1,groups_11_SUITE,[testcase_2]},
		{skip_cases,TestDir1,groups_12_SUITE,[testcase_1b],"Skip it!"}],

    setup_and_execute(order_of_tests_in_multiple_suites_with_skip, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

all_plus_one_tc_no_merge_tests(Config) when is_list(Config) ->
    
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestSpec = [{merge_tests,false},
		{suites,TestDir1,groups_12_SUITE},
		{cases,TestDir1,groups_12_SUITE,[testcase_1a]}],

    setup_and_execute(all_plus_one_tc_no_merge_tests, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%%

all_plus_one_tc(Config) when is_list(Config) ->
    
    DataDir = ?config(data_dir, Config),

    TestDir1 = filename:join(DataDir, "groups_1"),
    TestSpec = [{suites,TestDir1,groups_12_SUITE},
		{cases,TestDir1,groups_12_SUITE,[testcase_1a]}],

    setup_and_execute(all_plus_one_tc, 
		      TestSpec, Config).

%%%-----------------------------------------------------------------
%%% HELP FUNCTIONS
%%%-----------------------------------------------------------------

setup_and_execute(TCName, TestSpec, Config) ->
    SpecFile = create_spec_file(?config(priv_dir, Config),
				TCName, TestSpec),
    TestTerms =
	case lists:keymember(label, 1, TestSpec) of
	    true -> [{spec,SpecFile}];
	    false -> [{spec,SpecFile},{label,TCName}]
	end,
    {Opts,ERPid} = setup(TestTerms, Config),
    ok = ct_test_support:run(Opts, Config),
    TestSpec1 = [{logdir,proplists:get_value(logdir,Opts)},
		 {label,proplists:get_value(label,TestTerms)} | TestSpec],
    ok = ct_test_support:run(ct, run_testspec, [TestSpec1], Config),
    Events = ct_test_support:get_events(ERPid, Config),

    ct_test_support:log_events(TCName,
			       reformat(Events, ?eh),
			       ?config(priv_dir, Config)),

    TestEvents = events_to_check(TCName),
    ok = ct_test_support:verify_events(TestEvents, Events, Config).

create_spec_file(SpecDir, TCName, TestSpec) ->
    FileName = filename:join(SpecDir,
			     atom_to_list(TCName)++".spec"),
    {ok,Dev} = file:open(FileName, [write]),
    [io:format(Dev, "~p.~n", [Term]) || Term <- TestSpec],
    file:close(Dev),
    io:format("~nTest spec created here~n~n<a href=\"file://~s\">~s</a>~n",
	      [FileName,FileName]),
    FileName.

setup(Test, Config) when is_tuple(Test) ->
    setup([Test], Config);
setup(Tests, Config) ->
    Opts0 = ct_test_support:get_opts(Config),
    Level = ?config(trace_level, Config),
    EvHArgs = [{cbm,ct_test_support},{trace_level,Level}],
    Opts = Opts0 ++ Tests ++ [{event_handler,{?eh,EvHArgs}}],
    ERPid = ct_test_support:start_event_receiver(Config),
    {Opts,ERPid}.

reformat(Events, EH) ->
    ct_test_support:reformat(Events, EH).
%reformat(Events, _EH) ->
%    Events.

%%%-----------------------------------------------------------------
%%% TEST EVENTS
%%%-----------------------------------------------------------------
events_to_check(Test) ->
    %% 2 tests (ct:run_test + script_start) is default
    events_to_check(Test, 2).

events_to_check(_, 0) ->
    [];
events_to_check(Test, N) ->
    test_events(Test) ++ events_to_check(Test, N-1).

test_events(all_suites) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{simple_1_SUITE,init_per_suite}},
     {?eh,tc_done,{simple_1_SUITE,end_per_suite,'_'}},
     {?eh,tc_start,{simple_2_SUITE,init_per_suite}},
     {?eh,test_stats,{4,0,{0,0}}},
     {?eh,tc_done,{simple_2_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(skip_all_suites) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_user_skip,{simple_1_SUITE,all,"SKIPPED!"}},
     {?eh,tc_user_skip,{simple_2_SUITE,all,"SKIPPED!"}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(suite) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{simple_1_SUITE,init_per_suite}},
     {?eh,test_stats,{2,0,{0,0}}},
     {?eh,tc_done,{simple_1_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];
 
test_events(skip_suite) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_user_skip,{simple_1_SUITE,all,"SKIPPED!"}},
     {?eh,tc_done,{simple_2_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(all_testcases) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{simple_1_SUITE,init_per_suite}},
     {?eh,test_stats,{2,0,{0,0}}},
     {?eh,tc_done,{simple_1_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];
 
test_events(skip_all_testcases) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_user_skip,{simple_1_SUITE,all,"SKIPPED!"}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(testcase) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{simple_1_SUITE,init_per_suite}},
     {?eh,test_stats,{1,0,{0,0}}},
     {negative,{?eh,test_stats,{2,0,{0,0}}},
      {?eh,tc_done,{simple_1_SUITE,end_per_suite,'_'}}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];
 
test_events(skip_testcase) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{simple_1_SUITE,init_per_suite}},
     {?eh,tc_user_skip,{simple_1_SUITE,tc1,"SKIPPED!"}},
     {?eh,tc_start,{simple_1_SUITE,tc2}},
     {?eh,tc_start,{simple_1_SUITE,end_per_suite}},

     {?eh,tc_start,{simple_2_SUITE,init_per_suite}},
     {?eh,tc_user_skip,{simple_2_SUITE,tc2,"SKIPPED!"}},
     {?eh,tc_start,{simple_2_SUITE,tc1}},
     {?eh,test_stats,{2,0,{2,0}}},
     {?eh,tc_start,{simple_2_SUITE,end_per_suite}},
     
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(all_groups) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_11_SUITE,init_per_suite}},
     {?eh,test_stats,{12,0,{0,0}}},
     {?eh,tc_done,{groups_11_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];
 
test_events(skip_all_groups) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_11_SUITE,init_per_suite}},
     {?eh,tc_user_skip, {groups_11_SUITE,{group,test_group_1a},"SKIPPED!"}},
     {?eh,test_stats,{0,0,{1,0}}},
     {?eh,tc_user_skip, {groups_11_SUITE,{group,test_group_1b},"SKIPPED!"}},
     {?eh,test_stats,{0,0,{2,0}}},
     {?eh,tc_user_skip, {groups_11_SUITE,{group,test_group_2},"SKIPPED!"}},
     {?eh,test_stats,{0,0,{3,0}}},
     {?eh,tc_user_skip, {groups_11_SUITE,{group,test_group_4},"SKIPPED!"}},
     {?eh,test_stats,{0,0,{4,0}}},
     {?eh,tc_done,{groups_11_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(group) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_11_SUITE,init_per_suite}},
     {?eh,tc_start,{groups_11_SUITE,{init_per_group,test_group_1a,[]}}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1a}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1b}},
     {?eh,test_stats,{2,0,{0,0}}},
     {?eh,tc_done,{groups_11_SUITE,{end_per_group,test_group_1a,[]},'_'}},
     {?eh,tc_done,{groups_11_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];
 
test_events(skip_group) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_11_SUITE,init_per_suite}},
     
     {?eh,tc_start,{groups_11_SUITE,{init_per_group,test_group_1a,[]}}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1a}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1b}},
     {?eh,test_stats,{2,0,{0,0}}},
     {?eh,tc_done,{groups_11_SUITE,{end_per_group,test_group_1a,[]},'_'}},
     
     {?eh,tc_user_skip, {groups_11_SUITE,{group,test_group_1b},"SKIPPED!"}},
     {?eh,test_stats,{2,0,{1,0}}},
     {negative,{?eh,tc_user_skip,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(group_all_testcases) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_11_SUITE,init_per_suite}},
     {?eh,tc_start,{groups_11_SUITE,{init_per_group,test_group_1a,[]}}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1a}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1b}},
     {?eh,test_stats,{2,0,{0,0}}},
     {?eh,tc_done,{groups_11_SUITE,{end_per_group,test_group_1a,[]},'_'}},
     {?eh,tc_done,{groups_11_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];
 
test_events(skip_group_all_testcases) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_11_SUITE,init_per_suite}},
     {?eh,tc_user_skip, {groups_11_SUITE,{group,test_group_1a},"SKIPPED!"}},
     {?eh,tc_user_skip, {groups_11_SUITE,{group,test_group_1b},"SKIPPED!"}},
     {?eh,test_stats,{0,0,{2,0}}},
     {?eh,tc_start,{groups_11_SUITE,end_per_suite}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(group_testcase) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_11_SUITE,init_per_suite}},
     {?eh,tc_start,{groups_11_SUITE,{init_per_group,test_group_1a,[]}}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1a}},
     {?eh,test_stats,{1,0,{0,0}}},
     {negative,{?eh,test_stats,{2,0,{0,0}}},
      {?eh,tc_done,{groups_11_SUITE,{end_per_group,test_group_1a,[]},'_'}}},

     {?eh,tc_done,{groups_11_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];
 
test_events(skip_group_testcase) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_11_SUITE,init_per_suite}},
     
     {?eh,tc_start,{groups_11_SUITE,{init_per_group,test_group_1a,[]}}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1a}},
     {?eh,tc_user_skip,{groups_11_SUITE,testcase_1b,"SKIPPED!"}},
     {?eh,test_stats,{1,0,{1,0}}},
     {?eh,tc_done,{groups_11_SUITE,{end_per_group,test_group_1a,[]},'_'}},
     
     {?eh,tc_start,{groups_11_SUITE,{init_per_group,test_group_1b,[]}}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1b}},
     {?eh,tc_user_skip,{groups_11_SUITE,testcase_1a,"SKIPPED!"}},
     {?eh,test_stats,{2,0,{2,0}}},
     {?eh,tc_done,{groups_11_SUITE,{end_per_group,test_group_1b,[]},'_'}},

     {negative,{?eh,tc_user_skip,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(topgroup) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},
     
     {parallel, 
      [{?eh,tc_start,
	{groups_12_SUITE,{init_per_group,test_group_2,[parallel]}}},
       {?eh,tc_done,
	{groups_12_SUITE,{init_per_group,test_group_2,[parallel]},ok}},
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]}}}
       ],
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_3,[]}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_3,[]}}}
       ],
       {?eh,test_stats,{6,0,{0,0}}},
       {?eh,tc_start,
	{groups_12_SUITE,{end_per_group,test_group_2,[parallel]}}},
       {?eh,tc_done,
	{groups_12_SUITE,{end_per_group,test_group_2,[parallel]},ok}}]},

     [{?eh,tc_start,
       {groups_12_SUITE,{init_per_group,test_group_4,[]}}},
      {parallel,
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_5,[parallel]}}},
	{?eh,tc_done,
	 {groups_12_SUITE,{init_per_group,test_group_5,[parallel]},ok}},
	{parallel,
	 [{?eh,tc_start,
	   {groups_12_SUITE,{init_per_group,test_group_6,[parallel]}}},
	  {?eh,tc_done,
	   {groups_12_SUITE,{init_per_group,test_group_6,[parallel]},ok}},
	  [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_7,'_'}}},
	   {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_7,'_'}}}],
	  {shuffle,
	   [{?eh,tc_start,
	     {groups_12_SUITE,{init_per_group,test_group_8,
			       [{shuffle,'_'},sequence]}}},
	    {?eh,tc_done,
	     {groups_12_SUITE,{init_per_group,test_group_8,
			       [{shuffle,'_'},sequence]},ok}},
	    {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_8,
					    [shuffle,sequence]}}},
	    {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_8,
					    [shuffle,sequence]},ok}}
	   ]},
	  {?eh,tc_start,
	   {groups_12_SUITE,{end_per_group,test_group_6,[parallel]}}},
	  {?eh,tc_done,
	   {groups_12_SUITE,{end_per_group,test_group_6,[parallel]},ok}}
	 ]},
	{?eh,test_stats,{12,0,{0,0}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_5,[parallel]}}},
	{?eh,tc_done,
	 {groups_12_SUITE,{end_per_group,test_group_5,[parallel]},ok}}]},
      {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_4,[]}}}],

     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(subgroup) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},

     {parallel, 
      [{?eh,tc_start,
	{groups_12_SUITE,{init_per_group,test_group_2,[parallel]}}},
       {?eh,tc_done,
	{groups_12_SUITE,{init_per_group,test_group_2,[parallel]},ok}},
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]}}}
       ],
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_3,[]}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_3,[]}}}
       ],
       {?eh,test_stats,{4,0,{0,0}}},
       {?eh,tc_start,
	{groups_12_SUITE,{end_per_group,test_group_2,[parallel]}}},
       {?eh,tc_done,
	{groups_12_SUITE,{end_per_group,test_group_2,[parallel]},ok}}]},
     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];
 
test_events(skip_subgroup) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},

     [{?eh,tc_start,
       {groups_12_SUITE,{init_per_group,test_group_4,[]}}},
      {parallel,
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_5,[parallel]}}},
	{?eh,tc_done,
	 {groups_12_SUITE,{init_per_group,test_group_5,[parallel]},ok}},
	{parallel,
	 [{?eh,tc_start,
	   {groups_12_SUITE,{init_per_group,test_group_6,[parallel]}}},
	  {?eh,tc_done,
	   {groups_12_SUITE,{init_per_group,test_group_6,[parallel]},ok}},
	  [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_7,'_'}}},
	   {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_7,'_'}}}],
	  {?eh,tc_user_skip,
	   {groups_12_SUITE,{group,test_group_8},"SKIPPED!"}},
	  {?eh,tc_start,
	   {groups_12_SUITE,{end_per_group,test_group_6,[parallel]}}},
	  {?eh,tc_done,
	   {groups_12_SUITE,{end_per_group,test_group_6,[parallel]},ok}}
	 ]},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_5,[parallel]}}},
	{?eh,tc_done,
	 {groups_12_SUITE,{end_per_group,test_group_5,[parallel]},ok}}]},
      {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_4,[]}}}],

     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(subgroup_all_testcases) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},

     [{?eh,tc_start,
       {groups_12_SUITE,{init_per_group,test_group_4,[]}}},
      {parallel,
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_5,[parallel]}}},
	{?eh,tc_done,
	 {groups_12_SUITE,{init_per_group,test_group_5,[parallel]},ok}},
	{parallel,
	 [{?eh,tc_start,
	   {groups_12_SUITE,{init_per_group,test_group_6,[parallel]}}},
	  {?eh,tc_done,
	   {groups_12_SUITE,{init_per_group,test_group_6,[parallel]},ok}},
	  [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_7,'_'}}},
	   {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_7,'_'}}}],
	  {shuffle,
	   [{?eh,tc_start,
	     {groups_12_SUITE,{init_per_group,test_group_8,
			       [{shuffle,'_'},sequence]}}},
	    {?eh,tc_done,
	     {groups_12_SUITE,{init_per_group,test_group_8,
			       [{shuffle,'_'},sequence]},ok}},
	    {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_8,
					    [shuffle,sequence]}}},
	    {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_8,
					    [shuffle,sequence]},ok}}
	   ]},
	  {?eh,tc_start,
	   {groups_12_SUITE,{end_per_group,test_group_6,[parallel]}}},
	  {?eh,tc_done,
	   {groups_12_SUITE,{end_per_group,test_group_6,[parallel]},ok}}
	 ]},
	{?eh,test_stats,{6,0,{0,0}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_5,[parallel]}}},
	{?eh,tc_done,
	 {groups_12_SUITE,{end_per_group,test_group_5,[parallel]},ok}}]},
      {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_4,[]}}}],

     {parallel, 
      [{?eh,tc_start,
	{groups_12_SUITE,{init_per_group,test_group_2,[parallel]}}},
       {?eh,tc_done,
	{groups_12_SUITE,{init_per_group,test_group_2,[parallel]},ok}},
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]}}}
       ],
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_3,[]}}},
	{?eh,test_stats,{10,0,{0,0}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_3,[]}}}
       ],
       {?eh,tc_start,
	{groups_12_SUITE,{end_per_group,test_group_2,[parallel]}}},
       {?eh,tc_done,
	{groups_12_SUITE,{end_per_group,test_group_2,[parallel]},ok}}]},

     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];
 
test_events(skip_subgroup_all_testcases) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},

     [{?eh,tc_start,
       {groups_12_SUITE,{init_per_group,test_group_4,[]}}},
      {?eh,tc_done,
       {groups_12_SUITE,{init_per_group,test_group_4,[]},ok}},
      {?eh,tc_user_skip,{groups_12_SUITE,{group,test_group_5},"SKIPPED!"}},
      {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_4,[]}}},
      {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_4,[]},ok}}
     ],

     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(subgroup_testcase) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},

     [{?eh,tc_start,
       {groups_12_SUITE,{init_per_group,test_group_4,[]}}},
      {parallel,
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_5,[parallel]}}},
	{?eh,tc_done,
	 {groups_12_SUITE,{init_per_group,test_group_5,[parallel]},ok}},
	{parallel,
	 [{?eh,tc_start,
	   {groups_12_SUITE,{init_per_group,test_group_6,[parallel]}}},
	  {?eh,tc_done,
	   {groups_12_SUITE,{init_per_group,test_group_6,[parallel]},ok}},
	  [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_7,'_'}}},
	   {?eh,test_stats,{1,0,{0,0}}},
	   {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_7,'_'}}}],
	  {?eh,tc_start,
	   {groups_12_SUITE,{end_per_group,test_group_6,[parallel]}}},
	  {?eh,tc_done,
	   {groups_12_SUITE,{end_per_group,test_group_6,[parallel]},ok}}
	 ]},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_5,[parallel]}}},
	{?eh,tc_done,
	 {groups_12_SUITE,{end_per_group,test_group_5,[parallel]},ok}}]},
      {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_4,[]}}}],

     {parallel, 
      [{?eh,tc_start,
	{groups_12_SUITE,{init_per_group,test_group_2,[parallel]}}},
       {?eh,tc_done,
	{groups_12_SUITE,{init_per_group,test_group_2,[parallel]},ok}},
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_3,[{repeat,2}]}}},
	{?eh,test_stats,{2,0,{0,0}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_3,[{repeat,2}]}}}
       ],
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_3,[]}}},
	{?eh,test_stats,{3,0,{0,0}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_3,[]}}}
       ],
       {?eh,tc_start,
	{groups_12_SUITE,{end_per_group,test_group_2,[parallel]}}},
       {?eh,tc_done,
	{groups_12_SUITE,{end_per_group,test_group_2,[parallel]},ok}}]},

     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];
 
test_events(skip_subgroup_testcase) ->
    [

    {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},

     [{?eh,tc_start,
       {groups_12_SUITE,{init_per_group,test_group_4,[]}}},
      {parallel,
       [{?eh,tc_start,
	 {groups_12_SUITE,{init_per_group,test_group_5,[parallel]}}},
	{?eh,tc_done,
	 {groups_12_SUITE,{init_per_group,test_group_5,[parallel]},ok}},
	{parallel,
	 [{?eh,tc_start,
	   {groups_12_SUITE,{init_per_group,test_group_6,[parallel]}}},
	  {?eh,tc_done,
	   {groups_12_SUITE,{init_per_group,test_group_6,[parallel]},ok}},
	  [{?eh,tc_start,{groups_12_SUITE,{init_per_group,test_group_7,'_'}}},
	   {?eh,tc_user_skip, {groups_12_SUITE,testcase_7a,"SKIPPED!"}},
           {?eh,test_stats,{1,0,{1,0}}},
           {?eh,tc_user_skip, {groups_12_SUITE,testcase_7b,"SKIPPED!"}},
           {?eh,test_stats,{1,0,{2,0}}},
	   {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_7,'_'}}}],
	  {shuffle,
	   [{?eh,tc_start,
	     {groups_12_SUITE,{init_per_group,test_group_8,
			       [{shuffle,'_'},sequence]}}},
	    {?eh,tc_done,
	     {groups_12_SUITE,{init_per_group,test_group_8,
			       [{shuffle,'_'},sequence]},ok}},
	    {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_8,
					    [shuffle,sequence]}}},
	    {?eh,tc_done,{groups_12_SUITE,{end_per_group,test_group_8,
					    [shuffle,sequence]},ok}}
	   ]},
	  {?eh,tc_start,
	   {groups_12_SUITE,{end_per_group,test_group_6,[parallel]}}},
	  {?eh,tc_done,
	   {groups_12_SUITE,{end_per_group,test_group_6,[parallel]},ok}}
	 ]},
	{?eh,test_stats,{4,0,{2,0}}},
	{?eh,tc_start,
	 {groups_12_SUITE,{end_per_group,test_group_5,[parallel]}}},
	{?eh,tc_done,
	 {groups_12_SUITE,{end_per_group,test_group_5,[parallel]},ok}}]},
      {?eh,tc_start,{groups_12_SUITE,{end_per_group,test_group_4,[]}}}],

     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
     
    ];

test_events(sub_skipped_by_top) ->
    [
     {?eh,start_logging,'_'},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},

     {?eh,tc_user_skip,{groups_12_SUITE,{group,test_group_4},"SKIPPED!"}},

     {negative,
      {?eh,tc_user_skip,{groups_12_SUITE,{group,test_group_4},"SKIPPED!"}},
      {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}}},

     {negative,{?eh,tc_start,'_'},{?eh,stop_logging,'_'}}
    ];

test_events(testcase_in_multiple_groups) ->
    [];

test_events(order_of_tests_in_multiple_dirs_no_merge_tests) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,tc_start,{groups_12_SUITE,testcase_1a}},
     {?eh,tc_done, {groups_12_SUITE,testcase_1a,
		    {failed,{error,{test_case_failed,no_group_data}}}}},
     {?eh,tc_start,{groups_22_SUITE,testcase_1}},
     {?eh,tc_done,{groups_22_SUITE,testcase_1,ok}},
     {?eh,tc_start,{groups_12_SUITE,testcase_1b}},
     {?eh,tc_done, {groups_12_SUITE,testcase_1b,
		    {failed,{error,{test_case_failed,no_group_data}}}}},
     {?eh,stop_logging,[]}
    ];
test_events(order_of_tests_in_multiple_suites_no_merge_tests) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,tc_start,{groups_12_SUITE,testcase_1a}},
     {?eh,tc_done,{groups_12_SUITE,testcase_1a,'_'}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1}},
     {?eh,tc_done,{groups_11_SUITE,testcase_1,ok}},
     {?eh,tc_start,{groups_12_SUITE,testcase_1b}},
     {?eh,tc_done,{groups_12_SUITE,testcase_1b,'_'}},
     {?eh,stop_logging,[]}
    ];
test_events(order_of_suites_in_multiple_dirs_no_merge_tests) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},
     {?eh,tc_done,{groups_12_SUITE,init_per_suite,'_'}},
     {?eh,tc_start,{groups_12_SUITE,end_per_suite}},
     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {?eh,tc_start,{groups_22_SUITE,init_per_suite}},
     {?eh,tc_done,{groups_22_SUITE,init_per_suite,'_'}},
     {?eh,tc_start,{groups_22_SUITE,end_per_suite}},
     {?eh,tc_done,{groups_22_SUITE,end_per_suite,'_'}},
     {?eh,tc_start,{groups_11_SUITE,init_per_suite}},
     {?eh,tc_done,{groups_11_SUITE,init_per_suite,'_'}},
     {?eh,tc_start,{groups_11_SUITE,end_per_suite}},
     {?eh,tc_done,{groups_11_SUITE,end_per_suite,'_'}},
     {?eh,stop_logging,[]}];
test_events(order_of_groups_in_multiple_dirs_no_merge_tests) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     
     {?eh,tc_start, {groups_12_SUITE,{init_per_group,test_group_1a,'_'}}},
     {?eh,tc_done, {groups_12_SUITE,{end_per_group,test_group_1a,'_'},'_'}},

     {?eh,tc_start, {groups_22_SUITE,{init_per_group,test_group_1a,'_'}}},
     {?eh,tc_done, {groups_22_SUITE,{end_per_group,test_group_1a,'_'},'_'}},
      
     {?eh,tc_start, {groups_12_SUITE,{init_per_group,test_group_1b,'_'}}},
     {?eh,tc_done, {groups_12_SUITE,{end_per_group,test_group_1b,'_'},'_'}},

     {?eh,stop_logging,[]}];
test_events(order_of_groups_in_multiple_suites_no_merge_tests) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     
     {?eh,tc_start, {groups_12_SUITE,{init_per_group,test_group_1a,'_'}}},
     {?eh,tc_done, {groups_12_SUITE,{end_per_group,test_group_1a,'_'},'_'}},

     {?eh,tc_start, {groups_11_SUITE,{init_per_group,test_group_1a,'_'}}},
     {?eh,tc_done, {groups_11_SUITE,{end_per_group,test_group_1a,'_'},'_'}},
      
     {?eh,tc_start, {groups_12_SUITE,{init_per_group,test_group_1b,'_'}}},
     {?eh,tc_done, {groups_12_SUITE,{end_per_group,test_group_1b,'_'},'_'}},

     {?eh,stop_logging,[]}];
test_events(order_of_tests_in_multiple_suites_with_skip_no_merge_tests) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,tc_start,{groups_12_SUITE,testcase_1a}},
     {?eh,tc_done,{groups_12_SUITE,testcase_1a,'_'}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1}},
     {?eh,tc_done,{groups_11_SUITE,testcase_1,ok}},
     {?eh,tc_user_skip,{groups_12_SUITE,testcase_1b,'_'}},
     {?eh,tc_start,{groups_11_SUITE,testcase_2}},
     {?eh,tc_done,{groups_11_SUITE,testcase_2,ok}},
     {?eh,stop_logging,[]}
    ];

test_events(order_of_tests_in_multiple_dirs) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,tc_start,{groups_12_SUITE,testcase_1a}},
     {?eh,tc_done,
      {groups_12_SUITE,testcase_1a,
       {failed,{error,{test_case_failed,no_group_data}}}}},
     {?eh,tc_start,{groups_12_SUITE,testcase_1b}},
     {?eh,tc_done,
      {groups_12_SUITE,testcase_1b,
       {failed,{error,{test_case_failed,no_group_data}}}}},
     {?eh,tc_start,{groups_22_SUITE,testcase_1}},
     {?eh,tc_done,{groups_22_SUITE,testcase_1,ok}},
     {?eh,stop_logging,[]}
    ];
test_events(order_of_tests_in_multiple_suites) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,tc_start,{groups_12_SUITE,testcase_1a}},
     {?eh,tc_done,{groups_12_SUITE,testcase_1a,'_'}},

     {?eh,tc_start,{groups_12_SUITE,testcase_1b}},
     {?eh,tc_done,{groups_12_SUITE,testcase_1b,'_'}},

     {?eh,tc_start,{groups_11_SUITE,testcase_1}},
     {?eh,tc_done,{groups_11_SUITE,testcase_1,ok}},
     {?eh,stop_logging,[]}
    ];
test_events(order_of_suites_in_multiple_dirs) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},
     {?eh,tc_done,{groups_12_SUITE,init_per_suite,'_'}},
     {?eh,tc_start,{groups_12_SUITE,end_per_suite}},
     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},

     {?eh,tc_start,{groups_11_SUITE,init_per_suite}},
     {?eh,tc_done,{groups_11_SUITE,init_per_suite,'_'}},
     {?eh,tc_start,{groups_11_SUITE,end_per_suite}},
     {?eh,tc_done,{groups_11_SUITE,end_per_suite,'_'}},

     {?eh,tc_start,{groups_22_SUITE,init_per_suite}},
     {?eh,tc_done,{groups_22_SUITE,init_per_suite,'_'}},
     {?eh,tc_start,{groups_22_SUITE,end_per_suite}},
     {?eh,tc_done,{groups_22_SUITE,end_per_suite,'_'}},
     {?eh,stop_logging,[]}];
test_events(order_of_groups_in_multiple_dirs) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     
     {?eh,tc_start, {groups_12_SUITE,{init_per_group,test_group_1a,'_'}}},
     {?eh,tc_done, {groups_12_SUITE,{end_per_group,test_group_1a,'_'},'_'}},

     {?eh,tc_start, {groups_12_SUITE,{init_per_group,test_group_1b,'_'}}},
     {?eh,tc_done, {groups_12_SUITE,{end_per_group,test_group_1b,'_'},'_'}},

     {?eh,tc_start, {groups_22_SUITE,{init_per_group,test_group_1a,'_'}}},
     {?eh,tc_done, {groups_22_SUITE,{end_per_group,test_group_1a,'_'},'_'}},

     {?eh,stop_logging,[]}];
test_events(order_of_groups_in_multiple_suites) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     
     {?eh,tc_start, {groups_12_SUITE,{init_per_group,test_group_1a,'_'}}},
     {?eh,tc_done, {groups_12_SUITE,{end_per_group,test_group_1a,'_'},'_'}},

     {?eh,tc_start, {groups_12_SUITE,{init_per_group,test_group_1b,'_'}}},
     {?eh,tc_done, {groups_12_SUITE,{end_per_group,test_group_1b,'_'},'_'}},

     {?eh,tc_start, {groups_11_SUITE,{init_per_group,test_group_1a,'_'}}},
     {?eh,tc_done, {groups_11_SUITE,{end_per_group,test_group_1a,'_'},'_'}},

     {?eh,stop_logging,[]}];

test_events(order_of_tests_in_multiple_suites_with_skip) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,tc_start,{groups_12_SUITE,testcase_1a}},
     {?eh,tc_done,{groups_12_SUITE,testcase_1a,'_'}},
     {?eh,tc_user_skip,{groups_12_SUITE,testcase_1b,'_'}},
     {?eh,tc_start,{groups_11_SUITE,testcase_1}},
     {?eh,tc_done,{groups_11_SUITE,testcase_1,ok}},
     {?eh,tc_start,{groups_11_SUITE,testcase_2}},
     {?eh,tc_done,{groups_11_SUITE,testcase_2,ok}},
     {?eh,stop_logging,[]}
    ];

test_events(all_plus_one_tc_no_merge_tests) ->

    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},
     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},
     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {?eh,stop_logging,[]}
    ];

test_events(all_plus_one_tc) ->

    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,tc_start,{groups_12_SUITE,init_per_suite}},
     {?eh,tc_done,{groups_12_SUITE,end_per_suite,'_'}},
     {negative,{?eh,tc_start,{groups_12_SUITE,init_per_suite}},
      {?eh,stop_logging,[]}}
    ];

test_events(_) ->
    [
    ].