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 ******************************************************************************/
10 import from TitanLoggerControl all;
12 //const Severities log_nothing := {};
16 testcase read_settings() runs on L
18 var Severities actual_file_mask := TitanLoggerControl.get_file_mask("LegacyLogger");
19 if ( match(actual_file_mask, TitanLoggerControl.log_all)) { setverdict(pass); }
20 else { setverdict(fail, match(actual_file_mask, TitanLoggerControl.log_all)); }
22 var Severities actual_console_mask := TitanLoggerControl.get_console_mask("LegacyLogger");
23 if ( match(actual_console_mask, TitanLoggerControl.log_console_default)) { setverdict(pass); }
24 else { setverdict(fail, match(actual_console_mask, TitanLoggerControl.log_console_default)); }
27 template Severities LeChuck := {
28 EXECUTOR_RUNTIME, EXECUTOR_CONFIGDATA, EXECUTOR_EXTCOMMAND, EXECUTOR_COMPONENT,
29 EXECUTOR_LOGOPTIONS, EXECUTOR_UNQUALIFIED
32 template Severities portevent_all := {
33 PORTEVENT_PQUEUE, PORTEVENT_MQUEUE, PORTEVENT_STATE,
34 PORTEVENT_PMIN, PORTEVENT_PMOUT, PORTEVENT_PCIN, PORTEVENT_PCOUT,
35 PORTEVENT_MMRECV, PORTEVENT_MMSEND, PORTEVENT_MCRECV, PORTEVENT_MCSEND,
36 PORTEVENT_DUALRECV, PORTEVENT_DUALSEND, PORTEVENT_UNQUALIFIED
39 template Severities aew := {
45 testcase on_off() runs on L
47 var Severities user_log_only := { USER_UNQUALIFIED }
48 TitanLoggerControl.add_to_console_mask("LegacyLogger", log_all);
49 // makes sure user logs are visible on the console
51 // Start printouts for the test
52 log("You should see this from ", __LINE__); // 1
54 log("console default: ", log_console_default);
55 TitanLoggerControl.set_file_mask("LegacyLogger", log_nothing);
56 log("You should not see this (in the log file) from ", __LINE__);
58 // VERDICTOP is off, this line will not be logged
59 setverdict(none, "You should not see this either, from ", __LINE__);
61 var Severities actual_file_mask0 := TitanLoggerControl.get_file_mask("LegacyLogger");
63 // set it back to LOG_ALL
64 TitanLoggerControl.set_file_mask("LegacyLogger", log_all);
65 log("You should see this again, from ", __LINE__); // 2
67 setverdict(pass, "We're back! at ", __LINE__); // this should be visible
69 // now check the previously retrieved logger setting
70 if ( match(actual_file_mask0, TitanLoggerControl.log_nothing)) { setverdict(pass); }
71 else { setverdict(fail, match(actual_file_mask0, TitanLoggerControl.log_nothing)); }
73 TitanLoggerControl.set_file_mask("LegacyLogger", log_everything);
74 log("You should see this too, from ", __LINE__); // 3
76 var Severities actual_file_mask_everything := TitanLoggerControl.get_file_mask("LegacyLogger");
77 if ( match(actual_file_mask_everything, TitanLoggerControl.log_everything)) { setverdict(pass); }
78 else { setverdict(fail, match(actual_file_mask_everything, TitanLoggerControl.log_everything)); }
80 TitanLoggerControl.remove_from_file_mask("LegacyLogger", user_log_only);
81 log("Again, you should not see this from ", __LINE__);
83 TitanLoggerControl.add_to_file_mask("LegacyLogger", user_log_only);
84 log("And, you should see this from ", __LINE__); // 4
86 action("speaks louder than words, so you can see this at ", __LINE__); // 5
87 TitanLoggerControl.remove_from_file_mask("LegacyLogger", valueof(aew));
88 action("You should not see this action at ", __LINE__);
91 testcase entity() runs on L
94 var boolean log_entity_name := TitanLoggerControl.get_log_entity_name("LegacyLogger");
95 if (log_entity_name) { setverdict(fail, "LogEntityName should default to FALSE"); }
96 else { setverdict(pass); }
98 TitanLoggerControl.set_log_entity_name("LegacyLogger", true);
99 log_entity_name := TitanLoggerControl.get_log_entity_name("LegacyLogger");
100 if (log_entity_name) { setverdict(pass); }
101 else { setverdict(fail, "LogEntityName should be TRUE now"); }
103 log("The tc should be mentioned in this log line");
106 TitanLoggerControl.set_log_entity_name("LegacyLogger", false);
107 log("The entity should not be logged anymore");
110 type set of record { integer field1, charstring field2 } rr;
112 template rr t_rr := {
114 field1 := 42, field2 := "fourty-two"
117 field1 := 13, field2 := "Hail Eris!"
123 field1 := 42, field2 := "forty-two" // 'u' is missing
126 field1 := 13, field2 := "Hail Eris!"
130 testcase hints() runs on L
133 var verbosity v := TitanLoggerControl.get_matching_verbosity("LegacyLogger");
134 if (v == compact) { setverdict(pass); }
135 else { setverdict(fail, "Matching verbosity should default to compact"); }
137 log("Compact:", match(c_rr, t_rr));
139 TitanLoggerControl.set_matching_verbosity("LegacyLogger", full);
140 v := TitanLoggerControl.get_matching_verbosity("LegacyLogger");
141 if (v == full) { setverdict(pass); }
142 else { setverdict(fail, "Matching verbosity should now be full"); }
144 log("Full :", match(c_rr, t_rr));
147 testcase changename() runs on L
149 TitanLoggerControl.set_log_file("LegacyLogger", "changed_name-%c-%t.log");
150 log("New log in a new file");
156 execute(read_settings());
162 // last but not least
163 execute(changename());