Merge branch 'maint/7.0'
[ninja.git] / test / unit_test / reports / generate_test.php
blob43ad647693dbfd1d7580c6e9caabdd9a820cc452
1 <?php
2 /*
3 Will parse csv output from file specified below
4 and generate test case
5 */
7 $s_header = 'HOST_NAME,
8 TIME_UP_SCHEDULED,
9 PERCENT_TIME_UP_SCHEDULED,
10 PERCENT_KNOWN_TIME_UP_SCHEDULED,
11 TIME_UP_UNSCHEDULED,
12 PERCENT_TIME_UP_UNSCHEDULED,
13 PERCENT_KNOWN_TIME_UP_UNSCHEDULED,
14 TOTAL_TIME_UP,
15 PERCENT_TOTAL_TIME_UP,
16 PERCENT_KNOWN_TIME_UP,
17 TIME_DOWN_SCHEDULED,
18 PERCENT_TIME_DOWN_SCHEDULED,
19 PERCENT_KNOWN_TIME_DOWN_SCHEDULED,
20 TIME_DOWN_UNSCHEDULED,
21 PERCENT_TIME_DOWN_UNSCHEDULED,
22 PERCENT_KNOWN_TIME_DOWN_UNSCHEDULED,
23 TOTAL_TIME_DOWN,
24 PERCENT_TOTAL_TIME_DOWN,
25 PERCENT_KNOWN_TIME_DOWN,
26 TIME_UNREACHABLE_SCHEDULED,
27 PERCENT_TIME_UNREACHABLE_SCHEDULED,
28 PERCENT_KNOWN_TIME_UNREACHABLE_SCHEDULED,
29 TIME_UNREACHABLE_UNSCHEDULED,
30 PERCENT_TIME_UNREACHABLE_UNSCHEDULED,
31 PERCENT_KNOWN_TIME_UNREACHABLE_UNSCHEDULED,
32 TOTAL_TIME_UNREACHABLE,
33 PERCENT_TOTAL_TIME_UNREACHABLE,
34 PERCENT_KNOWN_TIME_UNREACHABLE,
35 TIME_UNDETERMINED_NOT_RUNNING,
36 PERCENT_TIME_UNDETERMINED_NOT_RUNNING,
37 TIME_UNDETERMINED_NO_DATA,
38 PERCENT_TIME_UNDETERMINED_NO_DATA,
39 TOTAL_TIME_UNDETERMINED,
40 PERCENT_TOTAL_TIME_UNDETERMINED';
42 // parameters that we actually are interested in
43 // service params
44 $svc_return_values = array('SERVICE_DESCRIPTION',
45 'TIME_OK_SCHEDULED',
46 'TIME_OK_UNSCHEDULED',
47 'TIME_WARNING_SCHEDULED',
48 'TIME_WARNING_UNSCHEDULED',
49 'TIME_UNKNOWN_SCHEDULED',
50 'TIME_UNKNOWN_UNSCHEDULED',
51 'TIME_CRITICAL_SCHEDULED',
52 'TIME_CRITICAL_UNSCHEDULED',
53 'TIME_UNDETERMINED_NOT_RUNNING',
54 'TIME_UNDETERMINED_NO_DATA'
56 // host params
57 $return_values = array( 'TIME_UP_SCHEDULED',
58 'TIME_UP_UNSCHEDULED',
59 'TIME_DOWN_SCHEDULED',
60 'TIME_DOWN_UNSCHEDULED',
61 'TIME_UNREACHABLE_SCHEDULED',
62 'TIME_UNREACHABLE_UNSCHEDULED',
63 'TIME_UNDETERMINED_NOT_RUNNING',
64 'TIME_UNDETERMINED_NO_DATA');
66 // Read csv data from file
67 $_newfile = file('apa1');
69 $header = explode(',', $s_header);
72 Hard coded start- and end time
73 Set $is_service below to true to get servicename
74 and correct return values array
76 $start_time = 1196463600;
77 $end_time = 1199142000;
78 $is_service = false;
80 echo "<pre>";
82 for ($i=1;$i<sizeof($_newfile);$i++) {
83 // loop through all lines in _newfile
84 $newfile = explode(',', $_newfile[$i]);
86 $hostname = str_replace('"', '', $newfile[0]);
87 if ($is_service) {
88 $service = str_replace('"', '', $newfile[1]);
89 $return_array_values = $svc_return_values;
90 } else {
91 $return_array_values = $return_values;
94 echo "test case ".$hostname." {\n";
95 echo "\tstart_time = $start_time
96 \tend_time = $end_time
97 \thostname = ".$hostname;
98 if ($is_service)
99 echo "\tservice = ".$service;
100 echo "\n";
102 // print correct values
103 echo "\tcorrect {";
104 for ($a=0;$a<sizeof($newfile);$a++) {
105 if (in_array(trim($header[$a]), $return_array_values)) {
106 echo "\n\t\t".trim($header[$a]) . " =" . $newfile[$a];
109 echo "
111 }\n\n";
114 echo "</pre>";