aboutsummaryrefslogblamecommitdiffstats
path: root/lib/common_test/test/ct_hooks_SUITE.erl
blob: 46243242952f335baa09708e5bd9cef8ecf6609a (plain) (tree)
1
2
3
4
5
6
7
8
9
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131


                   
                                                        
  


                                                                   
  






                                                                           















                                                                      
                                           

































                                                                               
                             



               
             



                                                                   

                                                        
                                                                 
                                                            
                             
                                                     
                                                                 
                            
                                                                      
                                                  
                                                         
                                                           

                                                        
       
      







                                                                      
                                       

                                                                         
                                       


















                                                                             
 




                                                                   
                                                










































                                                                                




                                                                                







                                                          



                                                                 



                                                          



                                                           














                                                                      
 







                                                                               

                                              

                                                                  
 



                                                









                                                                              



                                              
                                       

                                                    
                              






















                                                                           





                                                                             
 




















                                                                             



                                                                    





                                                   
 


                                                                                      
                                        



                                                                               


                                                       
                                   


                                                         

                                          

                                                                   




























                                                                    
                                                      

                                                   







                                                                 



                                                                                                    
                                                     
 












                                                                                      
                                                      
                             

                                   
                                   







                                                                                         



                                                                                            
                                                     
 






















                                                                                
                                                      
                             







                                           
                                                      

                                           




                                                          
 








                                                         
                                                      
                             

                                           
                                   





                                                                                         

                                                                                            
                                                     
 














                                                                                
                                                      
                                   







                                                        
 


                                                         
 






























                                                                 
                                                      
                                         




                                          
                                                      
                                   














                                                                                                   

                                                                                                      
                                                               
 





















                                                                                               

                                                                                                  
                                                           
 


















                                                                                      
                                                                                                            
                                                                                 
 
                                                              

                                                                                                       
                                                                
 
                                                                              

                                                                                                  

                                                                                 
 
















                                                                                                             

                                                                                                                
                                                                     
 





















                                                                                                         

                                                                                                            
                                                                 
 


















                                                                                                
                                                                                                                     
                                                                                       
 
                                                                    

                                                                                                                 
                                                                      
 
                                                                                    

                                                                                                            

                                                                                       
 








                                                                         
                                                      
                                   
 






                                                                            
                                                                                
 
 



                                                                   
                                                            


                                                                         
 



                                                                      
                                                                


                                                                             
 




                                         
















                                                                    


                                          
                                                      
                                   




                                                                                         
                                                                                                 



                                                                   
                                                                                     
 


                                                                      
                                                                                         








                                          
                                                      
                                   




                                                                                                
                                                                                             
 
                                                                   
                                                                                             
 
                                                                         





                                         





                                                                    
 


                                                                               
                                                                                                           
                                                                                 
 
                                                              

                                                                                                       
                                                                
 
                                                                              

                                                                                                  

                                                                           

                                                             




                                                                     

                                                            






                                                                    


                                          
                                                      
                                   
 




                                                                                         
                                                                                             
 
                                                                   
                                                                                             
 
                                                                         
 




                                         


































                                                                                  



                                        
                                                      
                                   







                                                                        
                                                                 
                                         
                                                                 
                                        
 













                                                          
                                                      
                                   
 













                                                                         

                                       




                                               

                                       














                                                                          

                                       







                                                  

                                       












                                                                        

                                       







                                               

                                       









                                                                         
 



























                                                               
                                                      

                                   
                                         
 
































                                                                               
                                                      
                                             







                                                                     

                                                                                                       
                                                     
 












                                                                                          
                                                      
                             
                             
                                           











                                                                              
                                                                                         
               

                                                                                              
               
                                                                                             
                                                       
 















                                                                                  
                                                      
                                   
                                         















                                                                                       

                                                                        

                                                                            

                                                                        










                                                                               




                                          
                        






                                                                 

                 








                                                                      
 
                                          








                                                                            
 









                                                                              
 





                                                                      



                                                                         


                                                                           
                                      



                                                                        
                                        



                                                                         



                                                                           


                                                                          
                                   


                                                                           


                                                            
 
                         












                                                                 
                                                                 
                                               
                                                                    



                                                                            
                                                                 
                                              
                                                                             



                                                                 
                                                                  
                                                
                                                                     



                                                                           
                                                                 
                                             
                                                                    










                                                                              
 































































































































































                                                                                 













                                                                                                        
                                                                                                        
                                               
                                                                                                           



                                                                            
                                                                                                        
                                              
                                                                                                                    



                                                                 
                                                                                                         
                                                
                                                                                                            



                                                                           
                                                                                                        
                                             
                                                                                                           










                                                                                               





                                                      



                                                                          
                                     



                                                                            
 




                                                    

















































                                                                              

















                                                                          















































































































































































































































































































































































































































































































                                                                                      


                  




































                                             
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2009-2016. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%%     http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% %CopyrightEnd%
%%

%%%-------------------------------------------------------------------
%%% File: ct_error_SUITE
%%%
%%% Description: 
%%% Test various errors in Common Test suites.
%%%
%%% The suites used for the test are located in the data directory.
%%%-------------------------------------------------------------------
-module(ct_hooks_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) ->
    DataDir = ?config(data_dir, Config),
    TestDir = filename:join(DataDir,"cth/tests/"),
    CTHs = filelib:wildcard(filename:join(TestDir,"*_cth.erl")),
    io:format("CTHs: ~p",[CTHs]),
    [io:format("Compiling ~p: ~p",
	    [FileName,compile:file(FileName,[{outdir,TestDir},debug_info])]) ||
	FileName <- CTHs],
    ct_test_support:init_per_suite([{path_dirs,[TestDir]} | Config]).

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() ->
    [{timetrap,{minutes,1}}].

all() ->
    all(suite).

all(suite) ->
    lists:reverse(
      [
       one_cth, two_cth, faulty_cth_no_init, faulty_cth_id_no_init,
       faulty_cth_exit_in_init, faulty_cth_exit_in_id,
       faulty_cth_exit_in_init_scope_suite, minimal_cth,
       minimal_and_maximal_cth, faulty_cth_undef,
       scope_per_suite_cth, scope_per_group_cth, scope_suite_cth,
       scope_per_suite_state_cth, scope_per_group_state_cth,
       scope_suite_state_cth,
       fail_pre_suite_cth, double_fail_pre_suite_cth,
       fail_post_suite_cth, skip_pre_suite_cth, skip_pre_end_cth,
       skip_pre_init_tc_cth,
       skip_post_suite_cth, recover_post_suite_cth, update_config_cth,
       state_update_cth, options_cth, same_id_cth,
       fail_n_skip_with_minimal_cth, prio_cth, no_config,
       no_init_suite_config, no_init_config, no_end_config,
       failed_sequence, repeat_force_stop, config_clash,
       callbacks_on_skip, fallback, data_dir, cth_log
      ]
    ).


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

%%%-----------------------------------------------------------------
%%% 
one_cth(Config) when is_list(Config) ->
    do_test(one_empty_cth, "ct_cth_empty_SUITE.erl",[empty_cth], Config).

two_cth(Config) when is_list(Config) ->
    do_test(two_empty_cth, "ct_cth_empty_SUITE.erl",[empty_cth,empty_cth],
	    Config).

faulty_cth_no_init(Config) when is_list(Config) ->
    do_test(faulty_cth_no_init, "ct_cth_empty_SUITE.erl",[askjhdkljashdkaj],
	    Config,{error,"Failed to start CTH, see the "
		   "CT Log for details"}).

faulty_cth_id_no_init(Config) when is_list(Config) ->
    do_test(faulty_cth_id_no_init, "ct_cth_empty_SUITE.erl",[id_no_init_cth],
	    Config,{error,"Failed to start CTH, see the "
		   "CT Log for details"}).

minimal_cth(Config) when is_list(Config) ->
    do_test(minimal_cth, "ct_cth_empty_SUITE.erl",[minimal_cth],Config).

minimal_and_maximal_cth(Config) when is_list(Config) ->
    do_test(minimal_and_maximal_cth, "ct_cth_empty_SUITE.erl",
	    [minimal_cth, empty_cth],Config).

faulty_cth_undef(Config) when is_list(Config) ->
    do_test(faulty_cth_undef, "ct_cth_empty_SUITE.erl",
	    [undef_cth],Config).

faulty_cth_exit_in_init_scope_suite(Config) when is_list(Config) ->
    do_test(faulty_cth_exit_in_init_scope_suite,
	    "ct_exit_in_init_scope_suite_cth_SUITE.erl",
	    [],Config).

faulty_cth_exit_in_init(Config) when is_list(Config) ->
    do_test(faulty_cth_exit_in_init, "ct_cth_empty_SUITE.erl",
	    [crash_init_cth], Config,
	    {error,"Failed to start CTH, see the "
	     "CT Log for details"}).

faulty_cth_exit_in_id(Config) when is_list(Config) ->
    do_test(faulty_cth_exit_in_id, "ct_cth_empty_SUITE.erl",
	    [crash_id_cth], Config,
	    {error,"Failed to start CTH, see the "
	     "CT Log for details"}).

scope_per_suite_cth(Config) when is_list(Config) ->
    do_test(scope_per_suite_cth, "ct_scope_per_suite_cth_SUITE.erl",
	    [],Config).

scope_suite_cth(Config) when is_list(Config) ->
    do_test(scope_suite_cth, "ct_scope_suite_cth_SUITE.erl",
	    [],Config).

scope_per_group_cth(Config) when is_list(Config) ->
    do_test(scope_per_group_cth, "ct_scope_per_group_cth_SUITE.erl",
	    [],Config).

scope_per_suite_state_cth(Config) when is_list(Config) ->
    do_test(scope_per_suite_state_cth, "ct_scope_per_suite_state_cth_SUITE.erl",
	    [],Config).

scope_suite_state_cth(Config) when is_list(Config) ->
    do_test(scope_suite_state_cth, "ct_scope_suite_state_cth_SUITE.erl",
	    [],Config).

scope_per_group_state_cth(Config) when is_list(Config) ->
    do_test(scope_per_group_state_cth, "ct_scope_per_group_state_cth_SUITE.erl",
	    [],Config).

fail_pre_suite_cth(Config) when is_list(Config) ->
    do_test(fail_pre_suite_cth, "ct_cth_empty_SUITE.erl",
	    [fail_pre_suite_cth],Config).

double_fail_pre_suite_cth(Config) when is_list(Config) ->
    do_test(double_fail_pre_suite_cth, "{ct_scope_suite_crash_in_cth_SUITE.erl,"
	    "ct_scope_suite_cth_SUITE.erl}",
	    [],Config).

fail_post_suite_cth(Config) when is_list(Config) ->
    do_test(fail_post_suite_cth, "ct_cth_empty_SUITE.erl",
	    [fail_post_suite_cth],Config).

skip_pre_suite_cth(Config) when is_list(Config) ->
    do_test(skip_pre_suite_cth, "ct_cth_empty_SUITE.erl",
	    [skip_pre_suite_cth],Config).

skip_pre_end_cth(Config) when is_list(Config) ->
    do_test(skip_pre_end_cth, "ct_scope_per_group_cth_SUITE.erl",
	    [skip_pre_end_cth],Config).

skip_post_suite_cth(Config) when is_list(Config) ->
    do_test(skip_post_suite_cth, "ct_cth_empty_SUITE.erl",
	    [skip_post_suite_cth],Config).

skip_pre_init_tc_cth(Config) ->
    do_test(skip_pre_init_tc_cth, "ct_cth_empty_SUITE.erl",
	    [skip_pre_init_tc_cth],Config).

recover_post_suite_cth(Config) when is_list(Config) ->
    do_test(recover_post_suite_cth, "ct_cth_fail_per_suite_SUITE.erl",
	    [recover_post_suite_cth],Config).

update_config_cth(Config) when is_list(Config) ->
    do_test(update_config_cth, "ct_update_config_SUITE.erl",
	    [update_config_cth],Config).

state_update_cth(Config) when is_list(Config) ->
    do_test(state_update_cth, "ct_cth_fail_one_skip_one_SUITE.erl",
	    [state_update_cth,state_update_cth],Config).

options_cth(Config) when is_list(Config) ->
    do_test(options_cth, "ct_cth_empty_SUITE.erl",
	    [{empty_cth,[test]}],Config).

