diff options
Diffstat (limited to 'lib/tests/test_utils.c')
-rw-r--r-- | lib/tests/test_utils.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c index 53369077..d4a08005 100644 --- a/lib/tests/test_utils.c +++ b/lib/tests/test_utils.c | |||
@@ -37,8 +37,6 @@ main (int argc, char **argv) | |||
37 | state_key *temp_state_key = NULL; | 37 | state_key *temp_state_key = NULL; |
38 | state_data *temp_state_data; | 38 | state_data *temp_state_data; |
39 | time_t current_time; | 39 | time_t current_time; |
40 | char *temp_filename; | ||
41 | FILE *temp_fp; | ||
42 | 40 | ||
43 | plan_tests(141); | 41 | plan_tests(141); |
44 | 42 | ||
@@ -342,7 +340,7 @@ main (int argc, char **argv) | |||
342 | ok( !strcmp(temp_state_key->_filename, "/usr/local/nagios/var/check_test/funnykeyname"), "Got internal filename" ); | 340 | ok( !strcmp(temp_state_key->_filename, "/usr/local/nagios/var/check_test/funnykeyname"), "Got internal filename" ); |
343 | ok( temp_state_key->data_version==54, "Version set" ); | 341 | ok( temp_state_key->data_version==54, "Version set" ); |
344 | 342 | ||
345 | temp_state_data = np_state_read(temp_state_key); | 343 | temp_state_data = np_state_read(); |
346 | ok( temp_state_data==NULL, "Got no state data as file does not exist" ); | 344 | ok( temp_state_data==NULL, "Got no state data as file does not exist" ); |
347 | 345 | ||
348 | 346 | ||
@@ -356,31 +354,31 @@ main (int argc, char **argv) | |||
356 | */ | 354 | */ |
357 | 355 | ||
358 | temp_state_key->_filename="var/statefile"; | 356 | temp_state_key->_filename="var/statefile"; |
359 | temp_state_data = np_state_read(temp_state_key); | 357 | temp_state_data = np_state_read(); |
360 | ok( this_nagios_plugin->state->state_data!=NULL, "Got state data now" ) || diag("Are you running in right directory? Will get coredump next if not"); | 358 | ok( this_nagios_plugin->state->state_data!=NULL, "Got state data now" ) || diag("Are you running in right directory? Will get coredump next if not"); |
361 | ok( this_nagios_plugin->state->state_data->time==1234567890, "Got time" ); | 359 | ok( this_nagios_plugin->state->state_data->time==1234567890, "Got time" ); |
362 | ok( !strcmp((char *)this_nagios_plugin->state->state_data->data, "String to read"), "Data as expected" ); | 360 | ok( !strcmp((char *)this_nagios_plugin->state->state_data->data, "String to read"), "Data as expected" ); |
363 | 361 | ||
364 | temp_state_key->data_version=53; | 362 | temp_state_key->data_version=53; |
365 | temp_state_data = np_state_read(temp_state_key); | 363 | temp_state_data = np_state_read(); |
366 | ok( temp_state_data==NULL, "Older data version gives NULL" ); | 364 | ok( temp_state_data==NULL, "Older data version gives NULL" ); |
367 | temp_state_key->data_version=54; | 365 | temp_state_key->data_version=54; |
368 | 366 | ||
369 | temp_state_key->_filename="var/nonexistant"; | 367 | temp_state_key->_filename="var/nonexistant"; |
370 | temp_state_data = np_state_read(temp_state_key); | 368 | temp_state_data = np_state_read(); |
371 | ok( temp_state_data==NULL, "Missing file gives NULL" ); | 369 | ok( temp_state_data==NULL, "Missing file gives NULL" ); |
372 | ok( this_nagios_plugin->state->state_data==NULL, "No state information" ); | 370 | ok( this_nagios_plugin->state->state_data==NULL, "No state information" ); |
373 | 371 | ||
374 | temp_state_key->_filename="var/oldformat"; | 372 | temp_state_key->_filename="var/oldformat"; |
375 | temp_state_data = np_state_read(temp_state_key); | 373 | temp_state_data = np_state_read(); |
376 | ok( temp_state_data==NULL, "Old file format gives NULL" ); | 374 | ok( temp_state_data==NULL, "Old file format gives NULL" ); |
377 | 375 | ||
378 | temp_state_key->_filename="var/baddate"; | 376 | temp_state_key->_filename="var/baddate"; |
379 | temp_state_data = np_state_read(temp_state_key); | 377 | temp_state_data = np_state_read(); |
380 | ok( temp_state_data==NULL, "Bad date gives NULL" ); | 378 | ok( temp_state_data==NULL, "Bad date gives NULL" ); |
381 | 379 | ||
382 | temp_state_key->_filename="var/missingdataline"; | 380 | temp_state_key->_filename="var/missingdataline"; |
383 | temp_state_data = np_state_read(temp_state_key); | 381 | temp_state_data = np_state_read(); |
384 | ok( temp_state_data==NULL, "Missing data line gives NULL" ); | 382 | ok( temp_state_data==NULL, "Missing data line gives NULL" ); |
385 | 383 | ||
386 | 384 | ||
@@ -413,7 +411,7 @@ main (int argc, char **argv) | |||
413 | temp_state_key->_filename="var/generated"; | 411 | temp_state_key->_filename="var/generated"; |
414 | time(¤t_time); | 412 | time(¤t_time); |
415 | np_state_write_string(0, "String to read"); | 413 | np_state_write_string(0, "String to read"); |
416 | temp_state_data = np_state_read(temp_state_key); | 414 | temp_state_data = np_state_read(); |
417 | /* Check time is set to current_time */ | 415 | /* Check time is set to current_time */ |
418 | ok(system("cmp var/generated var/statefile > /dev/null")!=0, "Generated file should be different this time"); | 416 | ok(system("cmp var/generated var/statefile > /dev/null")!=0, "Generated file should be different this time"); |
419 | ok(this_nagios_plugin->state->state_data->time-current_time<=1, "Has time generated from current time"); | 417 | ok(this_nagios_plugin->state->state_data->time-current_time<=1, "Has time generated from current time"); |