You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
printf(" test for ups.status: '%s'; any duplicates?\n", NUT_STRARG(valueStr));
90
+
printf(" test for ups.status: '%s'; got no duplicates?\n", NUT_STRARG(valueStr));
90
91
91
-
/* test case #2, build on top of #1 */
92
+
/* test case #2 (built on top of #1) */
93
+
/* we raise an alarm using the modern alarm functions */
94
+
/* expectation: alarm status token is present */
95
+
/* note: normally we would re-init and re-set the values */
92
96
alarm_init();
93
97
alarm_set("Test alarm 1");
94
98
alarm_set("[Test alarm 2]");
95
99
alarm_set("Test alarm 1");
96
100
alarm_commit();
97
-
/* Note: normally we re-init and re-set the values */
98
-
status_commit();
101
+
status_commit(); /* to register ALARM status */
102
+
99
103
valueStr=dstate_getinfo("ups.status");
100
104
report_0_means_pass(strcmp(valueStr, "ALARM OL BOOST OB"));
101
-
printf(" test for ups.status: '%s'; got alarm?\n", NUT_STRARG(valueStr));
105
+
printf(" test for ups.status: '%s'; got alarm, no duplicates?\n", NUT_STRARG(valueStr));
102
106
103
-
/* test case #3, build on top of #2 */
107
+
/* test case #3 (built on top of #2) */
108
+
/* we raise an alarm using the modern alarm functions */
109
+
/* expectation: three alarm messages stored in ups.alarm */
110
+
/* note: normally we would re-init and re-set the values */
104
111
valueStr=dstate_getinfo("ups.alarm");
105
-
/* NOTE: no dedup here! */
106
112
report_0_means_pass(strcmp(valueStr, "Test alarm 1 [Test alarm 2] Test alarm 1"));
107
113
printf(" test for ups.alarm: '%s'; got 3 alarms?\n", NUT_STRARG(valueStr));
108
114
109
-
/* test case #4, build on top of #1 and #2 */
110
-
/* Note: normally we re-init and re-set the values */
115
+
/* test case #4 (built on top of #3) */
116
+
/* reset the status, see if the raised modern alarm persists */
117
+
/* expectation: alarm remains, no duplicate tokens reported */
118
+
/* note: normally we would re-init and re-set the values */
119
+
status_init();
120
+
status_set(" OL ");
121
+
status_set("OL BOOST");
122
+
status_set("OB ");
123
+
status_set(" BOOST");
111
124
status_set("BOO");
112
125
status_set("BOO");
113
126
status_set("OST");
114
127
status_set("OST");
115
128
status_set("OOS");
116
129
status_set("OOS");
117
130
status_commit();
131
+
118
132
valueStr=dstate_getinfo("ups.status");
119
133
report_0_means_pass(strcmp(valueStr, "ALARM OL BOOST OB BOO OST OOS"));
120
-
printf(" test for ups.status: '%s'; any duplicates?\n", NUT_STRARG(valueStr));
134
+
printf(" test for ups.status: '%s'; got alarm, no duplicates?\n", NUT_STRARG(valueStr));
135
+
136
+
/* test case #5 (built on top of #4) */
137
+
/* reset the status, see if the raised modern alarm persists */
138
+
/* expectation: three alarm messages still stored in ups.alarm */
139
+
/* note: normally we would re-init and re-set the values */
140
+
valueStr=dstate_getinfo("ups.alarm");
141
+
report_0_means_pass(strcmp(valueStr, "Test alarm 1 [Test alarm 2] Test alarm 1"));
142
+
printf(" test for ups.alarm: '%s'; got 3 alarms?\n", NUT_STRARG(valueStr));
143
+
144
+
/* clear testing state for next from-scratch test */
145
+
alarm_init();
146
+
alarm_commit();
147
+
status_init();
148
+
status_commit();
121
149
122
-
/* test case #5+#6 from scratch */
150
+
/* test case #6 (from scratch) */
151
+
/* mix legacy alarm status and modern alarm functions */
152
+
/* expectation: alarm status token is present, no duplicates */
123
153
status_init();
124
154
alarm_init();
125
155
status_set("OL BOOST");
@@ -131,13 +161,25 @@ int main(int argc, char **argv) {
131
161
132
162
valueStr=dstate_getinfo("ups.status");
133
163
report_0_means_pass(strcmp(valueStr, "ALARM OL BOOST OB"));
134
-
printf(" test for ups.status with explicit ALARM set via status_set() and alarm_set() was not used first: '%s'; any duplicate ALARM?\n", NUT_STRARG(valueStr));
164
+
printf(" test for ups.status with explicit ALARM set via status_set() and alarm_set() was not used first: '%s'; got alarm, no duplicates?\n", NUT_STRARG(valueStr));
135
165
166
+
/* test case #7 (built on top of #6) */
167
+
/* mix legacy alarm status and modern alarm functions */
168
+
/* expectation: 1 alarm message is recorded in ups.alarm */
169
+
/* note: normally we would re-init and re-set the values */
printf(" test for ups.alarm with explicit ALARM set via status_set() and alarm_set() was not used first: '%s'; got 1 alarm (injected N/A replaced by later explicit text)\n", NUT_STRARG(valueStr));
172
+
printf(" test for ups.alarm with explicit ALARM set via status_set() and alarm_set() was not used first: '%s'; got 1 alarm?\n", NUT_STRARG(valueStr));
139
173
140
-
/* test case #7+#8 from scratch */
174
+
/* clear testing state for next from-scratch test */
175
+
alarm_init();
176
+
alarm_commit();
177
+
status_init();
178
+
status_commit();
179
+
180
+
/* test case #8 (from scratch) */
181
+
/* mix legacy alarm status and modern alarm functions (reverse) */
182
+
/* expectation: alarm status token is present, no duplicates */
141
183
status_init();
142
184
alarm_init();
143
185
status_set("OL BOOST");
@@ -149,78 +191,129 @@ int main(int argc, char **argv) {
149
191
150
192
valueStr=dstate_getinfo("ups.status");
151
193
report_0_means_pass(strcmp(valueStr, "ALARM OL BOOST OB"));
152
-
printf(" test for ups.status with explicit ALARM set via status_set() and alarm_set() was used first: '%s'; any duplicate ALARM?\n", NUT_STRARG(valueStr));
194
+
printf(" test for ups.status with explicit ALARM set via status_set() and alarm_set() was used first: '%s'; got alarm, no duplicates?\n", NUT_STRARG(valueStr));
153
195
196
+
/* test case #9 (built on top of #8) */
197
+
/* mix legacy alarm status and modern alarm functions (reverse) */
198
+
/* expectation: 1 alarm message is recorded in ups.alarm */
199
+
/* note: normally we would re-init and re-set the values */
printf(" test for ups.alarm with explicit ALARM set via status_set() and alarm_set() was used first: '%s'; got 1 alarm (none injected)\n", NUT_STRARG(valueStr));
202
+
printf(" test for ups.alarm with explicit ALARM set via status_set() and alarm_set() was used first: '%s'; got 1 alarm?\n", NUT_STRARG(valueStr));
157
203
158
-
/* test case #9+#10 from scratch */
159
-
status_init();
204
+
/* clear testing state for next from-scratch test */
160
205
alarm_init();
206
+
alarm_commit();
207
+
status_init();
208
+
status_commit();
209
+
210
+
/* test case #10 (from scratch) */
211
+
/* legacy alarm status and no modern alarm functions */
212
+
/* expectation: alarm status token is present, no duplicates */
213
+
status_init();
161
214
status_set("OL BOOST");
162
215
status_set("ALARM");
163
216
status_set("OB");
164
-
alarm_commit();
165
217
status_commit();
166
218
167
219
valueStr=dstate_getinfo("ups.status");
168
220
report_0_means_pass(strcmp(valueStr, "ALARM OL BOOST OB"));
169
-
printf(" test for ups.status with explicit ALARM set via status_set() and no extra alarm_set(): '%s'; any duplicate ALARM?\n", NUT_STRARG(valueStr));
221
+
printf(" test for ups.status with explicit ALARM set via status_set() and no extra alarm_ funcs: '%s'; got alarm, no duplicates?\n", NUT_STRARG(valueStr));
170
222
223
+
/* test case #11 (built on top of #10) */
224
+
/* legacy alarm status and no modern alarm functions */
225
+
/* expectation: no alarm message is recorded in ups.alarm */
226
+
/* note: normally we would re-init and re-set the values */
report_0_means_pass(strcmp(valueStr, "ALARM OL BOOST OB LB"));
190
-
printf(" test for ups.status with explicit ALARM set via status_set() and no extra alarm_set() nor alarm_commit(): '%s'; is ALARM reported?\n", NUT_STRARG(valueStr));
printf(" test for ups.status with ignored LB: '%s'; got no alarm, ignored LB, no duplicates?\n", NUT_STRARG(valueStr));
191
250
192
-
valueStr=dstate_getinfo("ups.alarm");
193
-
/*
194
-
report_0_means_pass(valueStr != NULL); // pass if valueStr is NULL
195
-
printf(" test for ups.alarm with explicit ALARM set via status_set() and no extra alarm_set() nor alarm_commit(): '%s'; got no alarms spelled out\n", NUT_STRARG(valueStr));
printf(" test for ups.alarm with explicit ALARM set via status_set() and no extra alarm_set() nor alarm_commit(): '%s'; got 1 (injected) alarm\n", NUT_STRARG(valueStr));
199
-
200
-
/* test case #13+#14 from scratch */
201
-
/* flush ups.alarm report */
251
+
/* clear testing state for next from-scratch test */
printf(" test for ups.alarm with explicit alarm_set(N/A) and another alarm_set(): '%s'; got both alarms, namesake of not-injected is not overwritten\n", NUT_STRARG(valueStr));
312
+
/* clear testing state before finish */
313
+
alarm_init();
314
+
alarm_commit();
315
+
status_init();
316
+
status_commit();
224
317
225
318
/* finish */
226
319
printf("test_rules completed. Total cases %d, passed %d, failed %d\n",
0 commit comments