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.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c
index 3a45944..057c484 100644
--- a/lib/tests/test_utils.c
+++ b/lib/tests/test_utils.c
@@ -28,6 +28,10 @@ main (int argc, char **argv)
28 double temp; 28 double temp;
29 thresholds *thresholds = NULL; 29 thresholds *thresholds = NULL;
30 int rc; 30 int rc;
31 char *temp_string;
32 state_key *temp_state_key = NULL;
33 state_data *temp_state_data;
34 time_t current_time;
31 35
32 plan_tests(81+23); 36 plan_tests(81+23);
33 37
@@ -251,5 +255,29 @@ main (int argc, char **argv)
251 test=np_extract_ntpvar("", "foo"); 255 test=np_extract_ntpvar("", "foo");
252 ok(!test, "Empty string return NULL"); 256 ok(!test, "Empty string return NULL");
253 257
258
259 temp_string = np_state_generate_key(argv);
260 ok(!strcmp(temp_string, "Ahash"), "Got hash" );
261
262 ok(temp_state_key==NULL, "temp_state_key initially empty");
263 temp_state_key = np_state_init("check_test", temp_string, 54);
264 ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" );
265 ok( !strcmp(temp_state_key->name, temp_string), "Got key name" );
266 ok( !strcmp(temp_state_key->_filename, "Tobedone"), "Got internal filename" );
267 ok( temp_state_key->data_version==54, "Version set" );
268
269 temp_state_data = np_state_read(temp_state_key);
270 ok( temp_state_data==NULL, "Got state data" );
271
272 time(&current_time);
273 np_state_write_string(temp_state_key, NULL, "New data");
274
275 temp_state_data = np_state_read(temp_state_key);
276 /* Check time is set to current_time */
277
278
279 np_state_cleanup(temp_state_key);
280 ok(temp_state_key==NULL, "temp_state_key cleared");
281
254 return exit_status(); 282 return exit_status();
255} 283}