4
%% Copyright Ericsson AB 2004-2010. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
20
%%%------------------------------------------------------------------
21
%%% Test Server self test.
22
%%%------------------------------------------------------------------
23
-module(test_server_line_SUITE).
24
-include_lib("test_server/include/test_server.hrl").
27
-export([init_per_testcase/2, fin_per_testcase/2]).
28
-export([parse_transform/1, lines/1]).
30
all(doc) -> ["Test of parse transform for collection line numbers"];
31
all(suite) -> [parse_transform,lines].
34
init_per_testcase(_Case, Config) ->
35
?line test_server_line:clear(),
36
Dog = ?t:timetrap(?t:minutes(2)),
37
[{watchdog, Dog}|Config].
39
fin_per_testcase(_Case, Config) ->
40
?line test_server_line:clear(),
41
Dog=?config(watchdog, Config),
42
?t:timetrap_cancel(Dog),
45
parse_transform(suite) -> [];
46
parse_transform(doc) -> [];
47
parse_transform(Config) when is_list(Config) ->
48
?line DataDir = ?config(data_dir,Config),
49
code:add_pathz(DataDir),
51
?line ok = parse_transform_test:excluded(),
52
?line [] = test_server_line:get_lines(),
54
?line test_server_line:clear(),
55
?line ok = parse_transform_test:func(),
57
?line [{parse_transform_test,func4,58},
58
{parse_transform_test,func,49},
59
{parse_transform_test,func3,56},
60
{parse_transform_test,func,39},
61
{parse_transform_test,func2,54},
62
{parse_transform_test,func,36},
63
{parse_transform_test,func1,52},
64
{parse_transform_test,func,35}] = test_server_line:get_lines(),
66
code:del_path(DataDir),
70
lines(doc) -> ["Test parse transform for collection line numbers"];
71
lines(Config) when is_list(Config) ->
72
?line L0 = [{mod,func,1},{mod,func,2},{mod,func,3},
73
{m,f,4},{m,f,5},{m,f,6},
74
{mo,fu,7},{mo,fu,8},{mo,fu,9}],
75
?line LL = string:copies(L0, 1000),
76
?line T1 = erlang:now(),
77
?line lists:foreach(fun ({M,F,L}) ->
78
test_server_line:'$test_server_line'(M, F, L)
80
?line T2 = erlang:now(),
81
?line Long = test_server_line:get_lines(),
82
?line test_server_line:clear(),
84
?line T3 = erlang:now(),
85
?line lists:foreach(fun ({M,F,L}) ->
86
test_server_line:'$test_server_lineQ'(M, F, L)
88
?line T4 = erlang:now(),
89
?line LongQ = test_server_line:get_lines(),
91
?line io:format("'$test_server_line': ~f~n'$test_server_lineQ': ~f~n",
92
[timer:now_diff(T2, T1)/1000, timer:now_diff(T4, T3)/1000]),
93
?line io:format("'$test_server_line' result long:~p~n", [Long]),
94
?line io:format("'$test_server_lineQ' result long:~p~n", [LongQ]),
99
?line ?t:fail("The two methods did not produce same result for"
100
" long lists of lines")
103
?line test_server_line:clear(),
104
?line lists:foreach(fun ({M,F,L}) ->
105
test_server_line:'$test_server_line'(M, F, L)
107
?line Short = test_server_line:get_lines(),
108
?line test_server_line:clear(),
109
?line lists:foreach(fun ({M,F,L}) ->
110
test_server_line:'$test_server_lineQ'(M, F, L)
112
?line ShortQ = test_server_line:get_lines(),
114
?line io:format("'$test_server_line' result short:~p~n", [Short]),
115
?line io:format("'$test_server_lineQ' result short:~p~n", [ShortQ]),
117
if Short =:= ShortQ ->
120
?line ?t:fail("The two methods did not produce same result for"
121
" shot lists of lines\n")