Sync with 5.4.0
[deliverable/titan.core.git] / regression_test / profiler / Testcases.ttcn
CommitLineData
a38c6d4c 1/******************************************************************************
2 * Copyright (c) 2000-2015 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 ******************************************************************************/
8
9module Testcases {
10
11import from Shell all;
12
13type record of charstring CharstringList;
14
3abe9331 15function f_compare_output_files(in CharstringList p_output_files,
16 in CharstringList p_exp_output_files) runs on Shell_CT
17{
18 var integer i;
19 for (i := 0; i < sizeof(p_output_files); i := i + 1) {
20 f_compareFiles(p_output_files[i], p_exp_output_files[i], 0);
21 if (getverdict != pass) {
22 action("Output file '" & p_output_files[i] & "' does not match the expected file '" &
23 p_exp_output_files[i] & "'");
24 }
25 }
26}
27
a38c6d4c 28function f_test_profiler(in charstring p_target_file, in charstring p_config_file,
29 in CharstringList p_output_files, in CharstringList p_exp_output_files) runs on Shell_CT
30{
31 // make the target (the makefile must have a rule for it)
3abe9331 32 f_shellCommandWithVerdict("make " & p_target_file, "", c_shell_successWithoutError);
a38c6d4c 33
34 if (getverdict == pass) {
35 // run the executable with the specified configuration file
36 f_shellCommandWithVerdict("ttcn3_start " & p_target_file & " " & p_config_file, "",
37 c_shell_successWithoutWarningAndError);
38
39 if (getverdict == pass) {
3abe9331 40 f_compare_output_files(p_output_files, p_exp_output_files);
a38c6d4c 41 }
42 else {
43 action("Failed to run target '", p_target_file, "', with configuration file '", p_config_file, "'");
44 }
45 }
46 else {
47 action("Failed to make target '", p_target_file, "'");
48 }
49}
50
3abe9331 51function f_test_profmerge(in charstring p_arguments, in CharstringList p_output_files,
52 in CharstringList p_exp_output_files) runs on Shell_CT
53{
54 // run the profmerge command
55 f_shellCommandWithVerdict("ttcn3_profmerge " & p_arguments, "",
56 c_shell_successWithoutWarningAndError);
57 if (getverdict == pass) {
58 f_compare_output_files(p_output_files, p_exp_output_files);
59 }
60 else {
61 action("Failed to run profmerge with arguments '", p_arguments, "'");
62 }
63}
64
a38c6d4c 65testcase tc_coverage() runs on Shell_CT
66{
67 // only code coverage is done in this case, since that is exact, and the results can be checked with
68 // a simple file comparison
69 f_test_profiler("prof.exe", "prof1.cfg", { "data.json", "prof1.stats" }, { "data_e.json", "prof1_e.stats" } );
70}
71
72testcase tc_profiling() runs on Shell_CT
73{
74 // only profiling is done in this case
75 // the results cannot be checked, since the call times will vary in each run
76 f_test_profiler("prof.exe", "prof2.cfg", { }, { } );
77}
78
79testcase tc_profiling_and_coverage() runs on Shell_CT
80{
81 // both profiling and code coverage is activated in this case
82 // although the call times cannot be checked, the statistics filter is set to generate an
83 // empty statistics file, which can be cheked
84 f_test_profiler("prof.exe", "prof3.cfg", { "empty.stats" }, { "empty_e.stats" } );
85}
86
3abe9331 87testcase tc_profmerge_double() runs on Shell_CT
88{
89 // the database file of the coverage-only test is merged with itself (values are doubled)
90 // the results can be compared, since they only contain coverage data and zero times
91 // all average time related statistics are filtered out (since they're all zeros),
92 // as well as all sorted statistics (since those are platform dependent)
93 f_test_profmerge("-s double.stats -o double.json -f 1800007 data.json data.json",
94 { "double.json", "double.stats" }, { "double_e.json", "double_e.stats" } );
95}
96
97testcase tc_profmerge_all() runs on Shell_CT
98{
99 // the database files of the 3 profiler tests are merged (values are again doubled)
100 // profiler data is discarded (-p), so the results can be compared
101 // (the output database is the same as the previous test, the statistics file is not,
102 // since it contains no time data instead of zero times)
103 f_test_profmerge("-p -o merged.json -s merged.stats -f 1800007 data.json data2.json data3.json",
104 { "merged.json", "merged.stats" }, { "double_e.json", "merged_e.stats" } );
105}
106
a38c6d4c 107control {
3abe9331 108 // the profmerge tests require the output files generated by the profiler tests
109 var verdicttype vt1 := execute(tc_coverage());
110 var verdicttype vt2 := execute(tc_profiling());
111 var verdicttype vt3 := execute(tc_profiling_and_coverage());
112 if (vt1 == pass) {
113 execute(tc_profmerge_double());
114 }
115 if (vt1 == pass and vt2 == pass and vt3 == pass) {
116 execute(tc_profmerge_all());
117 }
a38c6d4c 118}
119
120}
This page took 0.028489 seconds and 5 git commands to generate.