@@ -31,21 +31,30 @@ static void testAddEnvVarsX(void)
3131 "DEVICE" ,
3232 "FAMILY"
3333 };
34- int expectedNumExtraEnvs = 0 ;
34+ size_t defaultEnvCount = 0 ;
35+ while (default_envs [defaultEnvCount ]) {
36+ defaultEnvCount ++ ;
37+ }
38+ int expectedNumExtraEnvs = defaultEnvCount ;
3539
3640 testDiag ("Testing addReccasterEnvVars with one good env" );
3741 argvlist [1 ] = "SECTOR" ;
3842 argc = 2 ;
3943 i = 0 ;
40- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
44+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
4145 addReccasterEnvVars (& caster , argc , argvlist );
4246 expectedNumExtraEnvs ++ ;
43- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
47+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
4448 ELLNODE * cur ;
45- cur = ellFirst (& caster .extra_envs );
49+ cur = ellFirst (& caster .envs );
4650 while (cur != NULL ) {
4751 string_list_t * temp = (string_list_t * )cur ;
48- testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i ]) == 0 );
52+ if (i < defaultEnvCount ) {
53+ testOk1 (strcmp (temp -> item_str , default_envs [i ]) == 0 );
54+ }
55+ else {
56+ testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i - defaultEnvCount ]) == 0 );
57+ }
4958 i ++ ;
5059 cur = ellNext (cur );
5160 }
@@ -55,14 +64,19 @@ static void testAddEnvVarsX(void)
5564 argvlist [2 ] = "CONTACT" ;
5665 argc = 3 ;
5766 i = 0 ;
58- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
67+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
5968 addReccasterEnvVars (& caster , argc , argvlist );
6069 expectedNumExtraEnvs += 2 ;
61- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
62- cur = ellFirst (& caster .extra_envs );
70+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
71+ cur = ellFirst (& caster .envs );
6372 while (cur != NULL ) {
6473 string_list_t * temp = (string_list_t * )cur ;
65- testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i ]) == 0 );
74+ if (i < defaultEnvCount ) {
75+ testOk1 (strcmp (temp -> item_str , default_envs [i ]) == 0 );
76+ }
77+ else {
78+ testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i - defaultEnvCount ]) == 0 );
79+ }
6680 i ++ ;
6781 cur = ellNext (cur );
6882 }
@@ -71,13 +85,18 @@ static void testAddEnvVarsX(void)
7185 argvlist [1 ] = "SECTOR" ;
7286 argc = 2 ;
7387 i = 0 ;
74- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
88+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
7589 addReccasterEnvVars (& caster , argc , argvlist );
76- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
77- cur = ellFirst (& caster .extra_envs );
90+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
91+ cur = ellFirst (& caster .envs );
7892 while (cur != NULL ) {
7993 string_list_t * temp = (string_list_t * )cur ;
80- testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i ]) == 0 );
94+ if (i < defaultEnvCount ) {
95+ testOk1 (strcmp (temp -> item_str , default_envs [i ]) == 0 );
96+ }
97+ else {
98+ testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i - defaultEnvCount ]) == 0 );
99+ }
81100 i ++ ;
82101 cur = ellNext (cur );
83102 }
@@ -87,14 +106,19 @@ static void testAddEnvVarsX(void)
87106 argvlist [2 ] = "DEVICE" ;
88107 argc = 3 ;
89108 i = 0 ;
90- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
109+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
91110 addReccasterEnvVars (& caster , argc , argvlist );
92111 expectedNumExtraEnvs ++ ;
93- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
94- cur = ellFirst (& caster .extra_envs );
112+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
113+ cur = ellFirst (& caster .envs );
95114 while (cur != NULL ) {
96115 string_list_t * temp = (string_list_t * )cur ;
97- testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i ]) == 0 );
116+ if (i < defaultEnvCount ) {
117+ testOk1 (strcmp (temp -> item_str , default_envs [i ]) == 0 );
118+ }
119+ else {
120+ testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i - defaultEnvCount ]) == 0 );
121+ }
98122 i ++ ;
99123 cur = ellNext (cur );
100124 }
@@ -104,14 +128,19 @@ static void testAddEnvVarsX(void)
104128 argvlist [2 ] = "FAMILY" ;
105129 argc = 3 ;
106130 i = 0 ;
107- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
131+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
108132 addReccasterEnvVars (& caster , argc , argvlist );
109133 expectedNumExtraEnvs ++ ;
110- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
111- cur = ellFirst (& caster .extra_envs );
134+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
135+ cur = ellFirst (& caster .envs );
112136 while (cur != NULL ) {
113137 string_list_t * temp = (string_list_t * )cur ;
114- testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i ]) == 0 );
138+ if (i < defaultEnvCount ) {
139+ testOk1 (strcmp (temp -> item_str , default_envs [i ]) == 0 );
140+ }
141+ else {
142+ testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i - defaultEnvCount ]) == 0 );
143+ }
115144 i ++ ;
116145 cur = ellNext (cur );
117146 }
@@ -124,13 +153,18 @@ static void testAddEnvVarsX(void)
124153 argvlist [5 ] = "ENGINEER" ;
125154 argc = 6 ;
126155 i = 0 ;
127- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
156+ testOk1 (caster .envs .count == expectedNumExtraEnvs );
128157 addReccasterEnvVars (& caster , argc , argvlist );
129- testOk1 (caster .extra_envs .count == expectedNumExtraEnvs );
130- cur = ellFirst (& caster .extra_envs );
158+ testOk1 (caster .envs .count == expectedNumExtraEnvs ); /* these are all defaults so the count should not change */
159+ cur = ellFirst (& caster .envs );
131160 while (cur != NULL ) {
132161 string_list_t * temp = (string_list_t * )cur ;
133- testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i ]) == 0 );
162+ if (i < defaultEnvCount ) {
163+ testOk1 (strcmp (temp -> item_str , default_envs [i ]) == 0 );
164+ }
165+ else {
166+ testOk1 (strcmp (temp -> item_str , expectedExtraEnvs [i - defaultEnvCount ]) == 0 );
167+ }
134168 i ++ ;
135169 cur = ellNext (cur );
136170 }
@@ -145,30 +179,36 @@ static void testAddEnvVarsBadInput(void)
145179 casterInit (& caster );
146180 caster .onmsg = & testLog ;
147181
182+ size_t defaultEnvCount = 0 ;
183+ while (default_envs [defaultEnvCount ]) {
184+ defaultEnvCount ++ ;
185+ }
186+
148187 int argc ;
149188 char * argvlist [2 ];
150189 argvlist [0 ] = "addReccasterEnvVars" ;
151190
152191 testDiag ("Testing addReccasterEnvVars with no arguments" );
153192 argc = 1 ;
154- testOk1 (caster .extra_envs .count == 0 );
193+ testOk1 (caster .envs .count == defaultEnvCount );
155194 addReccasterEnvVars (& caster , argc , argvlist );
156- testOk1 (caster .extra_envs .count == 0 );
195+ testOk1 (caster .envs .count == defaultEnvCount );
157196
158197 testDiag ("Testing addReccasterEnvVars with empty string argument" );
159198 argvlist [1 ] = "" ;
160199 argc = 2 ;
161- testOk1 (caster .extra_envs .count == 0 );
200+ testOk1 (caster .envs .count == defaultEnvCount );
162201 addReccasterEnvVars (& caster , argc , argvlist );
163- testOk1 (caster .extra_envs .count == 0 );
202+ testOk1 (caster .envs .count == defaultEnvCount );
164203
165204 epicsEventSignal (caster .shutdownEvent );
166205 casterShutdown (& caster );
167206}
168207
169208MAIN (testAddEnvVars )
170209{
171- testPlan (37 );
210+ /* 96 is defaultEnvCount * 6 for each test loop to check default env list */
211+ testPlan (37 + 96 );
172212 osiSockAttach ();
173213 testAddEnvVarsX ();
174214 testAddEnvVarsBadInput ();
0 commit comments