same_id_cth(Config) when is_list(Config) ->
    do_test(same_id_cth, "ct_cth_empty_SUITE.erl",
	    [same_id_cth,same_id_cth],Config).

fail_n_skip_with_minimal_cth(Config) when is_list(Config) ->
    do_test(fail_n_skip_with_minimal_cth, "ct_cth_fail_one_skip_one_SUITE.erl",
	    [minimal_terminate_cth],Config).

prio_cth(Config) when is_list(Config) ->
    do_test(prio_cth, "ct_cth_prio_SUITE.erl",
	    [{empty_cth,[1000],1000},{empty_cth,[900],900},
	     {prio_cth,[1100,100],100},{prio_cth,[1100]}],Config).

no_config(Config) when is_list(Config) ->
    do_test(no_config, "ct_no_config_SUITE.erl",
	    [verify_config_cth],Config).

no_init_suite_config(Config) when is_list(Config) ->
    do_test(no_init_suite_config, "ct_no_init_suite_config_SUITE.erl",
            [empty_cth],Config).

no_init_config(Config) when is_list(Config) ->
    do_test(no_init_config, "ct_no_init_config_SUITE.erl",[empty_cth],Config).

no_end_config(Config) when is_list(Config) ->
    do_test(no_end_config, "ct_no_end_config_SUITE.erl",[empty_cth],Config).

data_dir(Config) when is_list(Config) ->
    do_test(data_dir, "ct_data_dir_SUITE.erl",
	    [verify_data_dir_cth],Config).

cth_log(Config) when is_list(Config) ->
    %% test that cth_log_redirect writes properly to
    %% unexpected I/O log
    ct:timetrap({minutes,10}),
    StartOpts = do_test(cth_log, "cth_log_SUITE.erl", [], Config),
    Logdir = proplists:get_value(logdir, StartOpts),
    UnexpIoLogs =
	filelib:wildcard(
	  filename:join(Logdir,
			"ct_run*/cth.tests*/run*/unexpected_io.log.html")),
    lists:foreach(
      fun(UnexpIoLog) ->
	      {ok,Bin} = file:read_file(UnexpIoLog),
	      Ts = string:tokens(binary_to_list(Bin),[$\n]),
	      Matches = lists:foldl(fun([$=,$E,$R,$R,$O,$R|_],  N) ->
					    N+1;
				       ([$L,$o,$g,$g,$e,$r|_],  N) ->
					    N+1;
				       (_, N) -> N
				    end, 0, Ts),
	      ct:pal("~p matches in ~tp", [Matches,UnexpIoLog]),
	      if Matches > 10 -> ok;
		 true -> exit({no_unexpected_io_found,UnexpIoLog})
	      end
      end, UnexpIoLogs),
    ok.

%% OTP-10599 adds the Suite argument as first argument to all hook
%% callbacks that did not have a Suite argument from before. This test
%% checks that ct_hooks will fall back to old versions of callbacks if
%% new versions are not exported.
fallback(Config) ->
    do_test(fallback, "all_hook_callbacks_SUITE.erl",[fallback_cth], Config).

%% Test that expected callbacks, and only those, are called when tests
%% are skipped in different ways
callbacks_on_skip(Config) ->
    do_test(callbacks_on_skip, {spec,"skip.spec"},[skip_cth], Config).

%% Test that expected callbacks, and only those, are called when tests
%% are skipped due to failed sequence
failed_sequence(Config) ->
    do_test(failed_sequence, "seq_SUITE.erl", [skip_cth], Config).

%% Test that expected callbacks, and only those, are called when tests
%% are skipped due to {force_stop,skip_rest} option
repeat_force_stop(Config) ->
    do_test(repeat_force_stop, "repeat_SUITE.erl", [skip_cth], Config, ok, 2,
            [{force_stop,skip_rest},{duration,"000009"}]).

%% Test that expected callbacks, and only those, are called when a test
%% are fails due to clash in config alias names
config_clash(Config) ->
    do_test(config_clash, "config_clash_SUITE.erl", [skip_cth], Config).

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

do_test(Tag, WTT, CTHs, Config) ->
    do_test(Tag, WTT, CTHs, Config, ok).
do_test(Tag, WTT, CTHs, Config, {error,_} = Res) ->
    do_test(Tag, WTT, CTHs, Config, Res, 1,[]);
do_test(Tag, WTT, CTHs, Config, Res) ->
    do_test(Tag, WTT, CTHs, Config, Res, 2,[]).

do_test(Tag, WhatToTest, CTHs, Config, Res, EC, ExtraOpts) when is_list(WhatToTest) ->
    do_test(Tag, {suite,WhatToTest}, CTHs, Config, Res, EC, ExtraOpts);
do_test(Tag, {WhatTag,Wildcard}, CTHs, Config, Res, EC, ExtraOpts) ->
    DataDir = ?config(data_dir, Config),
    Files = filelib:wildcard(
               filename:join([DataDir,"cth/tests",Wildcard])),
    {Opts,ERPid} =
        setup([{WhatTag,Files},{ct_hooks,CTHs},{label,Tag}|ExtraOpts], Config),
    Res = ct_test_support:run(Opts, Config),
    Events = ct_test_support:get_events(ERPid, Config),

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

    TestEvents = events_to_check(Tag, EC),
    ok = ct_test_support:verify_events(TestEvents, Events, Config),
    Opts.

