diff options
| author | Ton Voon <ton.voon@opsera.com> | 2010-06-17 10:57:59 +0100 |
|---|---|---|
| committer | Ton Voon <ton.voon@opsera.com> | 2010-06-17 10:57:59 +0100 |
| commit | 301599a4eca67e214ef79bd609843a9e1e710b3a (patch) | |
| tree | e2404d11826e25e632d31dd4c6beea627e4dda9d /lib/tests | |
| parent | 95b190f3dee629b1c1ee2fab5b69c08e511f51b3 (diff) | |
| download | monitoring-plugins-301599a4eca67e214ef79bd609843a9e1e710b3a.tar.gz | |
Add skeleton tests
Diffstat (limited to 'lib/tests')
| -rw-r--r-- | lib/tests/test_utils.c | 28 |
1 files changed, 28 insertions, 0 deletions
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) | |||
| 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(¤t_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 | } |
