1 /******************************************************************************
2 * Copyright (c) 2000-2016 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
13 ******************************************************************************/
16 import from TitanLoggerControl all;
18 //const Severities log_nothing := {};
22 testcase read_settings() runs on L
24 var Severities actual_file_mask := TitanLoggerControl.get_file_mask("LegacyLogger");
25 if ( match(actual_file_mask, TitanLoggerControl.log_all)) { setverdict(pass); }
26 else { setverdict(fail, match(actual_file_mask, TitanLoggerControl.log_all)); }
28 var Severities actual_console_mask := TitanLoggerControl.get_console_mask("LegacyLogger");
29 if ( match(actual_console_mask, TitanLoggerControl.log_console_default)) { setverdict(pass); }
30 else { setverdict(fail, match(actual_console_mask, TitanLoggerControl.log_console_default)); }
33 template Severities LeChuck := {
34 EXECUTOR_RUNTIME, EXECUTOR_CONFIGDATA, EXECUTOR_EXTCOMMAND, EXECUTOR_COMPONENT,
35 EXECUTOR_LOGOPTIONS, EXECUTOR_UNQUALIFIED
38 template Severities portevent_all := {
39 PORTEVENT_PQUEUE, PORTEVENT_MQUEUE, PORTEVENT_STATE,
40 PORTEVENT_PMIN, PORTEVENT_PMOUT, PORTEVENT_PCIN, PORTEVENT_PCOUT,
41 PORTEVENT_MMRECV, PORTEVENT_MMSEND, PORTEVENT_MCRECV, PORTEVENT_MCSEND,
42 PORTEVENT_DUALRECV, PORTEVENT_DUALSEND, PORTEVENT_UNQUALIFIED
45 template Severities aew := {
51 testcase on_off() runs on L
53 var Severities user_log_only := { USER_UNQUALIFIED }
54 TitanLoggerControl.add_to_console_mask("LegacyLogger", log_all);
55 // makes sure user logs are visible on the console
57 // Start printouts for the test
58 log("You should see this from ", __LINE__); // 1
60 log("console default: ", log_console_default);
61 TitanLoggerControl.set_file_mask("LegacyLogger", log_nothing);
62 log("You should not see this (in the log file) from ", __LINE__);
64 // VERDICTOP is off, this line will not be logged
65 setverdict(none, "You should not see this either, from ", __LINE__);
67 var Severities actual_file_mask0 := TitanLoggerControl.get_file_mask("LegacyLogger");
69 // set it back to LOG_ALL
70 TitanLoggerControl.set_file_mask("LegacyLogger", log_all);
71 log("You should see this again, from ", __LINE__); // 2
73 setverdict(pass, "We're back! at ", __LINE__); // this should be visible
75 // now check the previously retrieved logger setting
76 if ( match(actual_file_mask0, TitanLoggerControl.log_nothing)) { setverdict(pass); }
77 else { setverdict(fail, match(actual_file_mask0, TitanLoggerControl.log_nothing)); }
79 TitanLoggerControl.set_file_mask("LegacyLogger", log_everything);
80 log("You should see this too, from ", __LINE__); // 3
82 var Severities actual_file_mask_everything := TitanLoggerControl.get_file_mask("LegacyLogger");
83 if ( match(actual_file_mask_everything, TitanLoggerControl.log_everything)) { setverdict(pass); }
84 else { setverdict(fail, match(actual_file_mask_everything, TitanLoggerControl.log_everything)); }
86 TitanLoggerControl.remove_from_file_mask("LegacyLogger", user_log_only);
87 log("Again, you should not see this from ", __LINE__);
89 TitanLoggerControl.add_to_file_mask("LegacyLogger", user_log_only);
90 log("And, you should see this from ", __LINE__); // 4
92 action("speaks louder than words, so you can see this at ", __LINE__); // 5
93 TitanLoggerControl.remove_from_file_mask("LegacyLogger", valueof(aew));
94 action("You should not see this action at ", __LINE__);
97 testcase entity() runs on L
100 var boolean log_entity_name := TitanLoggerControl.get_log_entity_name("LegacyLogger");
101 if (log_entity_name) { setverdict(fail, "LogEntityName should default to FALSE"); }
102 else { setverdict(pass); }
104 TitanLoggerControl.set_log_entity_name("LegacyLogger", true);
105 log_entity_name := TitanLoggerControl.get_log_entity_name("LegacyLogger");
106 if (log_entity_name) { setverdict(pass); }
107 else { setverdict(fail, "LogEntityName should be TRUE now"); }
109 log("The tc should be mentioned in this log line");
112 TitanLoggerControl.set_log_entity_name("LegacyLogger", false);
113 log("The entity should not be logged anymore");
116 type set of record { integer field1, charstring field2 } rr;
118 template rr t_rr := {
120 field1 := 42, field2 := "fourty-two"
123 field1 := 13, field2 := "Hail Eris!"
129 field1 := 42, field2 := "forty-two" // 'u' is missing
132 field1 := 13, field2 := "Hail Eris!"
136 testcase hints() runs on L
139 var verbosity v := TitanLoggerControl.get_matching_verbosity("LegacyLogger");
140 if (v == compact) { setverdict(pass); }
141 else { setverdict(fail, "Matching verbosity should default to compact"); }
143 log("Compact:", match(c_rr, t_rr));
145 TitanLoggerControl.set_matching_verbosity("LegacyLogger", full);
146 v := TitanLoggerControl.get_matching_verbosity("LegacyLogger");
147 if (v == full) { setverdict(pass); }
148 else { setverdict(fail, "Matching verbosity should now be full"); }
150 log("Full :", match(c_rr, t_rr));
153 testcase changename() runs on L
155 TitanLoggerControl.set_log_file("LegacyLogger", "changed_name-%c-%t.log");
156 log("New log in a new file");
162 execute(read_settings());
168 // last but not least
169 execute(changename());