setup(Test, Config) ->
    Opts0 = ct_test_support:get_opts(Config),
    Level = ?config(trace_level, Config),
    EvHArgs = [{cbm,ct_test_support},{trace_level,Level}],
    Opts = Opts0 ++ [{event_handler,{?eh,EvHArgs}}|Test],
    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(one_empty_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,id,[[]]}},
     {?eh,cth,{empty_cth,init,[{'_','_','_'},[]]}},
     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,cth,{empty_cth,pre_init_per_suite,
	       [ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_suite,
	       [ct_cth_empty_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}},

     {?eh,tc_start,{ct_cth_empty_SUITE,test_case}},
     {?eh,cth,{empty_cth,pre_init_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist','_',[]]}},
     {?eh,cth,{empty_cth,pre_end_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist','_',[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}},

     {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}},
     {?eh,cth,{empty_cth,pre_end_per_suite,
	       [ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{empty_cth,terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(two_empty_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',id,[[]]}},
     {?eh,cth,{'_',id,[[]]}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}},

     {?eh,tc_start,{ct_cth_empty_SUITE,test_case}},
     {?eh,cth,{'_',pre_init_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',[]]}},
     {?eh,cth,{'_',pre_init_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',[]]}},
     {?eh,cth,{'_',post_end_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',ok,[]]}},
     {?eh,cth,{'_',post_end_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',ok,[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}},

     {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}},
     {?eh,cth,{'_',pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[]]}},
     {?eh,cth,{'_',post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{'_',terminate,[[]]}},
     {?eh,cth,{'_',terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(faulty_cth_no_init) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(faulty_cth_id_no_init) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',id,[[]]}},
     {negative,{?eh,tc_start,'_'},
      {?eh,test_done,{'DEF','STOP_TIME'}}},
     {?eh,stop_logging,[]}
    ];

test_events(minimal_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {negative,{?eh,cth,{'_',id,['_',[]]}},
      {?eh,cth,{'_',init,['_',[]]}}},
     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}},

     {?eh,tc_start,{ct_cth_empty_SUITE,test_case}},
     {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}},

     {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}},
     {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(minimal_and_maximal_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',id,[[]]}},
     {negative,{?eh,cth,{'_',id,['_',[]]}},
      {?eh,cth,{'_',init,['_',[]]}}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}},

     {?eh,tc_start,{ct_cth_empty_SUITE,test_case}},
     {?eh,cth,{'_',pre_init_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',[]]}},
     {?eh,cth,{'_',post_end_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',ok,[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}},

     {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}},
     {?eh,cth,{'_',pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{'_',terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(faulty_cth_undef) ->
    FailReasonStr = "undef_cth:pre_init_per_suite/3 CTH call failed",
    FailReason = {ct_cth_empty_SUITE,init_per_suite,
		  {failed,FailReasonStr}},
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,
		  {failed, {error,FailReasonStr}}}},
     {?eh,cth,{'_',on_tc_fail,'_'}},

     {?eh,tc_auto_skip,{ct_cth_empty_SUITE,test_case,
			{failed, FailReason}}},
     {?eh,cth,{'_',on_tc_skip,'_'}},

     {?eh,tc_auto_skip,{ct_cth_empty_SUITE,end_per_suite,
			{failed, FailReason}}},
     {?eh,cth,{'_',on_tc_skip,'_'}},

     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(faulty_cth_exit_in_init_scope_suite) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,tc_start,{'_',init_per_suite}},
     {?eh,cth,{empty_cth,init,['_',[]]}},
     {?eh,tc_done,
      {ct_exit_in_init_scope_suite_cth_SUITE,init_per_suite,
       {failed,
	{error,
	 "Failed to start CTH, see the CT Log for details"}}}},
     {?eh,tc_auto_skip,
      {ct_exit_in_init_scope_suite_cth_SUITE,test_case,
       {failed,
	{ct_exit_in_init_scope_suite_cth_SUITE,init_per_suite,
	 {failed,
	  "Failed to start CTH, see the CT Log for details"}}}}},
     {?eh,tc_auto_skip,
      {ct_exit_in_init_scope_suite_cth_SUITE,end_per_suite,
       {failed,
	{ct_exit_in_init_scope_suite_cth_SUITE,init_per_suite,
	 {failed,
	  "Failed to start CTH, see the CT Log for details"}}}}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}];

test_events(faulty_cth_exit_in_init) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,init,['_',[]]}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}];

test_events(faulty_cth_exit_in_id) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,id,[[]]}},
     {negative, {?eh,tc_start,'_'},
      {?eh,test_done,{'DEF','STOP_TIME'}}},
     {?eh,stop_logging,[]}];

test_events(scope_per_suite_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,tc_start,{ct_scope_per_suite_cth_SUITE,init_per_suite}},
     {?eh,cth,{'_',id,[[]]}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_scope_per_suite_cth_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_scope_per_suite_cth_SUITE,init_per_suite,ok}},

     {?eh,tc_start,{ct_scope_per_suite_cth_SUITE,test_case}},
     {?eh,cth,{'_',pre_init_per_testcase,[ct_scope_per_suite_cth_SUITE,test_case,'$proplist',[]]}},
     {?eh,cth,{'_',post_end_per_testcase,[ct_scope_per_suite_cth_SUITE,test_case,'$proplist',ok,[]]}},
     {?eh,tc_done,{ct_scope_per_suite_cth_SUITE,test_case,ok}},

     {?eh,tc_start,{ct_scope_per_suite_cth_SUITE,end_per_suite}},
     {?eh,cth,{'_',pre_end_per_suite,
	       [ct_scope_per_suite_cth_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_end_per_suite,[ct_scope_per_suite_cth_SUITE,'$proplist','_',[]]}},
     {?eh,cth,{'_',terminate,[[]]}},
     {?eh,tc_done,{ct_scope_per_suite_cth_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(scope_suite_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,tc_start,{ct_scope_suite_cth_SUITE,init_per_suite}},
     {?eh,cth,{'_',id,[[]]}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,cth,{'_',pre_init_per_suite,[ct_scope_suite_cth_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_scope_suite_cth_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_scope_suite_cth_SUITE,init_per_suite,ok}},

     {?eh,tc_start,{ct_scope_suite_cth_SUITE,test_case}},
     {?eh,cth,{'_',pre_init_per_testcase,[ct_scope_suite_cth_SUITE,test_case,'$proplist',[]]}},
     {?eh,cth,{'_',post_end_per_testcase,[ct_scope_suite_cth_SUITE,test_case,'$proplist',ok,[]]}},
     {?eh,tc_done,{ct_scope_suite_cth_SUITE,test_case,ok}},

     {?eh,tc_start,{ct_scope_suite_cth_SUITE,end_per_suite}},
     {?eh,cth,{'_',pre_end_per_suite,[ct_scope_suite_cth_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_end_per_suite,[ct_scope_suite_cth_SUITE,'$proplist','_',[]]}},
     {?eh,cth,{'_',terminate,[[]]}},
     {?eh,tc_done,{ct_scope_suite_cth_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(scope_per_group_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,tc_start,{ct_scope_per_group_cth_SUITE,init_per_suite}},
     {?eh,tc_done,{ct_scope_per_group_cth_SUITE,init_per_suite,ok}},

     [{?eh,tc_start,{ct_scope_per_group_cth_SUITE,{init_per_group,group1,[]}}},
      {?eh,cth,{'_',id,[[]]}},
      {?eh,cth,{'_',init,['_',[]]}},
      {?eh,cth,{'_',post_init_per_group,[ct_scope_per_group_cth_SUITE,group1, '$proplist','$proplist',[]]}},
      {?eh,tc_done,{ct_scope_per_group_cth_SUITE,{init_per_group,group1,[]},ok}},

      {?eh,tc_start,{ct_scope_per_group_cth_SUITE,test_case}},
      {?eh,cth,{'_',pre_init_per_testcase,[ct_scope_per_group_cth_SUITE,test_case,'$proplist',[]]}},
      {?eh,cth,{'_',post_end_per_testcase,[ct_scope_per_group_cth_SUITE,test_case,'$proplist',ok,[]]}},
      {?eh,tc_done,{ct_scope_per_group_cth_SUITE,test_case,ok}},

      {?eh,tc_start,{ct_scope_per_group_cth_SUITE,{end_per_group,group1,[]}}},
      {?eh,cth,{'_',pre_end_per_group,[ct_scope_per_group_cth_SUITE,group1,'$proplist',[]]}},
      {?eh,cth,{'_',post_end_per_group,[ct_scope_per_group_cth_SUITE,group1,'$proplist','_',[]]}},
      {?eh,cth,{'_',terminate,[[]]}},
      {?eh,tc_done,{ct_scope_per_group_cth_SUITE,{end_per_group,group1,[]},ok}}],

     {?eh,tc_start,{ct_scope_per_group_cth_SUITE,end_per_suite}},
     {?eh,tc_done,{ct_scope_per_group_cth_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(scope_per_suite_state_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,tc_start,{ct_scope_per_suite_state_cth_SUITE,init_per_suite}},
     {?eh,cth,{'_',id,[[test]]}},
     {?eh,cth,{'_',init,['_',[test]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_scope_per_suite_state_cth_SUITE,'$proplist','$proplist',[test]]}},
     {?eh,tc_done,{ct_scope_per_suite_state_cth_SUITE,init_per_suite,ok}},

     {?eh,tc_start,{ct_scope_per_suite_state_cth_SUITE,test_case}},
     {?eh,cth,{'_',pre_init_per_testcase,[ct_scope_per_suite_state_cth_SUITE,test_case,'$proplist',[test]]}},
     {?eh,cth,{'_',post_end_per_testcase,[ct_scope_per_suite_state_cth_SUITE,test_case,'$proplist',ok,[test]]}},
     {?eh,tc_done,{ct_scope_per_suite_state_cth_SUITE,test_case,ok}},

     {?eh,tc_start,{ct_scope_per_suite_state_cth_SUITE,end_per_suite}},
     {?eh,cth,{'_',pre_end_per_suite,
	       [ct_scope_per_suite_state_cth_SUITE,'$proplist',[test]]}},
     {?eh,cth,{'_',post_end_per_suite,[ct_scope_per_suite_state_cth_SUITE,'$proplist','_',[test]]}},
     {?eh,cth,{'_',terminate,[[test]]}},
     {?eh,tc_done,{ct_scope_per_suite_state_cth_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(scope_suite_state_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,tc_start,{ct_scope_suite_state_cth_SUITE,init_per_suite}},
     {?eh,cth,{'_',id,[[test]]}},
     {?eh,cth,{'_',init,['_',[test]]}},
     {?eh,cth,{'_',pre_init_per_suite,[ct_scope_suite_state_cth_SUITE,'$proplist',[test]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_scope_suite_state_cth_SUITE,'$proplist','$proplist',[test]]}},
     {?eh,tc_done,{ct_scope_suite_state_cth_SUITE,init_per_suite,ok}},

     {?eh,tc_start,{ct_scope_suite_state_cth_SUITE,test_case}},
     {?eh,cth,{'_',pre_init_per_testcase,[ct_scope_suite_state_cth_SUITE,test_case,'$proplist',[test]]}},
     {?eh,cth,{'_',post_end_per_testcase,[ct_scope_suite_state_cth_SUITE,test_case,'$proplist',ok,[test]]}},
     {?eh,tc_done,{ct_scope_suite_state_cth_SUITE,test_case,ok}},

     {?eh,tc_start,{ct_scope_suite_state_cth_SUITE,end_per_suite}},
     {?eh,cth,{'_',pre_end_per_suite,[ct_scope_suite_state_cth_SUITE,'$proplist',[test]]}},
     {?eh,cth,{'_',post_end_per_suite,[ct_scope_suite_state_cth_SUITE,'$proplist','_',[test]]}},
     {?eh,cth,{'_',terminate,[[test]]}},
     {?eh,tc_done,{ct_scope_suite_state_cth_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(scope_per_group_state_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,tc_start,{ct_scope_per_group_state_cth_SUITE,init_per_suite}},
     {?eh,tc_done,{ct_scope_per_group_state_cth_SUITE,init_per_suite,ok}},

     [{?eh,tc_start,{ct_scope_per_group_state_cth_SUITE,{init_per_group,group1,[]}}},
      {?eh,cth,{'_',id,[[test]]}},
      {?eh,cth,{'_',init,['_',[test]]}},
      {?eh,cth,{'_',post_init_per_group,[ct_scope_per_group_state_cth_SUITE,group1,'$proplist','$proplist',[test]]}},
      {?eh,tc_done,{ct_scope_per_group_state_cth_SUITE,{init_per_group,group1,[]},ok}},

      {?eh,tc_start,{ct_scope_per_group_state_cth_SUITE,test_case}},
      {?eh,cth,{'_',pre_init_per_testcase,[ct_scope_per_group_state_cth_SUITE,test_case,'$proplist',[test]]}},
      {?eh,cth,{'_',post_end_per_testcase,[ct_scope_per_group_state_cth_SUITE,test_case,'$proplist',ok,[test]]}},
      {?eh,tc_done,{ct_scope_per_group_state_cth_SUITE,test_case,ok}},

      {?eh,tc_start,{ct_scope_per_group_state_cth_SUITE,{end_per_group,group1,[]}}},
      {?eh,cth,{'_',pre_end_per_group,[ct_scope_per_group_state_cth_SUITE,group1,'$proplist',[test]]}},
      {?eh,cth,{'_',post_end_per_group,[ct_scope_per_group_state_cth_SUITE,group1,'$proplist','_',[test]]}},
      {?eh,cth,{'_',terminate,[[test]]}},
      {?eh,tc_done,{ct_scope_per_group_state_cth_SUITE,{end_per_group,group1,[]},ok}}],

     {?eh,tc_start,{ct_scope_per_group_state_cth_SUITE,end_per_suite}},
     {?eh,tc_done,{ct_scope_per_group_state_cth_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(fail_pre_suite_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',init,['_',[]]}},

     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist',
					{fail,"Test failure"},[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,
                   {failed, {error,"Test failure"}}}},
     {?eh,cth,{'_',on_tc_fail,
	       [ct_cth_empty_SUITE,init_per_suite,{failed,"Test failure"},[]]}},


     {?eh,tc_auto_skip,{ct_cth_empty_SUITE,test_case,
                        {failed,{ct_cth_empty_SUITE,init_per_suite,
				 {failed,"Test failure"}}}}},
     {?eh,cth,{'_',on_tc_skip,
	       [ct_cth_empty_SUITE,test_case, {tc_auto_skip,
			    {failed, {ct_cth_empty_SUITE, init_per_suite,
				     {failed, "Test failure"}}}},[]]}},


     {?eh,tc_auto_skip, {ct_cth_empty_SUITE, end_per_suite,
                         {failed, {ct_cth_empty_SUITE, init_per_suite,
				   {failed, "Test failure"}}}}},
     {?eh,cth,{'_',on_tc_skip,
	       [ct_cth_empty_SUITE,end_per_suite, {tc_auto_skip,
				{failed, {ct_cth_empty_SUITE, init_per_suite,
					  {failed, "Test failure"}}}},[]]}},


     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth, {'_',terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(double_fail_pre_suite_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,tc_start,{'_',init_per_suite}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,cth,{'_',pre_init_per_suite,['_','$proplist',[]]}},
     {?eh,cth,{'_',post_init_per_suite,['_','$proplist',
					{fail,"Test failure"},[]]}},
     {?eh,cth, {empty_cth,terminate,[[]]}},

     {?eh,tc_start,{'_',init_per_suite}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,cth, {empty_cth,terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(fail_post_suite_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,
		   {failed,{error,"Test failure"}}}},
     {?eh,cth,{'_',on_tc_fail,[ct_cth_empty_SUITE,init_per_suite, {failed,"Test failure"}, []]}},

     {?eh,tc_auto_skip,{ct_cth_empty_SUITE,test_case,
                        {failed,{ct_cth_empty_SUITE,init_per_suite,
				 {failed,"Test failure"}}}}},
     {?eh,cth,{'_',on_tc_skip,[ct_cth_empty_SUITE,test_case,{tc_auto_skip,'_'},[]]}},

     {?eh,tc_auto_skip, {ct_cth_empty_SUITE, end_per_suite,
                         {failed, {ct_cth_empty_SUITE, init_per_suite,
				   {failed, "Test failure"}}}}},
     {?eh,cth,{'_',on_tc_skip,[ct_cth_empty_SUITE,end_per_suite,{tc_auto_skip,'_'},[]]}},

     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth, {'_',terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(skip_pre_suite_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist',{skip,"Test skip"},[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,{skipped,"Test skip"}}},
     {?eh,cth,{'_',on_tc_skip,
	       [ct_cth_empty_SUITE,init_per_suite,{tc_user_skip,{skipped,"Test skip"}},[]]}},

     {?eh,tc_user_skip,{ct_cth_empty_SUITE,test_case,"Test skip"}},
     {?eh,cth,{'_',on_tc_skip,[ct_cth_empty_SUITE,test_case,{tc_user_skip,"Test skip"},[]]}},

     {?eh,tc_user_skip, {ct_cth_empty_SUITE, end_per_suite,"Test skip"}},

     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth, {'_',terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(skip_pre_end_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,tc_start,{ct_scope_per_group_cth_SUITE,init_per_suite}},
     {?eh,tc_done,{ct_scope_per_group_cth_SUITE,init_per_suite,ok}},

     [{?eh,tc_start,{ct_scope_per_group_cth_SUITE,{init_per_group,group1,[]}}},
      {?eh,cth,{'_',id,[[]]}},
      {?eh,cth,{'_',init,['_',[]]}},
      {?eh,cth,{'_',post_init_per_group,[ct_scope_per_group_cth_SUITE,group1,'$proplist','$proplist',[]]}},
      {?eh,tc_done,{ct_scope_per_group_cth_SUITE,{init_per_group,group1,[]},ok}},

      {?eh,tc_start,{ct_scope_per_group_cth_SUITE,test_case}},
      {?eh,cth,{'_',pre_init_per_testcase,[ct_scope_per_group_cth_SUITE,test_case,'$proplist',[]]}},
      {?eh,cth,{'_',post_end_per_testcase,[ct_scope_per_group_cth_SUITE,test_case,'$proplist',ok,[]]}},
      {?eh,tc_done,{ct_scope_per_group_cth_SUITE,test_case,ok}},

      {?eh,tc_start,{ct_scope_per_group_cth_SUITE,{end_per_group,group1,[]}}},
      {?eh,cth,{'_',pre_end_per_group,[ct_scope_per_group_cth_SUITE,group1,'$proplist',[]]}},
      {?eh,cth,{'_',post_end_per_group,[ct_scope_per_group_cth_SUITE,group1,'$proplist','_',[]]}},
      {?eh,tc_done,{ct_scope_per_group_cth_SUITE,{end_per_group,group1,[]},
		    {skipped,"Test skip"}}}],
      {?eh,cth,{'_',on_tc_skip,[ct_scope_per_group_cth_SUITE,
                                {end_per_group,group1},
				{tc_user_skip,{skipped,"Test skip"}},
				[]]}},
     {?eh,tc_start,{ct_scope_per_group_cth_SUITE,end_per_suite}},
     {?eh,tc_done,{ct_scope_per_group_cth_SUITE,end_per_suite,
		   {skipped,"Test skip"}}},
     {?eh,cth,{'_',on_tc_skip,[ct_scope_per_group_cth_SUITE,
                               end_per_suite,
			       {tc_user_skip,{skipped,"Test skip"}},
			       []]}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{'_',terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(skip_post_suite_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',init,['_',[]]}},

     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{'_',post_init_per_suite,[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,{skipped,"Test skip"}}},
     {?eh,cth,{'_',on_tc_skip,
	       [ct_cth_empty_SUITE,init_per_suite,{tc_user_skip,{skipped,"Test skip"}},[]]}},

     {?eh,tc_user_skip,{ct_cth_empty_SUITE,test_case,"Test skip"}},
     {?eh,cth,{'_',on_tc_skip,[ct_cth_empty_SUITE,test_case,{tc_user_skip,"Test skip"},[]]}},

     {?eh,tc_user_skip, {ct_cth_empty_SUITE, end_per_suite,"Test skip"}},

     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{'_',terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(skip_pre_init_tc_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,init,['_',[]]}},
     {?eh,start_info,{1,1,1}},
     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,cth,{empty_cth,pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_suite,
               [ct_cth_empty_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}},
     {?eh,tc_start,{ct_cth_empty_SUITE,test_case}},
     {?eh,cth,{empty_cth,pre_init_per_testcase,
               [ct_cth_empty_SUITE,test_case,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_testcase,
               [ct_cth_empty_SUITE,test_case,'$proplist',
                {skip,"Skipped in pre_init_per_testcase"},
                []]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,test_case,
                   {skipped,"Skipped in pre_init_per_testcase"}}},
     {?eh,cth,{empty_cth,on_tc_skip,
               [ct_cth_empty_SUITE,test_case,
                {tc_user_skip,{skipped,"Skipped in pre_init_per_testcase"}},
                []]}},
     {?eh,test_stats,{0,0,{1,0}}},
     {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}},
     {?eh,cth,{empty_cth,pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_suite,
               [ct_cth_empty_SUITE,'$proplist',ok,[]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{empty_cth,terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(recover_post_suite_cth) ->
    Suite = ct_cth_fail_per_suite_SUITE,
    [
     {?eh,start_logging,'_'},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,tc_start,{Suite,init_per_suite}},
     {?eh,cth,{'_',pre_init_per_suite,[Suite,'$proplist','$proplist']}},
     {?eh,cth,{'_',post_init_per_suite,[Suite,contains([tc_status]),
					{'EXIT',{'_','_'}},[]]}},
     {?eh,tc_done,{Suite,init_per_suite,ok}},

     {?eh,tc_start,{Suite,test_case}},
     {?eh,cth,{'_',pre_init_per_testcase,
	       [Suite,test_case, not_contains([tc_status]),[]]}},
     {?eh,cth,{'_',post_end_per_testcase,
	       [Suite,test_case, contains([tc_status]),'_',[]]}},
     {?eh,tc_done,{Suite,test_case,ok}},

     {?eh,tc_start,{Suite,end_per_suite}},
     {?eh,cth,{'_',pre_end_per_suite,
	       [Suite,not_contains([tc_status]),[]]}},
     {?eh,cth,{'_',post_end_per_suite,
	       [Suite,not_contains([tc_status]),'_',[]]}},
     {?eh,tc_done,{Suite,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{'_',terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(update_config_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',init,['_',[]]}},

     {?eh,tc_start,{ct_update_config_SUITE,init_per_suite}},
     {?eh,cth,{'_',pre_init_per_suite,
	       [ct_update_config_SUITE,contains([]),[]]}},
     {?eh,cth,{'_',post_init_per_suite,
	       [ct_update_config_SUITE,
		'$proplist',
		contains(
			  [init_per_suite,
			   pre_init_per_suite]),
		[]]}},
     {?eh,tc_done,{ct_update_config_SUITE,init_per_suite,ok}},

     {?eh,tc_start,{ct_update_config_SUITE, {init_per_group,group1,[]}}},
     {?eh,cth,{'_',pre_init_per_group,
	       [ct_update_config_SUITE,
                group1,contains(
			 [post_init_per_suite,
			  init_per_suite,
			  pre_init_per_suite]),
		[]]}},
     {?eh,cth,{'_',post_init_per_group,
	       [ct_update_config_SUITE,
                group1,
		contains(
		  [post_init_per_suite,
		   init_per_suite,
		   pre_init_per_suite]),
		contains(
		  [init_per_group,
		   pre_init_per_group,
		   post_init_per_suite,
		   init_per_suite,
		   pre_init_per_suite]),
	       []]}},
     {?eh,tc_done,{ct_update_config_SUITE,{init_per_group,group1,[]},ok}},

     {?eh,tc_start,{ct_update_config_SUITE,test_case}},
     {?eh,cth,{'_',pre_init_per_testcase,
	       [ct_update_config_SUITE,
                test_case,contains(
			    [post_init_per_group,
			     init_per_group,
			     pre_init_per_group,
			     post_init_per_suite,
			     init_per_suite,
			     pre_init_per_suite]),
		[]]}},
     {?eh,cth,{'_',post_end_per_testcase,
	       [ct_update_config_SUITE,
                test_case,contains(
			    [init_per_testcase,
			     pre_init_per_testcase,
			     post_init_per_group,
			     init_per_group,
			     pre_init_per_group,
			     post_init_per_suite,
			     init_per_suite,
			     pre_init_per_suite]),
		ok,[]]}},
     {?eh,tc_done,{ct_update_config_SUITE,test_case,ok}},

     {?eh,tc_start,{ct_update_config_SUITE, {end_per_group,group1,[]}}},
     {?eh,cth,{'_',pre_end_per_group,
	       [ct_update_config_SUITE,
                group1,contains(
			 [post_init_per_group,
			  init_per_group,
			  pre_init_per_group,
			  post_init_per_suite,
			  init_per_suite,
			  pre_init_per_suite]),
		[]]}},
     {?eh,cth,{'_',post_end_per_group,
	       [ct_update_config_SUITE,
                group1,
		contains(
		  [pre_end_per_group,
		   post_init_per_group,
		   init_per_group,
		   pre_init_per_group,
		   post_init_per_suite,
		   init_per_suite,
		   pre_init_per_suite]),
	       ok,[]]}},
     {?eh,tc_done,{ct_update_config_SUITE,{end_per_group,group1,[]},ok}},

     {?eh,tc_start,{ct_update_config_SUITE,end_per_suite}},
     {?eh,cth,{'_',pre_end_per_suite,
	       [ct_update_config_SUITE,contains(
					 [post_init_per_suite,
					  init_per_suite,
					  pre_init_per_suite]),
		[]]}},
     {?eh,cth,{'_',post_end_per_suite,
	       [ct_update_config_SUITE,contains(
					 [pre_end_per_suite,
					  post_init_per_suite,
					  init_per_suite,
					  pre_init_per_suite]),
	       '_',[]]}},
     {?eh,tc_done,{ct_update_config_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{'_',terminate,[contains(
				[post_end_per_suite,
				 pre_end_per_suite,
				 post_init_per_suite,
				 init_per_suite,
				 pre_init_per_suite])]}},
     {?eh,stop_logging,[]}
    ];

test_events(state_update_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,tc_start,{'_',init_per_suite}},

     {?eh,tc_done,{'_',end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{'_',terminate,[contains(
				[post_end_per_suite,pre_end_per_suite,
				 post_end_per_group,pre_end_per_group,
				 {not_in_order,
				  [post_end_per_testcase,pre_init_per_testcase,
				   on_tc_skip,post_end_per_testcase,
				   pre_init_per_testcase,on_tc_fail,
				   post_end_per_testcase,pre_init_per_testcase]
				 },
				 post_init_per_group,pre_init_per_group,
				 post_init_per_suite,pre_init_per_suite,
				 init])]}},
     {?eh,cth,{'_',terminate,[contains(
				[post_end_per_suite,pre_end_per_suite,
				 post_end_per_group,pre_end_per_group,
				 {not_in_order,
				  [post_end_per_testcase,pre_init_per_testcase,
				   on_tc_skip,post_end_per_testcase,
				   pre_init_per_testcase,on_tc_fail,
				   post_end_per_testcase,pre_init_per_testcase]
				 },
				 post_init_per_group,pre_init_per_group,
				 post_init_per_suite,pre_init_per_suite,
				 init]
			       )]}},
     {?eh,stop_logging,[]}
    ];

test_events(options_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,init,['_',[test]]}},
     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,cth,{empty_cth,pre_init_per_suite,
	       [ct_cth_empty_SUITE,'$proplist',[test]]}},
     {?eh,cth,{empty_cth,post_init_per_suite,
	       [ct_cth_empty_SUITE,'$proplist','$proplist',[test]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}},

     {?eh,tc_start,{ct_cth_empty_SUITE,test_case}},
     {?eh,cth,{empty_cth,pre_init_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',[test]]}},
     {?eh,cth,{empty_cth,post_end_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist','_',[test]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}},

     {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}},
     {?eh,cth,{empty_cth,pre_end_per_suite,
	       [ct_cth_empty_SUITE,'$proplist',[test]]}},
     {?eh,cth,{empty_cth,post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[test]]}},
     {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{empty_cth,terminate,[[test]]}},
     {?eh,stop_logging,[]}
    ];

test_events(same_id_cth) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',id,[[]]}},
     {?eh,cth,{'_',id,[[]]}},
     {?eh,cth,{'_',init,[same_id_cth,[]]}},
     {?eh,tc_start,{ct_cth_empty_SUITE,init_per_suite}},
     {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {negative,
       {?eh,cth,{'_',pre_init_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
      {?eh,cth,{'_',post_init_per_suite,
		[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}}},
     {negative,
      {?eh,cth,{'_',post_init_per_suite,
		[ct_cth_empty_SUITE,'$proplist','$proplist',[]]}},
      {?eh,tc_done,{ct_cth_empty_SUITE,init_per_suite,ok}}},

     {?eh,tc_start,{ct_cth_empty_SUITE,test_case}},
     {?eh,cth,{'_',pre_init_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',[]]}},
     {negative,
      {?eh,cth,{'_',pre_init_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',[]]}},
      {?eh,cth,{'_',post_end_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',ok,[]]}}},
     {negative,
      {?eh,cth,{'_',post_end_per_testcase,[ct_cth_empty_SUITE,test_case,'$proplist',ok,[]]}},
      {?eh,tc_done,{ct_cth_empty_SUITE,test_case,ok}}},

     {?eh,tc_start,{ct_cth_empty_SUITE,end_per_suite}},
     {?eh,cth,{'_',pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
     {negative,
      {?eh,cth,{'_',pre_end_per_suite,[ct_cth_empty_SUITE,'$proplist',[]]}},
      {?eh,cth,{'_',post_end_per_suite,[ct_cth_empty_SUITE,'$proplist','_',[]]}}},
     {negative,
      {?eh,cth,{'_',post_end_per_suite,
		[ct_cth_empty_SUITE,'$proplist','_',[]]}},
      {?eh,tc_done,{ct_cth_empty_SUITE,end_per_suite,ok}}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{'_',terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(fail_n_skip_with_minimal_cth) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{'_',init,['_',[]]}},
     {?eh,tc_start,{'_',init_per_suite}},

     {parallel,
      [{?eh,tc_start,{ct_cth_fail_one_skip_one_SUITE,{init_per_group,
						      group1,[parallel]}}},
       {?eh,tc_done,{ct_cth_fail_one_skip_one_SUITE,{init_per_group,
						     group1,[parallel]},ok}},
       {parallel,
	[{?eh,tc_start,{ct_cth_fail_one_skip_one_SUITE,{init_per_group,
							group2,[parallel]}}},
	 {?eh,tc_done,{ct_cth_fail_one_skip_one_SUITE,{init_per_group,
						       group2,[parallel]},ok}},
	 %% Verify that 'skip' as well as 'skipped' works
	 {?eh,tc_start,{ct_cth_fail_one_skip_one_SUITE,test_case2}},
	 {?eh,tc_done,{ct_cth_fail_one_skip_one_SUITE,test_case2,{skipped,"skip it"}}},
	 {?eh,tc_start,{ct_cth_fail_one_skip_one_SUITE,test_case3}},
	 {?eh,tc_done,{ct_cth_fail_one_skip_one_SUITE,test_case3,{skipped,"skip it"}}},
	 {?eh,cth,{empty_cth,on_tc_skip,[ct_cth_fail_one_skip_one_SUITE,
                                         {test_case2,group2},
					 {tc_user_skip,{skipped,"skip it"}},
					 []]}},
	 {?eh,cth,{empty_cth,on_tc_skip,[ct_cth_fail_one_skip_one_SUITE,
                                         {test_case3,group2},
					 {tc_user_skip,{skipped,"skip it"}},
					 []]}},
	 {?eh,tc_start,{ct_cth_fail_one_skip_one_SUITE,{end_per_group,
							group2,[parallel]}}},
	 {?eh,tc_done,{ct_cth_fail_one_skip_one_SUITE,{end_per_group,group2,
						       [parallel]},ok}}]},
       {?eh,tc_start,{ct_cth_fail_one_skip_one_SUITE,{end_per_group,
						      group1,[parallel]}}},
       {?eh,tc_done,{ct_cth_fail_one_skip_one_SUITE,{end_per_group,
						     group1,[parallel]},ok}}]},

     {?eh,tc_done,{'_',end_per_suite,ok}},
     {?eh,cth,{'_',terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(prio_cth) ->
    GenPre = fun(Func,States) when Func==pre_init_per_suite;
                                   Func==pre_end_per_suite ->
		     [{?eh,cth,{'_',Func,['_','_',State]}} ||
                         State <- States];
                (Func,States) ->
		     [{?eh,cth,{'_',Func,['_','_','_',State]}} ||
			 State <- States]
	     end,

    GenPost = fun(Func,States) when Func==post_init_per_suite;
                                    Func==post_end_per_suite ->
		      [{?eh,cth,{'_',Func,['_','_','_',State]}} ||
			  State <- States];
                 (Func,States) ->
		      [{?eh,cth,{'_',Func,['_','_','_','_',State]}} ||
			  State <- States]

              end,

    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}] ++

	[{?eh,tc_start,{ct_cth_prio_SUITE,init_per_suite}}] ++
	GenPre(pre_init_per_suite,
	       [[1100,100],[800],[900],[1000],[1200,1050],[1100],[1200]]) ++
	GenPost(post_init_per_suite,
		[[1100,100],[600,200],[600,600],[700],[800],[900],[1000],
		 [1200,1050],[1100],[1200]]) ++
	[{?eh,tc_done,{ct_cth_prio_SUITE,init_per_suite,ok}},


	 [{?eh,tc_start,{ct_cth_prio_SUITE,{init_per_group,'_',[]}}}] ++
	     GenPre(pre_init_per_group,
		    [[1100,100],[600,200],[600,600],[700],[800],
		     [900],[1000],[1200,1050],[1100],[1200]]) ++
	     GenPost(post_init_per_group,
		     [[1100,100],[600,200],[600,600],[600],[700],[800],
		      [900],[900,900],[500,900],[1000],[1200,1050],
		      [1100],[1200]]) ++
	     [{?eh,tc_done,{ct_cth_prio_SUITE,{init_per_group,'_',[]},ok}}] ++

	     [{?eh,tc_start,{ct_cth_prio_SUITE,test_case}}] ++
	     GenPre(pre_init_per_testcase,
		    [[1100,100],[600,200],[600,600],[600],[700],[800],
		     [900],[900,900],[500,900],[1000],[1200,1050],
		     [1100],[1200]]) ++
	     GenPost(post_end_per_testcase,
		     lists:reverse(
		       [[1100,100],[600,200],[600,600],[600],[700],[800],
			[900],[900,900],[500,900],[1000],[1200,1050],
			[1100],[1200]])) ++
	     [{?eh,tc_done,{ct_cth_prio_SUITE,test_case,ok}},

	      {?eh,tc_start,{ct_cth_prio_SUITE,{end_per_group,'_',[]}}}] ++
	     GenPre(pre_end_per_group,
		    lists:reverse(
		      [[1100,100],[600,200],[600,600],[600],[700],[800],
		       [900],[900,900],[500,900],[1000],[1200,1050],
		       [1100],[1200]])) ++
	     GenPost(post_end_per_group,
		     lists:reverse(
		       [[1100,100],[600,200],[600,600],[600],[700],[800],
			[900],[900,900],[500,900],[1000],[1200,1050],
			[1100],[1200]])) ++
	     [{?eh,tc_done,{ct_cth_prio_SUITE,{end_per_group,'_',[]},ok}}],

	 {?eh,tc_start,{ct_cth_prio_SUITE,end_per_suite}}] ++
	GenPre(pre_end_per_suite,
	       lists:reverse(
		 [[1100,100],[600,200],[600,600],[700],[800],[900],[1000],
		  [1200,1050],[1100],[1200]])) ++
	GenPost(post_end_per_suite,
		lists:reverse(
		  [[1100,100],[600,200],[600,600],[700],[800],[900],[1000],
		   [1200,1050],[1100],[1200]])) ++
	[{?eh,tc_done,{ct_cth_prio_SUITE,end_per_suite,ok}},
	 {?eh,test_done,{'DEF','STOP_TIME'}},
	 {?eh,stop_logging,[]}];

test_events(no_config) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,init,[verify_config_cth,[]]}},
     {?eh,start_info,{1,1,2}},
     {?eh,tc_start,{ct_framework,init_per_suite}},
     {?eh,cth,{empty_cth,pre_init_per_suite,
	       [ct_no_config_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_suite,
	       [ct_no_config_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_framework,init_per_suite,ok}},
     {?eh,tc_start,{ct_no_config_SUITE,test_case_1}},
     {?eh,cth,{empty_cth,pre_init_per_testcase,
	       [ct_no_config_SUITE,test_case_1,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_testcase,
	       [ct_no_config_SUITE,test_case_1,'$proplist',ok,[]]}},
     {?eh,tc_done,{ct_no_config_SUITE,test_case_1,ok}},
     {?eh,test_stats,{1,0,{0,0}}},
     [{?eh,tc_start,{ct_framework,{init_per_group,test_group,'$proplist'}}},
      {?eh,cth,{empty_cth,pre_init_per_group,
		[ct_no_config_SUITE,test_group,'$proplist',[]]}},
      {?eh,cth,{empty_cth,post_init_per_group,
		[ct_no_config_SUITE,test_group,'$proplist','$proplist',[]]}},
      {?eh,tc_done,{ct_framework,
		    {init_per_group,test_group,'$proplist'},ok}},
      {?eh,tc_start,{ct_no_config_SUITE,test_case_2}},
      {?eh,cth,{empty_cth,pre_init_per_testcase,
		[ct_no_config_SUITE,test_case_2,'$proplist',[]]}},
      {?eh,cth,{empty_cth,post_end_per_testcase,
		[ct_no_config_SUITE,test_case_2,'$proplist',ok,[]]}},
      {?eh,tc_done,{ct_no_config_SUITE,test_case_2,ok}},
      {?eh,test_stats,{2,0,{0,0}}},
      {?eh,tc_start,{ct_framework,{end_per_group,test_group,'$proplist'}}},
      {?eh,cth,{empty_cth,pre_end_per_group,
		[ct_no_config_SUITE,test_group,'$proplist',[]]}},
      {?eh,cth,{empty_cth,post_end_per_group,
		[ct_no_config_SUITE,test_group,'$proplist',ok,[]]}},
      {?eh,tc_done,{ct_framework,{end_per_group,test_group,'$proplist'},ok}}],
     {?eh,tc_start,{ct_framework,end_per_suite}},
     {?eh,cth,{empty_cth,pre_end_per_suite,
	       [ct_no_config_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_suite,
	       [ct_no_config_SUITE,'$proplist',ok,[]]}},
     {?eh,tc_done,{ct_framework,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{empty_cth,terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(no_init_suite_config) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,init,[{'_','_','_'},[]]}},
     {?eh,start_info,{1,1,1}},
     {?eh,tc_start,{ct_no_init_suite_config_SUITE,init_per_suite}},
     {?eh,cth,{empty_cth,pre_init_per_suite,
	       [ct_no_init_suite_config_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_suite,
	       [ct_no_init_suite_config_SUITE,'$proplist','_',[]]}},
     {?eh,tc_done,{ct_no_init_suite_config_SUITE,init_per_suite,
                   {failed,{error,{undef,'_'}}}}},
     {?eh,cth,{empty_cth,on_tc_fail,[ct_no_init_suite_config_SUITE,
                                     init_per_suite,
                                     {failed,{undef,'_'}},[]]}},
      {?eh,tc_auto_skip,{ct_no_init_suite_config_SUITE,test_case,
                         {failed,{ct_no_init_suite_config_SUITE,init_per_suite,
                                  {'EXIT',{undef,'_'}}}}}},
     {?eh,cth,{empty_cth,on_tc_skip,
               [ct_no_init_suite_config_SUITE,
                test_case,
                {tc_auto_skip,
                 {failed,{ct_no_init_suite_config_SUITE,init_per_suite,
                          {'EXIT',{undef,'_'}}}}},
                []]}},
     {?eh,test_stats,{0,0,{0,1}}},
     {?eh,tc_auto_skip,{ct_no_init_suite_config_SUITE,end_per_suite,
                        {failed,{ct_no_init_suite_config_SUITE,init_per_suite,
                                 {'EXIT',{undef,'_'}}}}}},
     {?eh,cth,{empty_cth,on_tc_skip,
               [ct_no_init_suite_config_SUITE,
                end_per_suite,
                {tc_auto_skip,
                 {failed,{ct_no_init_suite_config_SUITE,init_per_suite,
                          {'EXIT',{undef,'_'}}}}},
                []]}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{empty_cth,terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(no_init_config) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,init,[{'_','_','_'},[]]}},
     {?eh,start_info,{1,1,2}},
     {?eh,tc_start,{ct_no_init_config_SUITE,init_per_suite}},
     {?eh,cth,{empty_cth,pre_init_per_suite,
	       [ct_no_init_config_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_suite,
	       [ct_no_init_config_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_no_init_config_SUITE,init_per_suite,ok}},
     {?eh,tc_start,{ct_no_init_config_SUITE,test_case_1}},
     {?eh,cth,{empty_cth,pre_init_per_testcase,
	       [ct_no_init_config_SUITE,test_case_1,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_testcase,
	       [ct_no_init_config_SUITE,test_case_1,'$proplist',ok,[]]}},
     {?eh,tc_done,{ct_no_init_config_SUITE,test_case_1,ok}},
     {?eh,test_stats,{1,0,{0,0}}},
     [{?eh,tc_start,{ct_no_init_config_SUITE,{init_per_group,test_group,[]}}},
      {?eh,cth,{empty_cth,pre_init_per_group,
		[ct_no_init_config_SUITE,test_group,'$proplist',[]]}},
      {?eh,cth,{empty_cth,post_init_per_group,
		[ct_no_init_config_SUITE,test_group,'$proplist','_',[]]}},
      {?eh,tc_done,{ct_no_init_config_SUITE,{init_per_group,test_group,[]},
                    {failed,{error,{undef,'_'}}}}},
      {?eh,cth,{empty_cth,on_tc_fail,[ct_no_init_config_SUITE,
                                      {init_per_group,test_group},
                                      {failed,{undef,'_'}},[]]}},
      {?eh,tc_auto_skip,{ct_no_init_config_SUITE,{test_case_2,test_group},
                         {failed,{ct_no_init_config_SUITE,init_per_group,
                                  {'EXIT',{undef,'_'}}}}}},
      {?eh,cth,{empty_cth,on_tc_skip,[ct_no_init_config_SUITE,
                                      {test_case_2,test_group},
                                      {tc_auto_skip,
                                       {failed,
                                        {ct_no_init_config_SUITE,init_per_group,
                                         {'EXIT',{undef,'_'}}}}},
                                       []]}},
      {?eh,test_stats,{1,0,{0,1}}},
      {?eh,tc_auto_skip,{ct_no_init_config_SUITE,{end_per_group,test_group},
                         {failed,{ct_no_init_config_SUITE,init_per_group,
                                  {'EXIT',{undef,'_'}}}}}},
      {?eh,cth,{empty_cth,on_tc_skip,[ct_no_init_config_SUITE,
                                      {end_per_group,test_group},
                                      {tc_auto_skip,
                                       {failed,
                                        {ct_no_init_config_SUITE,init_per_group,
                                         {'EXIT',{undef,'_'}}}}},
                                       []]}}],
     {?eh,tc_start,{ct_no_init_config_SUITE,end_per_suite}},
     {?eh,cth,{empty_cth,pre_end_per_suite,
	       [ct_no_init_config_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_suite,
	       [ct_no_init_config_SUITE,'$proplist',ok,[]]}},
     {?eh,tc_done,{ct_no_init_config_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{empty_cth,terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(no_end_config) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,init,[{'_','_','_'},[]]}},
     {?eh,start_info,{1,1,2}},
     {?eh,tc_start,{ct_no_end_config_SUITE,init_per_suite}},
     {?eh,cth,{empty_cth,pre_init_per_suite,
	       [ct_no_end_config_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_suite,
	       [ct_no_end_config_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{ct_no_end_config_SUITE,init_per_suite,ok}},
     {?eh,tc_start,{ct_no_end_config_SUITE,test_case_1}},
     {?eh,cth,{empty_cth,pre_init_per_testcase,
	       [ct_no_end_config_SUITE,test_case_1,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_testcase,
	       [ct_no_end_config_SUITE,test_case_1,'$proplist',ok,[]]}},
     {?eh,tc_done,{ct_no_end_config_SUITE,test_case_1,ok}},
     {?eh,test_stats,{1,0,{0,0}}},
     [{?eh,tc_start,{ct_no_end_config_SUITE,
                     {init_per_group,test_group,'$proplist'}}},
      {?eh,cth,{empty_cth,pre_init_per_group,
		[ct_no_end_config_SUITE,test_group,'$proplist',[]]}},
      {?eh,cth,{empty_cth,post_init_per_group,
		[ct_no_end_config_SUITE,test_group,'$proplist','$proplist',[]]}},
      {?eh,tc_done,{ct_no_end_config_SUITE,
		    {init_per_group,test_group,'$proplist'},ok}},
      {?eh,tc_start,{ct_no_end_config_SUITE,test_case_2}},
      {?eh,cth,{empty_cth,pre_init_per_testcase,
		[ct_no_end_config_SUITE,test_case_2,'$proplist',[]]}},
      {?eh,cth,{empty_cth,post_end_per_testcase,
		[ct_no_end_config_SUITE,test_case_2,'$proplist',ok,[]]}},
      {?eh,tc_done,{ct_no_end_config_SUITE,test_case_2,ok}},
      {?eh,test_stats,{2,0,{0,0}}},
      {?eh,tc_start,{ct_no_end_config_SUITE,
                     {end_per_group,test_group,'$proplist'}}},
      {?eh,cth,{empty_cth,pre_end_per_group,
		[ct_no_end_config_SUITE,test_group,'$proplist',[]]}},
      {?eh,cth,{empty_cth,post_end_per_group,
		[ct_no_end_config_SUITE,test_group,'$proplist','_',[]]}},
      {?eh,tc_done,{ct_no_end_config_SUITE,{end_per_group,test_group,[]},
                    {failed,{error,{undef,'_'}}}}},
      {?eh,cth,{empty_cth,on_tc_fail,[ct_no_end_config_SUITE,
                                      {end_per_group,test_group},
                                      {failed,{undef,'_'}},[]]}}],
     {?eh,tc_start,{ct_no_end_config_SUITE,end_per_suite}},
     {?eh,cth,{empty_cth,pre_end_per_suite,
	       [ct_no_end_config_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_suite,
	       [ct_no_end_config_SUITE,'$proplist','_',[]]}},
     {?eh,tc_done,{ct_no_end_config_SUITE,end_per_suite,
                   {failed,{error,{undef,'_'}}}}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{empty_cth,terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(data_dir) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,init,[verify_data_dir_cth,[]]}},
     {?eh,start_info,{1,1,2}},
     {?eh,tc_start,{ct_framework,init_per_suite}},
     {?eh,cth,{empty_cth,pre_init_per_suite,
	       [ct_data_dir_SUITE,'$proplist',[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
     {?eh,cth,{empty_cth,post_init_per_suite,
	       [ct_data_dir_SUITE,'$proplist','$proplist',[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
     {?eh,tc_done,{ct_framework,init_per_suite,ok}},
     {?eh,tc_start,{ct_data_dir_SUITE,test_case_1}},
     {?eh,cth,{empty_cth,pre_init_per_testcase,
	       [ct_data_dir_SUITE,test_case_1,'$proplist',[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
     {?eh,cth,{empty_cth,post_end_per_testcase,
	       [ct_data_dir_SUITE,test_case_1,'$proplist',ok,[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
     {?eh,tc_done,{ct_data_dir_SUITE,test_case_1,ok}},
     {?eh,test_stats,{1,0,{0,0}}},
     [{?eh,tc_start,{ct_framework,{init_per_group,test_group,'$proplist'}}},
      {?eh,cth,{empty_cth,pre_init_per_group,
		[ct_data_dir_SUITE,test_group,'$proplist',[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
      {?eh,cth,{empty_cth,post_init_per_group,
		[ct_data_dir_SUITE,test_group,'$proplist','$proplist',[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
      {?eh,tc_done,{ct_framework,
		    {init_per_group,test_group,'$proplist'},ok}},
      {?eh,tc_start,{ct_data_dir_SUITE,test_case_2}},
      {?eh,cth,{empty_cth,pre_init_per_testcase,
		[ct_data_dir_SUITE,test_case_2,'$proplist',[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
      {?eh,cth,{empty_cth,post_end_per_testcase,
		[ct_data_dir_SUITE,test_case_2,'$proplist',ok,[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
      {?eh,tc_done,{ct_data_dir_SUITE,test_case_2,ok}},
      {?eh,test_stats,{2,0,{0,0}}},
      {?eh,tc_start,{ct_framework,{end_per_group,test_group,'$proplist'}}},
      {?eh,cth,{empty_cth,pre_end_per_group,
		[ct_data_dir_SUITE,test_group,'$proplist',[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
      {?eh,cth,{empty_cth,post_end_per_group,
		[ct_data_dir_SUITE,test_group,'$proplist',ok,[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
      {?eh,tc_done,{ct_framework,{end_per_group,test_group,'$proplist'},ok}}],
     {?eh,tc_start,{ct_framework,end_per_suite}},
     {?eh,cth,{empty_cth,pre_end_per_suite,
	       [ct_data_dir_SUITE,'$proplist',[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
     {?eh,cth,{empty_cth,post_end_per_suite,
	       [ct_data_dir_SUITE,'$proplist',ok,[{data_dir_name,"ct_data_dir_SUITE_data"}]]}},
     {?eh,tc_done,{ct_framework,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(cth_log) ->
    [{?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,tc_start,{cth_log_SUITE,init_per_suite}},

     {parallel,
      [{?eh,tc_start,{ct_framework,{init_per_group,g1,
				    [{suite,cth_log_SUITE},parallel]}}},
       {?eh,tc_done,{ct_framework,{init_per_group,g1,
				   [{suite,cth_log_SUITE},parallel]},ok}},
       {?eh,test_stats,{30,0,{0,0}}},
       {?eh,tc_start,{ct_framework,{end_per_group,g1,
				    [{suite,cth_log_SUITE},parallel]}}},
       {?eh,tc_done,{ct_framework,{end_per_group,g1,
				   [{suite,cth_log_SUITE},parallel]},ok}}]},

     {?eh,tc_done,{cth_log_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,stop_logging,[]}
    ];

test_events(fallback) ->
    [
     {?eh,start_logging,{'DEF','RUNDIR'}},
     {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
     {?eh,cth,{empty_cth,id,[[]]}},
     {?eh,cth,{empty_cth,init,[{'_','_','_'},[]]}},
     {?eh,tc_start,{all_hook_callbacks_SUITE,init_per_suite}},
     {?eh,cth,{empty_cth,pre_init_per_suite,
	       [all_hook_callbacks_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_suite,
	       [all_hook_callbacks_SUITE,'$proplist','$proplist',[]]}},
     {?eh,tc_done,{all_hook_callbacks_SUITE,init_per_suite,ok}},

     [{?eh,tc_start,{ct_framework,{init_per_group,test_group,'$proplist'}}},
      {?eh,cth,{empty_cth,pre_init_per_group,
		[fallback_nosuite,test_group,'$proplist',[]]}},
      {?eh,cth,{empty_cth,post_init_per_group,
		[fallback_nosuite,test_group,'$proplist','$proplist',[]]}},
      {?eh,tc_done,{ct_framework,
		    {init_per_group,test_group,'$proplist'},ok}},
      {?eh,tc_start,{all_hook_callbacks_SUITE,test_case}},
      {?eh,cth,{empty_cth,pre_init_per_testcase,
		[fallback_nosuite,test_case,'$proplist',[]]}},
      {?eh,cth,{empty_cth,post_end_per_testcase,
		[fallback_nosuite,test_case,'$proplist',ok,[]]}},
      {?eh,tc_done,{all_hook_callbacks_SUITE,test_case,ok}},
      {?eh,test_stats,{1,0,{0,0}}},
      {?eh,tc_start,{ct_framework,{end_per_group,test_group,'$proplist'}}},
      {?eh,cth,{empty_cth,pre_end_per_group,
		[fallback_nosuite,test_group,'$proplist',[]]}},
      {?eh,cth,{empty_cth,post_end_per_group,
		[fallback_nosuite,test_group,'$proplist',ok,[]]}},
      {?eh,tc_done,{ct_framework,{end_per_group,test_group,'$proplist'},ok}}],
     {?eh,tc_start,{all_hook_callbacks_SUITE,test_case}},
     {?eh,cth,{empty_cth,pre_init_per_testcase,
               [fallback_nosuite,test_case,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_testcase,
               [fallback_nosuite,test_case,'$proplist','_',[]]}},
     {?eh,cth,{empty_cth,pre_end_per_testcase,
               [fallback_nosuite,test_case,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_testcase,
               [fallback_nosuite,test_case,'$proplist','_',[]]}},
     {?eh,tc_done,{all_hook_callbacks_SUITE,test_case,ok}},
     {?eh,test_stats,{2,0,{0,0}}},
     {?eh,tc_start,{all_hook_callbacks_SUITE,skip_case}},
     {?eh,cth,{empty_cth,pre_init_per_testcase,
               [fallback_nosuite,skip_case,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_init_per_testcase,
               [fallback_nosuite,skip_case,'$proplist',
                {skip,"Skipped in init_per_testcase/2"},[]]}},
     {?eh,tc_done,{all_hook_callbacks_SUITE,skip_case,
                   {skipped,"Skipped in init_per_testcase/2"}}},
     {?eh,cth,{empty_cth,on_tc_skip,
               [fallback_nosuite,skip_case,
                {tc_user_skip,{skipped,"Skipped in init_per_testcase/2"}},
                []]}},
     {?eh,test_stats,{2,0,{1,0}}},
     {?eh,tc_start,{all_hook_callbacks_SUITE,end_per_suite}},
     {?eh,cth,{empty_cth,pre_end_per_suite,
	       [all_hook_callbacks_SUITE,'$proplist',[]]}},
     {?eh,cth,{empty_cth,post_end_per_suite,
               [all_hook_callbacks_SUITE,'$proplist','_',[]]}},
     {?eh,tc_done,{all_hook_callbacks_SUITE,end_per_suite,ok}},
     {?eh,test_done,{'DEF','STOP_TIME'}},
     {?eh,cth,{empty_cth,terminate,[[]]}},
     {?eh,stop_logging,[]}
    ];

test_events(callbacks_on_skip) ->
    %% skip_cth.erl will send a 'cth_error' event if a hook is
    %% erroneously called. Therefore, all Events are changed to
    %% {negative,{?eh,cth_error,'_'},Event}
    %% at the end of this function.
    Events =
        [
         {?eh,start_logging,{'DEF','RUNDIR'}},
         {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
         {?eh,cth,{empty_cth,id,[[]]}},
         {?eh,cth,{empty_cth,init,[{'_','_','_'},[]]}},
         {?eh,start_info,{6,6,12}},

         %% all_hook_callbacks_SUITE is skipped in spec
         %% Only the on_tc_skip callback shall be called
         {?eh,tc_user_skip,{all_hook_callbacks_SUITE,all,"Skipped in spec"}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [all_hook_callbacks_SUITE,all,
                    {tc_user_skip,"Skipped in spec"},
                    []]}},
         {?eh,test_stats,{0,0,{1,0}}},

         %% skip_init_SUITE is skipped in its init_per_suite function
         %% No group- or testcase-functions shall be called.
         {?eh,tc_start,{skip_init_SUITE,init_per_suite}},
         {?eh,cth,{empty_cth,pre_init_per_suite,
                   [skip_init_SUITE,
                    '$proplist',
                    []]}},
         {?eh,cth,{empty_cth,post_init_per_suite,
                   [skip_init_SUITE,
                    '$proplist',
                    {skip,"Skipped in init_per_suite/1"},
                    []]}},
         {?eh,tc_done,{skip_init_SUITE,init_per_suite,
                       {skipped,"Skipped in init_per_suite/1"}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_init_SUITE,init_per_suite,
                    {tc_user_skip,{skipped,"Skipped in init_per_suite/1"}},
                    []]}},
         {?eh,tc_user_skip,{skip_init_SUITE,test_case,"Skipped in init_per_suite/1"}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_init_SUITE,test_case,
                    {tc_user_skip,"Skipped in init_per_suite/1"},
                    []]}},
         {?eh,test_stats,{0,0,{2,0}}},
         {?eh,tc_user_skip,{skip_init_SUITE,end_per_suite,
                            "Skipped in init_per_suite/1"}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_init_SUITE,end_per_suite,
                    {tc_user_skip,"Skipped in init_per_suite/1"},
                    []]}},

         %% skip_req_SUITE is auto-skipped since a 'require' statement
         %% returned by suite/0 is not fulfilled.
         %% No group- or testcase-functions shall be called.
         {?eh,tc_start,{skip_req_SUITE,init_per_suite}},
         {?eh,tc_done,{skip_req_SUITE,init_per_suite,
                       {auto_skipped,{require_failed_in_suite0,
                                      {not_available,whatever}}}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_req_SUITE,init_per_suite,
                    {tc_auto_skip,{auto_skipped,{require_failed_in_suite0,
                                                 {not_available,whatever}}}},
                    []]}},
         {?eh,tc_auto_skip,{skip_req_SUITE,test_case,{require_failed_in_suite0,
                                                      {not_available,whatever}}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_req_SUITE,test_case,
                    {tc_auto_skip,{require_failed_in_suite0,
                                   {not_available,whatever}}},
                    []]}},
         {?eh,test_stats,{0,0,{2,1}}},
         {?eh,tc_auto_skip,{skip_req_SUITE,end_per_suite,
                            {require_failed_in_suite0,
                             {not_available,whatever}}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_req_SUITE,end_per_suite,
                    {tc_auto_skip,{require_failed_in_suite0,
                                   {not_available,whatever}}},
                    []]}},

         %% skip_fail_SUITE is auto-skipped since the suite/0 function
         %% retuns a faluty format.
         %% No group- or testcase-functions shall be called.
         {?eh,tc_start,{skip_fail_SUITE,init_per_suite}},
         {?eh,tc_done,{skip_fail_SUITE,init_per_suite,
                       {failed,{error,{suite0_failed,bad_return_value}}}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_fail_SUITE,init_per_suite,
                    {tc_auto_skip,
                     {auto_skipped,
                      {failed,{error,{suite0_failed,bad_return_value}}}}},
                    []]}},
         {?eh,tc_auto_skip,{skip_fail_SUITE,test_case,
                            {failed,{error,{suite0_failed,bad_return_value}}}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_fail_SUITE,test_case,
                    {tc_auto_skip,
                     {failed,{error,{suite0_failed,bad_return_value}}}},
                    []]}},
         {?eh,test_stats,{0,0,{2,2}}},
         {?eh,tc_auto_skip,{skip_fail_SUITE,end_per_suite,
                            {failed,{error,{suite0_failed,bad_return_value}}}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_fail_SUITE,end_per_suite,
                    {tc_auto_skip,
                     {failed,{error,{suite0_failed,bad_return_value}}}},
                    []]}},

         %% skip_group_SUITE
         {?eh,tc_start,{skip_group_SUITE,init_per_suite}},
         {?eh,cth,{empty_cth,pre_init_per_suite,
                   [skip_group_SUITE,
                    '$proplist',
                    []]}},
         {?eh,cth,{empty_cth,post_init_per_suite,
                   [skip_group_SUITE,
                    '$proplist',
                    '_',
                    []]}},
         {?eh,tc_done,{skip_group_SUITE,init_per_suite,ok}},

         %% test_group_1 - auto_skip due to require failed
         [{?eh,tc_start,{skip_group_SUITE,{init_per_group,test_group_1,[]}}},
          {?eh,tc_done,
           {skip_group_SUITE,{init_per_group,test_group_1,[]},
            {auto_skipped,{require_failed,{not_available,whatever}}}}},
          {?eh,cth,{empty_cth,on_tc_skip,
                    [skip_group_SUITE,
                     {init_per_group,test_group_1},
                     {tc_auto_skip,
                      {auto_skipped,{require_failed,{not_available,whatever}}}},
                     []]}},
          {?eh,tc_auto_skip,{skip_group_SUITE,{test_case,test_group_1},
                             {require_failed,{not_available,whatever}}}},
          {?eh,cth,{empty_cth,on_tc_skip,
                    [skip_group_SUITE,
                     {test_case,test_group_1},
                     {tc_auto_skip,{require_failed,{not_available,whatever}}},
                     []]}},
          {?eh,test_stats,{0,0,{2,3}}},
          {?eh,tc_auto_skip,{skip_group_SUITE,{end_per_group,test_group_1},
                             {require_failed,{not_available,whatever}}}}],
         %% The following appears to be outside of the group, but
         %% that's only an implementation detail in
         %% ct_test_support.erl - it does not know about events from
         %% test suite specific hooks and regards the group ended with
         %% the above tc_auto_skip-event for end_per_group.
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_group_SUITE,
                    {end_per_group,test_group_1},
                    {tc_auto_skip,{require_failed,{not_available,whatever}}},
                    []]}},

         %% test_group_2 - auto_skip due to failed return from group/1
         [{?eh,tc_start,{skip_group_SUITE,{init_per_group,test_group_2,[]}}},
          {?eh,tc_done,
           {skip_group_SUITE,{init_per_group,test_group_2,[]},
            {auto_skipped,{group0_failed,bad_return_value}}}},
          {?eh,cth,{empty_cth,on_tc_skip,
                    [skip_group_SUITE,
                     {init_per_group,test_group_2},
                     {tc_auto_skip,
                      {auto_skipped,{group0_failed,bad_return_value}}},
                     []]}},
          {?eh,tc_auto_skip,{skip_group_SUITE,{test_case,test_group_2},
                             {group0_failed,bad_return_value}}},
          {?eh,cth,{empty_cth,on_tc_skip,
                    [skip_group_SUITE,
                     {test_case,test_group_2},
                     {tc_auto_skip,{group0_failed,bad_return_value}},
                     []]}},
          {?eh,test_stats,{0,0,{2,4}}},
          {?eh,tc_auto_skip,{skip_group_SUITE,{end_per_group,test_group_2},
                             {group0_failed,bad_return_value}}}],
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_group_SUITE,
                    {end_per_group,test_group_2},
                    {tc_auto_skip,{group0_failed,bad_return_value}},
                    []]}},
         %% test_group_3 - user_skip in init_per_group/2
         [{?eh,tc_start,
           {skip_group_SUITE,{init_per_group,test_group_3,[]}}},
          {?eh,cth,{empty_cth,pre_init_per_group,
                    [skip_group_SUITE,test_group_3,'$proplist',[]]}},
          {?eh,cth,{empty_cth,post_init_per_group,
                    [skip_group_SUITE,test_group_3,'$proplist',
                     {skip,"Skipped in init_per_group/2"},
                     []]}},
          {?eh,tc_done,{skip_group_SUITE,
                        {init_per_group,test_group_3,[]},
                        {skipped,"Skipped in init_per_group/2"}}},
          {?eh,cth,{empty_cth,on_tc_skip,
                    [skip_group_SUITE,
                     {init_per_group,test_group_3},
                     {tc_user_skip,{skipped,"Skipped in init_per_group/2"}},
                     []]}},
          {?eh,tc_user_skip,{skip_group_SUITE,
                             {test_case,test_group_3},
                             "Skipped in init_per_group/2"}},
          {?eh,cth,{empty_cth,on_tc_skip,
                    [skip_group_SUITE,
                     {test_case,test_group_3},
                     {tc_user_skip,"Skipped in init_per_group/2"},
                     []]}},
          {?eh,test_stats,{0,0,{3,4}}},
          {?eh,tc_user_skip,{skip_group_SUITE,
                             {end_per_group,test_group_3},
                             "Skipped in init_per_group/2"}}],
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_group_SUITE,
                    {end_per_group,test_group_3},
                    {tc_user_skip,"Skipped in init_per_group/2"},
                    []]}},

         {?eh,tc_start,{skip_group_SUITE,end_per_suite}},
         {?eh,cth,{empty_cth,pre_end_per_suite,
                   [skip_group_SUITE,
                    '$proplist',
                    []]}},
         {?eh,cth,{empty_cth,post_end_per_suite,
                   [skip_group_SUITE,
                    '$proplist',
                    ok,[]]}},
         {?eh,tc_done,{skip_group_SUITE,end_per_suite,ok}},


         %% skip_case_SUITE has 4 test cases which are all skipped in
         %% different ways
         {?eh,tc_start,{skip_case_SUITE,init_per_suite}},
         {?eh,cth,{empty_cth,pre_init_per_suite,
                   [skip_case_SUITE,
                    '$proplist',
                    []]}},
         {?eh,cth,{empty_cth,post_init_per_suite,
                   [skip_case_SUITE,
                    '$proplist',
                    '_',
                    []]}},
         {?eh,tc_done,{skip_case_SUITE,init_per_suite,ok}},

         %% Skip in spec -> only on_tc_skip shall be called
         {?eh,tc_user_skip,{skip_case_SUITE,skip_in_spec,"Skipped in spec"}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_case_SUITE,skip_in_spec,
                    {tc_user_skip,"Skipped in spec"},
                    []]}},
         {?eh,test_stats,{0,0,{4,4}}},

         %% Skip in init_per_testcase -> pre/post_end_per_testcase
         %% shall not be called
         {?eh,tc_start,{skip_case_SUITE,skip_in_init}},
         {?eh,cth,{empty_cth,pre_init_per_testcase,
                   [skip_case_SUITE,skip_in_init,
                    '$proplist',
                    []]}},
         {?eh,cth,{empty_cth,post_init_per_testcase,
                   [skip_case_SUITE,skip_in_init,
                    '$proplist',
                    {skip,"Skipped in init_per_testcase/2"},
                    []]}},
         {?eh,tc_done,{skip_case_SUITE,skip_in_init,
                       {skipped,"Skipped in init_per_testcase/2"}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_case_SUITE,skip_in_init,
                    {tc_user_skip,{skipped,"Skipped in init_per_testcase/2"}},
                    []]}},
         {?eh,test_stats,{0,0,{5,4}}},

         %% Fail in init_per_testcase -> pre/post_end_per_testcase
         %% shall not be called
         {?eh,tc_start,{skip_case_SUITE,fail_in_init}},
         {?eh,cth,{empty_cth,pre_init_per_testcase,
                   [skip_case_SUITE,fail_in_init,
                    '$proplist',
                    []]}},
         {?eh,cth,{empty_cth,post_init_per_testcase,
                   [skip_case_SUITE,fail_in_init,
                    '$proplist',
                    {skip,{failed,'_'}},
                    []]}},
         {?eh,tc_done,{skip_case_SUITE,fail_in_init,
                       {auto_skipped,{failed,'_'}}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_case_SUITE,fail_in_init,
                    {tc_auto_skip,{auto_skipped,{failed,'_'}}},
                    []]}},
         {?eh,test_stats,{0,0,{5,5}}},

         %% Skip in testcase function -> all callbacks shall be called
         {?eh,tc_start,{skip_case_SUITE,skip_in_case}},
         {?eh,cth,{empty_cth,pre_init_per_testcase,
                   [skip_case_SUITE,skip_in_case,
                    '$proplist',
                    []]}},
         {?eh,cth,{empty_cth,post_init_per_testcase,
                   [skip_case_SUITE,skip_in_case,
                    '$proplist',
                    ok,[]]}},
         {?eh,cth,{empty_cth,pre_end_per_testcase,
                   [skip_case_SUITE,skip_in_case,
                    '$proplist',
                    []]}},
         {?eh,cth,{empty_cth,post_end_per_testcase,
                   [skip_case_SUITE,skip_in_case,
                    '$proplist',
                    {skip,"Skipped in test case function"},
                    []]}},
         {?eh,tc_done,{skip_case_SUITE,skip_in_case,
                       {skipped,"Skipped in test case function"}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_case_SUITE,skip_in_case,
                    {tc_user_skip,{skipped,"Skipped in test case function"}},
                    []]}},
         {?eh,test_stats,{0,0,{6,5}}},

         %% Auto skip due to failed 'require' -> only the on_tc_skip
         %% callback shall be called
         {?eh,tc_start,{skip_case_SUITE,req_auto_skip}},
         {?eh,tc_done,{skip_case_SUITE,req_auto_skip,
                       {auto_skipped,{require_failed,{not_available,whatever}}}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_case_SUITE,req_auto_skip,
                    {tc_auto_skip,
                     {auto_skipped,{require_failed,{not_available,whatever}}}},
                    []]}},
         {?eh,test_stats,{0,0,{6,6}}},

         %% Auto skip due to failed testcase/0 function -> only the
         %% on_tc_skip callback shall be called
         {?eh,tc_start,{skip_case_SUITE,fail_auto_skip}},
         {?eh,tc_done,{skip_case_SUITE,fail_auto_skip,
                       {auto_skipped,{testcase0_failed,bad_return_value}}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [skip_case_SUITE,fail_auto_skip,
                    {tc_auto_skip,
                     {auto_skipped,{testcase0_failed,bad_return_value}}},
                    []]}},
         {?eh,test_stats,{0,0,{6,7}}},

         {?eh,tc_start,{skip_case_SUITE,end_per_suite}},
         {?eh,cth,{empty_cth,pre_end_per_suite,
                   [skip_case_SUITE,
                    '$proplist',
                    []]}},
         {?eh,cth,{empty_cth,post_end_per_suite,
                   [skip_case_SUITE,
                    '$proplist',
                    ok,[]]}},
         {?eh,tc_done,{skip_case_SUITE,end_per_suite,ok}},
         {?eh,test_done,{'DEF','STOP_TIME'}},
         {?eh,cth,{empty_cth,terminate,[[]]}},
         {?eh,stop_logging,[]}
        ],
    %% Make sure no 'cth_error' events are received!
    [{negative,{?eh,cth_error,'_'},E} || E <- Events];

test_events(failed_sequence) ->
    %% skip_cth.erl will send a 'cth_error' event if a hook is
    %% erroneously called. Therefore, all Events are changed to
    %% {negative,{?eh,cth_error,'_'},Event}
    %% at the end of this function.
    Events =
        [
         {?eh,start_logging,{'DEF','RUNDIR'}},
         {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
         {?eh,cth,{empty_cth,id,[[]]}},
         {?eh,cth,{empty_cth,init,[{'_','_','_'},[]]}},
         {?eh,start_info,{1,1,2}},
         {?eh,tc_start,{ct_framework,init_per_suite}},
         {?eh,cth,{empty_cth,pre_init_per_suite,[seq_SUITE,'$proplist',[]]}},
         {?eh,cth,{empty_cth,post_init_per_suite,
                   [seq_SUITE,'$proplist','$proplist',[]]}},
         {?eh,tc_done,{ct_framework,init_per_suite,ok}},
         {?eh,tc_start,{seq_SUITE,test_case_1}},
         {?eh,cth,{empty_cth,pre_init_per_testcase,
                   [seq_SUITE,test_case_1,'$proplist',[]]}},
         {?eh,cth,{empty_cth,post_init_per_testcase,
                   [seq_SUITE,test_case_1,'$proplist',ok,[]]}},
         {?eh,cth,{empty_cth,pre_end_per_testcase,
                   [seq_SUITE,test_case_1,'$proplist',[]]}},
         {?eh,cth,{empty_cth,post_end_per_testcase,
                   [seq_SUITE,test_case_1,'$proplist',
                    {error,failed_on_purpose},[]]}},
         {?eh,tc_done,{seq_SUITE,test_case_1,{failed,{error,failed_on_purpose}}}},
         {?eh,cth,{empty_cth,on_tc_fail,
                   [seq_SUITE,test_case_1,{failed,failed_on_purpose},[]]}},
         {?eh,test_stats,{0,1,{0,0}}},
         {?eh,tc_done,{seq_SUITE,test_case_2,
                       {auto_skipped,{sequence_failed,seq1,test_case_1}}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [seq_SUITE,test_case_2,
                    {tc_auto_skip,
                     {auto_skipped,{sequence_failed,seq1,test_case_1}}},
                    []]}},
         {?eh,test_stats,{0,1,{0,1}}},
         {?eh,tc_start,{ct_framework,end_per_suite}},
         {?eh,cth,{empty_cth,pre_end_per_suite,[seq_SUITE,'$proplist',[]]}},
         {?eh,cth,{empty_cth,post_end_per_suite,[seq_SUITE,'$proplist',ok,[]]}},
         {?eh,tc_done,{ct_framework,end_per_suite,ok}},
         {?eh,test_done,{'DEF','STOP_TIME'}},
         {?eh,cth,{empty_cth,terminate,[[]]}},
         {?eh,stop_logging,[]}
        ],
    %% Make sure no 'cth_error' events are received!
    [{negative,{?eh,cth_error,'_'},E} || E <- Events];

test_events(repeat_force_stop) ->
    %% skip_cth.erl will send a 'cth_error' event if a hook is
    %% erroneously called. Therefore, all Events are changed to
    %% {negative,{?eh,cth_error,'_'},Event}
    %% at the end of this function.
    Events=
        [
         {?eh,start_logging,{'DEF','RUNDIR'}},
         {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
         {?eh,cth,{empty_cth,id,[[]]}},
         {?eh,cth,{empty_cth,init,[{'_','_','_'},[]]}},
         {?eh,start_info,{1,1,2}},
         {?eh,tc_start,{ct_framework,init_per_suite}},
         {?eh,cth,{empty_cth,pre_init_per_suite,[repeat_SUITE,'$proplist',[]]}},
         {?eh,cth,{empty_cth,post_init_per_suite,
                   [repeat_SUITE,'$proplist','$proplist',[]]}},
         {?eh,tc_done,{ct_framework,init_per_suite,ok}},
         {?eh,tc_start,{repeat_SUITE,test_case_1}},
         {?eh,cth,{empty_cth,pre_init_per_testcase,
                   [repeat_SUITE,test_case_1,'$proplist',[]]}},
         {?eh,cth,{empty_cth,post_init_per_testcase,
                   [repeat_SUITE,test_case_1,'$proplist',ok,[]]}},
         {?eh,cth,{empty_cth,pre_end_per_testcase,
                   [repeat_SUITE,test_case_1,'$proplist',[]]}},
         {?eh,cth,{empty_cth,post_end_per_testcase,
                   [repeat_SUITE,test_case_1,'$proplist',ok,[]]}},
         {?eh,tc_done,{repeat_SUITE,test_case_1,ok}},
         {?eh,test_stats,{1,0,{0,0}}},
         {?eh,tc_done,{repeat_SUITE,test_case_2,
                       {auto_skipped,
                        "Repeated test stopped by force_stop option"}}},
         {?eh,cth,{empty_cth,on_tc_skip,
                   [repeat_SUITE,test_case_2,
                    {tc_auto_skip,
                     {auto_skipped,"Repeated test stopped by force_stop option"}},
                    []]}},
         {?eh,test_stats,{1,0,{0,1}}},
         {?eh,tc_start,{ct_framework,end_per_suite}},
         {?eh,cth,{empty_cth,pre_end_per_suite,[repeat_SUITE,'$proplist',[]]}},
         {?eh,cth,{empty_cth,post_end_per_suite,
                   [repeat_SUITE,'$proplist',ok,[]]}},
         {?eh,tc_done,{ct_framework,end_per_suite,ok}},
         {?eh,test_done,{'DEF','STOP_TIME'}},
         {?eh,cth,{empty_cth,terminate,[[]]}},
         {?eh,stop_logging,[]}
        ],
    %% Make sure no 'cth_error' events are received!
    [{negative,{?eh,cth_error,'_'},E} || E <- Events];

test_events(config_clash) ->
    %% skip_cth.erl will send a 'cth_error' event if a hook is
    %% erroneously called. Therefore, all Events are changed to
    %% {negative,{?eh,cth_error,'_'},Event}
    %% at the end of this function.
    Events =
        [
         {?eh,start_logging,{'DEF','RUNDIR'}},
         {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
         {?eh,cth,{empty_cth,id,[[]]}},
         {?eh,cth,{empty_cth,init,[{'_','_','_'},[]]}},
         {?eh,start_info,{1,1,1}},
         {?eh,tc_start,{ct_framework,init_per_suite}},
         {?eh,cth,{empty_cth,pre_init_per_suite,
                   [config_clash_SUITE,'$proplist',[]]}},
         {?eh,cth,{empty_cth,post_init_per_suite,
                   [config_clash_SUITE,'$proplist','$proplist',[]]}},
         {?eh,tc_done,{ct_framework,init_per_suite,ok}},
         {?eh,tc_start,{config_clash_SUITE,test_case_1}},
         {?eh,tc_done,{config_clash_SUITE,test_case_1,
                       {failed,{error,{config_name_already_in_use,[aa]}}}}},
         {?eh,cth,{empty_cth,on_tc_fail,
                   [config_clash_SUITE,test_case_1,
                    {failed,{config_name_already_in_use,[aa]}},
                    []]}},
         {?eh,test_stats,{0,1,{0,0}}},
         {?eh,tc_start,{ct_framework,end_per_suite}},
         {?eh,cth,{empty_cth,pre_end_per_suite,
                   [config_clash_SUITE,'$proplist',[]]}},
         {?eh,cth,{empty_cth,post_end_per_suite,
                   [config_clash_SUITE,'$proplist',ok,[]]}},
         {?eh,tc_done,{ct_framework,end_per_suite,ok}},
         {?eh,test_done,{'DEF','STOP_TIME'}},
         {?eh,cth,{empty_cth,terminate,[[]]}},
         {?eh,stop_logging,[]}
    ],
    %% Make sure no 'cth_error' events are received!
    [{negative,{?eh,cth_error,'_'},E} || E <- Events];

test_events(ok) ->
    ok.

%% test events help functions
contains(List) ->
    fun(Proplist) when is_list(Proplist) ->
	    contains(List,Proplist)
    end.

contains([{not_in_order,List}|T],Rest) ->
    contains_parallel(List,Rest),
    contains(T,Rest);
contains([{Ele,Pos}|T] = L,[H|T2]) ->
    case element(Pos,H) of
	Ele ->
	    contains(T,T2);
	_ ->
	    contains(L,T2)
    end;
contains([Ele|T],[{Ele,_}|T2])->
    contains(T,T2);
contains([Ele|T],[Ele|T2])->
    contains(T,T2);
contains(List,[_|T]) ->
    contains(List,T);
contains([],_) ->
    match.

contains_parallel([Key | T], Elems) ->
    contains([Key],Elems),
    contains_parallel(T,Elems);
contains_parallel([],_Elems) ->
    match.

not_contains(List) ->
    fun(Proplist) when is_list(Proplist) ->
	    [] = [Ele || {Ele,_} <- Proplist,
			 Test <- List,
			 Test =:= Ele]
    end.