14
14
#include "util_memory.h"
15
15
16
16
#include "tlib_main.h"
17
+ #include "util_strings.h"
17
18
#include "util_syscalls.h"
18
19
19
20
static void test_health (void ) {
20
21
nr_status_t rv ;
21
22
char * location = NULL ;
23
+ char * rand_uuid = NULL ;
24
+ char * rand_healthfile = NULL ;
22
25
23
26
nrh_set_start_time ();
24
27
@@ -29,42 +32,60 @@ static void test_health(void) {
29
32
tlib_pass_if_true ("initialization to bad path fails" , NULL == location ,
30
33
"location=%s" , NULL == location ? "NULL" : location );
31
34
nr_free (location );
32
-
33
35
rv = nrh_set_uuid ("bc21b5891f5e44fc9272caef924611a" );
34
36
tlib_pass_if_true ("set uuid with invalid length uuid fails" , NR_FAILURE == rv ,
35
37
"rv=%d" , (int )rv );
36
38
37
- rv = nrh_set_uuid ("ffffffffffffffffffffffffffffffff" );
38
- tlib_pass_if_true ("set uuid succeeds" , NR_SUCCESS == rv , "rv=%d" , (int )rv );
39
-
40
39
location = nrh_get_health_location ("file://./" );
41
40
tlib_pass_if_true ("initialization to good path succeeds" , NULL != location ,
42
41
"location=%s" , NULL == location ? "NULL" : location );
42
+ rv = nrh_set_last_error (NRH_INVALID_LICENSE );
43
+ rv = nrh_write_health (location );
44
+ tlib_pass_if_true ("health file write succeeds" , NR_SUCCESS == rv , "rv=%d" ,
45
+ (int )rv );
46
+ tlib_pass_if_exists ("./health-bc21b5891f5e44fc9272caef924611a8.yml" );
43
47
48
+ rv = nrh_set_uuid ("ffffffffffffffffffffffffffffffff" );
49
+ tlib_pass_if_true ("set uuid succeeds" , NR_SUCCESS == rv , "rv=%d" , (int )rv );
44
50
rv = nrh_set_last_error (NRH_MISSING_LICENSE );
45
-
46
51
rv = nrh_write_health (location );
47
52
tlib_pass_if_true ("health file write succeeds" , NR_SUCCESS == rv , "rv=%d" ,
48
53
(int )rv );
49
-
50
54
tlib_pass_if_exists ("./health-ffffffffffffffffffffffffffffffff.yml" );
51
55
52
56
rv = nrh_set_last_error (NRH_MISSING_APPNAME );
53
-
54
57
rv = nrh_write_health (location );
55
58
tlib_pass_if_true ("write_health succeeds" , NR_SUCCESS == rv , "rv=%d" ,
56
59
(int )rv );
57
60
58
61
rv = nrh_set_last_error (NRH_HEALTHY );
59
-
60
62
rv = nrh_write_health (location );
61
63
tlib_pass_if_true ("write_health succeeds" , NR_SUCCESS == rv , "rv=%d" ,
62
64
(int )rv );
63
65
66
+ rv = nrh_set_uuid (NULL );
67
+ tlib_pass_if_true ("set random uuid succeeds" , NR_SUCCESS == rv , "rv=%d" ,
68
+ (int )rv );
69
+ rand_uuid = nrh_get_uuid ();
70
+ tlib_pass_if_not_null ("get uuid succeeds" , rand_uuid );
71
+ tlib_pass_if_true (
72
+ "manual uuid successfully replaced by random uuid" ,
73
+ 0 != nr_strcmp ("ffffffffffffffffffffffffffffffff" , rand_uuid ), "rand=%s" ,
74
+ rand_uuid );
75
+ rv = nrh_set_last_error (NRH_CONNECTION_FAILED );
76
+ rv = nrh_write_health (location );
77
+
78
+ rand_healthfile = nrh_get_health_filename ();
79
+ tlib_pass_if_not_null ("get health filename succeeds" , rand_healthfile );
80
+ tlib_pass_if_exists (rand_healthfile );
81
+
64
82
nr_unlink ("health-bc21b5891f5e44fc9272caef924611a8.yml" );
65
83
nr_unlink ("health-ffffffffffffffffffffffffffffffff.yml" );
84
+ nr_unlink (rand_healthfile );
66
85
67
86
nr_free (location );
87
+ nr_free (rand_uuid );
88
+ nr_free (rand_healthfile );
68
89
}
69
90
70
91
tlib_parallel_info_t parallel_info
0 commit comments