diff options
Diffstat (limited to 'lib/tests/test_utils.c')
-rw-r--r-- | lib/tests/test_utils.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c index 79e1110a..7a1a1fa1 100644 --- a/lib/tests/test_utils.c +++ b/lib/tests/test_utils.c | |||
@@ -40,20 +40,20 @@ main (int argc, char **argv) | |||
40 | 40 | ||
41 | plan_tests(150); | 41 | plan_tests(150); |
42 | 42 | ||
43 | ok( this_nagios_plugin==NULL, "nagios_plugin not initialised"); | 43 | ok( this_monitoring_plugin==NULL, "monitoring_plugin not initialised"); |
44 | 44 | ||
45 | np_init( "check_test", argc, argv ); | 45 | np_init( "check_test", argc, argv ); |
46 | 46 | ||
47 | ok( this_nagios_plugin!=NULL, "nagios_plugin now initialised"); | 47 | ok( this_monitoring_plugin!=NULL, "monitoring_plugin now initialised"); |
48 | ok( !strcmp(this_nagios_plugin->plugin_name, "check_test"), "plugin name initialised" ); | 48 | ok( !strcmp(this_monitoring_plugin->plugin_name, "check_test"), "plugin name initialised" ); |
49 | 49 | ||
50 | ok( this_nagios_plugin->argc==argc, "Argc set" ); | 50 | ok( this_monitoring_plugin->argc==argc, "Argc set" ); |
51 | ok( this_nagios_plugin->argv==argv, "Argv set" ); | 51 | ok( this_monitoring_plugin->argv==argv, "Argv set" ); |
52 | 52 | ||
53 | np_set_args(0,0); | 53 | np_set_args(0,0); |
54 | 54 | ||
55 | ok( this_nagios_plugin->argc==0, "argc changed" ); | 55 | ok( this_monitoring_plugin->argc==0, "argc changed" ); |
56 | ok( this_nagios_plugin->argv==0, "argv changed" ); | 56 | ok( this_monitoring_plugin->argv==0, "argv changed" ); |
57 | 57 | ||
58 | np_set_args(argc, argv); | 58 | np_set_args(argc, argv); |
59 | 59 | ||
@@ -296,11 +296,11 @@ main (int argc, char **argv) | |||
296 | diag( "You are probably running in wrong directory. Must run as ./test_utils" ); | 296 | diag( "You are probably running in wrong directory. Must run as ./test_utils" ); |
297 | 297 | ||
298 | 298 | ||
299 | this_nagios_plugin->argc=4; | 299 | this_monitoring_plugin->argc=4; |
300 | this_nagios_plugin->argv[0] = "./test_utils"; | 300 | this_monitoring_plugin->argv[0] = "./test_utils"; |
301 | this_nagios_plugin->argv[1] = "here"; | 301 | this_monitoring_plugin->argv[1] = "here"; |
302 | this_nagios_plugin->argv[2] = "--and"; | 302 | this_monitoring_plugin->argv[2] = "--and"; |
303 | this_nagios_plugin->argv[3] = "now"; | 303 | this_monitoring_plugin->argv[3] = "now"; |
304 | temp_string = (char *) _np_state_generate_key(); | 304 | temp_string = (char *) _np_state_generate_key(); |
305 | ok(!strcmp(temp_string, "94b5e17bf5abf51cb15aff5f69b96f2f8dac5ecd"), "Got based on expected argv" ); | 305 | ok(!strcmp(temp_string, "94b5e17bf5abf51cb15aff5f69b96f2f8dac5ecd"), "Got based on expected argv" ); |
306 | 306 | ||
@@ -320,16 +320,16 @@ main (int argc, char **argv) | |||
320 | 320 | ||
321 | ok(temp_state_key==NULL, "temp_state_key initially empty"); | 321 | ok(temp_state_key==NULL, "temp_state_key initially empty"); |
322 | 322 | ||
323 | this_nagios_plugin->argc=1; | 323 | this_monitoring_plugin->argc=1; |
324 | this_nagios_plugin->argv[0] = "./test_utils"; | 324 | this_monitoring_plugin->argv[0] = "./test_utils"; |
325 | np_enable_state(NULL, 51); | 325 | np_enable_state(NULL, 51); |
326 | temp_state_key = this_nagios_plugin->state; | 326 | temp_state_key = this_monitoring_plugin->state; |
327 | ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); | 327 | ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); |
328 | ok( !strcmp(temp_state_key->name, "83d877b6cdfefb5d6f06101fd6fe76762f21792c"), "Got generated filename" ); | 328 | ok( !strcmp(temp_state_key->name, "83d877b6cdfefb5d6f06101fd6fe76762f21792c"), "Got generated filename" ); |
329 | 329 | ||
330 | 330 | ||
331 | np_enable_state("allowedchars_in_keyname", 77); | 331 | np_enable_state("allowedchars_in_keyname", 77); |
332 | temp_state_key = this_nagios_plugin->state; | 332 | temp_state_key = this_monitoring_plugin->state; |
333 | ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); | 333 | ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); |
334 | ok( !strcmp(temp_state_key->name, "allowedchars_in_keyname"), "Got key name with valid chars" ); | 334 | ok( !strcmp(temp_state_key->name, "allowedchars_in_keyname"), "Got key name with valid chars" ); |
335 | ok( !strcmp(temp_state_key->_filename, "/usr/local/nagios/var/check_test/allowedchars_in_keyname"), "Got internal filename" ); | 335 | ok( !strcmp(temp_state_key->_filename, "/usr/local/nagios/var/check_test/allowedchars_in_keyname"), "Got internal filename" ); |
@@ -338,12 +338,12 @@ main (int argc, char **argv) | |||
338 | /* Don't do this test just yet. Will die */ | 338 | /* Don't do this test just yet. Will die */ |
339 | /* | 339 | /* |
340 | np_enable_state("bad^chars$in@here", 77); | 340 | np_enable_state("bad^chars$in@here", 77); |
341 | temp_state_key = this_nagios_plugin->state; | 341 | temp_state_key = this_monitoring_plugin->state; |
342 | ok( !strcmp(temp_state_key->name, "bad_chars_in_here"), "Got key name with bad chars replaced" ); | 342 | ok( !strcmp(temp_state_key->name, "bad_chars_in_here"), "Got key name with bad chars replaced" ); |
343 | */ | 343 | */ |
344 | 344 | ||
345 | np_enable_state("funnykeyname", 54); | 345 | np_enable_state("funnykeyname", 54); |
346 | temp_state_key = this_nagios_plugin->state; | 346 | temp_state_key = this_monitoring_plugin->state; |
347 | ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); | 347 | ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); |
348 | ok( !strcmp(temp_state_key->name, "funnykeyname"), "Got key name" ); | 348 | ok( !strcmp(temp_state_key->name, "funnykeyname"), "Got key name" ); |
349 | 349 | ||
@@ -367,9 +367,9 @@ main (int argc, char **argv) | |||
367 | 367 | ||
368 | temp_state_key->_filename="var/statefile"; | 368 | temp_state_key->_filename="var/statefile"; |
369 | temp_state_data = np_state_read(); | 369 | temp_state_data = np_state_read(); |
370 | 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"); | 370 | ok( this_monitoring_plugin->state->state_data!=NULL, "Got state data now" ) || diag("Are you running in right directory? Will get coredump next if not"); |
371 | ok( this_nagios_plugin->state->state_data->time==1234567890, "Got time" ); | 371 | ok( this_monitoring_plugin->state->state_data->time==1234567890, "Got time" ); |
372 | ok( !strcmp((char *)this_nagios_plugin->state->state_data->data, "String to read"), "Data as expected" ); | 372 | ok( !strcmp((char *)this_monitoring_plugin->state->state_data->data, "String to read"), "Data as expected" ); |
373 | 373 | ||
374 | temp_state_key->data_version=53; | 374 | temp_state_key->data_version=53; |
375 | temp_state_data = np_state_read(); | 375 | temp_state_data = np_state_read(); |
@@ -379,7 +379,7 @@ main (int argc, char **argv) | |||
379 | temp_state_key->_filename="var/nonexistant"; | 379 | temp_state_key->_filename="var/nonexistant"; |
380 | temp_state_data = np_state_read(); | 380 | temp_state_data = np_state_read(); |
381 | ok( temp_state_data==NULL, "Missing file gives NULL" ); | 381 | ok( temp_state_data==NULL, "Missing file gives NULL" ); |
382 | ok( this_nagios_plugin->state->state_data==NULL, "No state information" ); | 382 | ok( this_monitoring_plugin->state->state_data==NULL, "No state information" ); |
383 | 383 | ||
384 | temp_state_key->_filename="var/oldformat"; | 384 | temp_state_key->_filename="var/oldformat"; |
385 | temp_state_data = np_state_read(); | 385 | temp_state_data = np_state_read(); |
@@ -426,7 +426,7 @@ main (int argc, char **argv) | |||
426 | temp_state_data = np_state_read(); | 426 | temp_state_data = np_state_read(); |
427 | /* Check time is set to current_time */ | 427 | /* Check time is set to current_time */ |
428 | ok(system("cmp var/generated var/statefile > /dev/null")!=0, "Generated file should be different this time"); | 428 | ok(system("cmp var/generated var/statefile > /dev/null")!=0, "Generated file should be different this time"); |
429 | ok(this_nagios_plugin->state->state_data->time-current_time<=1, "Has time generated from current time"); | 429 | ok(this_monitoring_plugin->state->state_data->time-current_time<=1, "Has time generated from current time"); |
430 | 430 | ||
431 | 431 | ||
432 | /* Don't know how to automatically test this. Need to be able to redefine die and catch the error */ | 432 | /* Don't know how to automatically test this. Need to be able to redefine die and catch the error */ |
@@ -438,7 +438,7 @@ main (int argc, char **argv) | |||
438 | 438 | ||
439 | np_cleanup(); | 439 | np_cleanup(); |
440 | 440 | ||
441 | ok( this_nagios_plugin==NULL, "Free'd this_nagios_plugin" ); | 441 | ok( this_monitoring_plugin==NULL, "Free'd this_monitoring_plugin" ); |
442 | 442 | ||
443 | return exit_status(); | 443 | return exit_status(); |
444 | } | 444 | } |