@@ -85,10 +85,11 @@ int main(int argc, char **argv) {
8585 status_set ("OL BOOST" );
8686 status_set ("OB " );
8787 status_set (" BOOST" );
88+ status_set (" LB" ); /* Initial ignorelb==0 so this should get set */
8889 status_commit ();
8990
9091 valueStr = dstate_getinfo ("ups.status" );
91- report_0_means_pass (strcmp (valueStr , "OL BOOST OB" ));
92+ report_0_means_pass (strcmp (valueStr , "OL BOOST OB LB " ));
9293 printf (" test for ups.status: '%s'; got no duplicates?\n" , NUT_STRARG (valueStr ));
9394
9495 /* Test case #2 (built on top of #1)
@@ -104,7 +105,7 @@ int main(int argc, char **argv) {
104105 status_commit (); /* to register ALARM status */
105106
106107 valueStr = dstate_getinfo ("ups.status" );
107- report_0_means_pass (strcmp (valueStr , "ALARM OL BOOST OB" ));
108+ report_0_means_pass (strcmp (valueStr , "ALARM OL BOOST OB LB " ));
108109 printf (" test for ups.status: '%s'; got alarm, no duplicates?\n" , NUT_STRARG (valueStr ));
109110
110111 /* Test case #3 (built on top of #2)
@@ -255,7 +256,7 @@ int main(int argc, char **argv) {
255256 status_init ();
256257 status_set ("OL BOOST" );
257258 status_set ("OB" );
258- status_set ("LB" ); /* Should be honoured */
259+ status_set ("LB" ); /* ignorelb should be honoured */
259260 status_commit ();
260261
261262 valueStr = dstate_getinfo ("ups.status" );
@@ -327,6 +328,45 @@ int main(int argc, char **argv) {
327328 report_0_means_pass (strcmp (valueStr , "\0" ));
328329 printf (" test for ups.status with alarm_ set, status_commit() before alarm_commit(): '%s'; got empty, no whitespace?\n" , NUT_STRARG (valueStr ));
329330
331+ /* Test cases #17+#18+#19+#20 (from scratch, checking data step by step)
332+ * Set and commit a status, then add and commit some more (without
333+ * a re-init). The resulting ups.status should contain all set tokens.
334+ */
335+ /* NOTE: This is a flag, either present with any value (true) or absent */
336+ dstate_delinfo ("driver.flag.ignorelb" );
337+
338+ alarm_init ();
339+ alarm_commit ();
340+ status_init ();
341+ status_set ("OB" );
342+ status_set ("LB" ); /* LB should be honoured when we do not ignorelb */
343+
344+ /* #17 */
345+ valueStr = dstate_getinfo ("ups.status" );
346+ report_0_means_pass (strcmp (valueStr , "\0" ));
347+ printf (" test for ups.status empty after status_set() and before status_commit(): '%s'; got alarm, no duplicates?\n" , NUT_STRARG (valueStr ));
348+
349+ status_commit ();
350+
351+ /* #18 */
352+ valueStr = dstate_getinfo ("ups.status" );
353+ report_0_means_pass (strcmp (valueStr , "OB LB" ));
354+ printf (" test for ups.status with just OB and LB set via status_set() and committed: '%s'; got alarm, no duplicates?\n" , NUT_STRARG (valueStr ));
355+
356+ status_set ("FSD" );
357+
358+ /* #19 */
359+ valueStr = dstate_getinfo ("ups.status" );
360+ report_0_means_pass (strcmp (valueStr , "OB LB" ));
361+ printf (" test for ups.status with next token set via status_set() but not yet committed: '%s'; got alarm, no duplicates?\n" , NUT_STRARG (valueStr ));
362+
363+ status_commit ();
364+
365+ /* #20 */
366+ valueStr = dstate_getinfo ("ups.status" );
367+ report_0_means_pass (strcmp (valueStr , "OB LB FSD" ));
368+ printf (" test for ups.status with FSD token set and now committed: '%s'; got alarm, no duplicates?\n" , NUT_STRARG (valueStr ));
369+
330370 /* Clear testing state before finishing. */
331371 alarm_init ();
332372 alarm_commit ();
0 commit comments