From 301599a4eca67e214ef79bd609843a9e1e710b3a Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Thu, 17 Jun 2010 10:57:59 +0100 Subject: Add skeleton tests --- lib/tests/test_utils.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib/tests') diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c index 3a45944a..057c4845 100644 --- a/lib/tests/test_utils.c +++ b/lib/tests/test_utils.c @@ -28,6 +28,10 @@ main (int argc, char **argv) double temp; thresholds *thresholds = NULL; int rc; + char *temp_string; + state_key *temp_state_key = NULL; + state_data *temp_state_data; + time_t current_time; plan_tests(81+23); @@ -251,5 +255,29 @@ main (int argc, char **argv) test=np_extract_ntpvar("", "foo"); ok(!test, "Empty string return NULL"); + + temp_string = np_state_generate_key(argv); + ok(!strcmp(temp_string, "Ahash"), "Got hash" ); + + ok(temp_state_key==NULL, "temp_state_key initially empty"); + temp_state_key = np_state_init("check_test", temp_string, 54); + ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); + ok( !strcmp(temp_state_key->name, temp_string), "Got key name" ); + ok( !strcmp(temp_state_key->_filename, "Tobedone"), "Got internal filename" ); + ok( temp_state_key->data_version==54, "Version set" ); + + temp_state_data = np_state_read(temp_state_key); + ok( temp_state_data==NULL, "Got state data" ); + + time(¤t_time); + np_state_write_string(temp_state_key, NULL, "New data"); + + temp_state_data = np_state_read(temp_state_key); + /* Check time is set to current_time */ + + + np_state_cleanup(temp_state_key); + ok(temp_state_key==NULL, "temp_state_key cleared"); + return exit_status(); } -- cgit v1.2.3-74-g34f1