summaryrefslogtreecommitdiffstats
path: root/lib/tests/test_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tests/test_utils.c')
-rw-r--r--lib/tests/test_utils.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c
index ffab748..ccc4a52 100644
--- a/lib/tests/test_utils.c
+++ b/lib/tests/test_utils.c
@@ -39,12 +39,13 @@ main (int argc, char **argv)
39 nagios_plugin *temp_nagios_plugin; 39 nagios_plugin *temp_nagios_plugin;
40 FILE *temp_fp; 40 FILE *temp_fp;
41 41
42 plan_tests(134); 42 plan_tests(138);
43 43
44 _get_nagios_plugin( &temp_nagios_plugin ); 44 _get_nagios_plugin( &temp_nagios_plugin );
45 ok( temp_nagios_plugin==NULL, "nagios_plugin not initialised"); 45 ok( temp_nagios_plugin==NULL, "nagios_plugin not initialised");
46 46
47 np_init( "check_test" ); 47 np_init( "check_test", argc, argv );
48
48 _get_nagios_plugin( &temp_nagios_plugin ); 49 _get_nagios_plugin( &temp_nagios_plugin );
49 ok( temp_nagios_plugin!=NULL, "nagios_plugin now initialised"); 50 ok( temp_nagios_plugin!=NULL, "nagios_plugin now initialised");
50 ok( !strcmp(temp_nagios_plugin->plugin_name, "check_test"), "plugin name initialised" ); 51 ok( !strcmp(temp_nagios_plugin->plugin_name, "check_test"), "plugin name initialised" );
@@ -271,10 +272,18 @@ main (int argc, char **argv)
271 ok(!test, "Empty string return NULL"); 272 ok(!test, "Empty string return NULL");
272 273
273 274
275 /* This is the result of running ./test_utils */
274 temp_string = (char *) _np_state_generate_key(); 276 temp_string = (char *) _np_state_generate_key();
275 ok(!strcmp(temp_string, "Ahash"), "Got hash" ); 277 ok(!strcmp(temp_string, "83d877b6cdfefb5d6f06101fd6fe76762f21792c"), "Got hash with exe and no parameters" );
276 278
277 279
280 temp_nagios_plugin->argc=4;
281 temp_nagios_plugin->argv[0] = "./test_utils";
282 temp_nagios_plugin->argv[1] = "here";
283 temp_nagios_plugin->argv[2] = "--and";
284 temp_nagios_plugin->argv[3] = "now";
285 temp_string = (char *) _np_state_generate_key();
286 ok(!strcmp(temp_string, "94b5e17bf5abf51cb15aff5f69b96f2f8dac5ecd"), "Got based on expected argv" );
278 287
279 unsetenv("NAGIOS_PLUGIN_STATE_DIRECTORY"); 288 unsetenv("NAGIOS_PLUGIN_STATE_DIRECTORY");
280 temp_string = (char *) _np_state_calculate_location_prefix(); 289 temp_string = (char *) _np_state_calculate_location_prefix();
@@ -292,10 +301,12 @@ main (int argc, char **argv)
292 301
293 ok(temp_state_key==NULL, "temp_state_key initially empty"); 302 ok(temp_state_key==NULL, "temp_state_key initially empty");
294 303
304 temp_nagios_plugin->argc=1;
305 temp_nagios_plugin->argv[0] = "./test_utils";
295 np_enable_state(NULL, 51); 306 np_enable_state(NULL, 51);
296 temp_state_key = temp_nagios_plugin->state; 307 temp_state_key = temp_nagios_plugin->state;
297 ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); 308 ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" );
298 ok( !strcmp(temp_state_key->name, "Ahash"), "Got key name" ); 309 ok( !strcmp(temp_state_key->name, "83d877b6cdfefb5d6f06101fd6fe76762f21792c"), "Got generated filename" );
299 310
300 311
301 np_enable_state("bad^chars$in@here", 77); 312 np_enable_state("bad^chars$in@here", 77);