Sync with 5.3.0
[deliverable/titan.core.git] / regression_test / profiler / Testcases.ttcn
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
9 module Testcases {
10
11 import from Shell all;
12
13 type record of charstring CharstringList;
14
15 function f_test_profiler(in charstring p_target_file, in charstring p_config_file,
16 in CharstringList p_output_files, in CharstringList p_exp_output_files) runs on Shell_CT
17 {
18 // make the target (the makefile must have a rule for it)
19 f_shellCommandWithVerdict("make " & p_target_file, "", c_shell_successWithoutWarningAndError);
20
21 if (getverdict == pass) {
22 // run the executable with the specified configuration file
23 f_shellCommandWithVerdict("ttcn3_start " & p_target_file & " " & p_config_file, "",
24 c_shell_successWithoutWarningAndError);
25
26 if (getverdict == pass) {
27 // compare the output files
28 var integer i;
29 for (i := 0; i < sizeof(p_output_files); i := i + 1) {
30 f_compareFiles(p_output_files[i], p_exp_output_files[i], 0);
31 if (getverdict != pass) {
32 action("Output file '" & p_output_files[i] & "' does not match the expected file '" &
33 p_exp_output_files[i] & "'");
34 }
35 }
36 }
37 else {
38 action("Failed to run target '", p_target_file, "', with configuration file '", p_config_file, "'");
39 }
40 }
41 else {
42 action("Failed to make target '", p_target_file, "'");
43 }
44 }
45
46 testcase tc_coverage() runs on Shell_CT
47 {
48 // only code coverage is done in this case, since that is exact, and the results can be checked with
49 // a simple file comparison
50 f_test_profiler("prof.exe", "prof1.cfg", { "data.json", "prof1.stats" }, { "data_e.json", "prof1_e.stats" } );
51 }
52
53 testcase tc_profiling() runs on Shell_CT
54 {
55 // only profiling is done in this case
56 // the results cannot be checked, since the call times will vary in each run
57 f_test_profiler("prof.exe", "prof2.cfg", { }, { } );
58 }
59
60 testcase tc_profiling_and_coverage() runs on Shell_CT
61 {
62 // both profiling and code coverage is activated in this case
63 // although the call times cannot be checked, the statistics filter is set to generate an
64 // empty statistics file, which can be cheked
65 f_test_profiler("prof.exe", "prof3.cfg", { "empty.stats" }, { "empty_e.stats" } );
66 }
67
68 control {
69 execute(tc_coverage());
70 execute(tc_profiling());
71 execute(tc_profiling_and_coverage());
72 }
73
74 }
This page took 0.033929 seconds and 5 git commands to generate.