VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstRTEnv.cpp@ 96407

Last change on this file since 96407 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 15.4 KB
Line 
1/* $Id: tstRTEnv.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * IPRT Testcase - Environment.
4 */
5
6/*
7 * Copyright (C) 2007-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#include <iprt/env.h>
42#include <iprt/err.h>
43#include <iprt/string.h>
44#include <iprt/test.h>
45
46
47int main()
48{
49 RTTEST hTest;
50 RTEXITCODE rcExit = RTTestInitAndCreate("tstRTEnv", &hTest);
51 if (rcExit != RTEXITCODE_SUCCESS)
52 return rcExit;
53 RTTestBanner(hTest);
54
55#define CHECK(expr) RTTEST_CHECK(hTest, expr)
56#define CHECK_RC(expr, rc) RTTEST_CHECK_RC(hTest, expr, rc)
57#define CHECK_STR(str1, str2) do { if (strcmp(str1, str2)) { RTTestFailed(hTest, "line %u: '%s' != '%s' (*)", __LINE__, str1, str2); } } while (0)
58
59 RTTestSub(hTest, "Basics");
60
61 /*
62 * Try mess around with the path a bit.
63 */
64#ifdef RT_OS_WINDOWS
65 static const char * const k_pszPathVar = "Path";
66#else
67 static const char * const k_pszPathVar = "PATH";
68#endif
69 static const char * const k_pszNonExistantVar = "IPRT_I_DON_T_EXIST";
70
71 CHECK(RTEnvExist(k_pszPathVar));
72 CHECK(RTEnvExistEx(RTENV_DEFAULT, k_pszPathVar));
73 CHECK(!RTEnvExist(k_pszNonExistantVar));
74 CHECK(!RTEnvExistEx(RTENV_DEFAULT, k_pszNonExistantVar));
75
76 CHECK(RTEnvGet(k_pszPathVar) != NULL);
77 char szBuf[8192];
78 char szBuf2[1024];
79 size_t cch;
80 CHECK_RC(RTEnvGetEx(RTENV_DEFAULT, k_pszPathVar, NULL, 0, &cch), VINF_SUCCESS);
81 CHECK(cch < sizeof(szBuf));
82 CHECK_RC(RTEnvGetEx(RTENV_DEFAULT, k_pszPathVar, szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
83 CHECK_RC(RTEnvGetEx(RTENV_DEFAULT, k_pszPathVar, szBuf, sizeof(szBuf), NULL), VINF_SUCCESS);
84 CHECK_RC(RTEnvGetEx(RTENV_DEFAULT, k_pszPathVar, szBuf, 1, &cch), VERR_BUFFER_OVERFLOW);
85 CHECK_RC(RTEnvGetEx(RTENV_DEFAULT, k_pszPathVar, szBuf, 1, NULL), VERR_BUFFER_OVERFLOW);
86
87 /* ditto for a clone. */
88 RTENV Env;
89 CHECK_RC(RTEnvClone(&Env, RTENV_DEFAULT), VINF_SUCCESS);
90 RTENV hEnvEq;
91 CHECK_RC(RTEnvCreateEx(&hEnvEq, RTENV_CREATE_F_ALLOW_EQUAL_FIRST_IN_VAR), VINF_SUCCESS);
92 RTENV hEnvNoEq;
93 CHECK_RC(RTEnvCreateEx(&hEnvNoEq, 0), VINF_SUCCESS);
94
95 CHECK(RTEnvExistEx(Env, k_pszPathVar));
96 CHECK(!RTEnvExistEx(Env, k_pszNonExistantVar));
97
98 CHECK_RC(RTEnvGetEx(Env, k_pszPathVar, NULL, 0, &cch), VINF_SUCCESS);
99 CHECK(cch < sizeof(szBuf));
100 CHECK_RC(RTEnvGetEx(Env, k_pszPathVar, szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
101 CHECK_RC(RTEnvGetEx(Env, k_pszPathVar, szBuf, sizeof(szBuf), NULL), VINF_SUCCESS);
102 CHECK_RC(RTEnvGetEx(Env, k_pszPathVar, szBuf, 1, &cch), VERR_BUFFER_OVERFLOW);
103 CHECK_RC(RTEnvGetEx(Env, k_pszPathVar, szBuf, 1, NULL), VERR_BUFFER_OVERFLOW);
104
105 CHECK_RC(RTEnvGetEx(hEnvEq, k_pszPathVar, szBuf, sizeof(szBuf), NULL), VERR_ENV_VAR_NOT_FOUND);
106 CHECK_RC(RTEnvGetEx(hEnvEq, k_pszPathVar, szBuf, 0, &cch), VERR_ENV_VAR_NOT_FOUND);
107 CHECK_RC(RTEnvGetEx(hEnvEq, "=D:", szBuf, 1, NULL), VERR_ENV_VAR_NOT_FOUND);
108 CHECK_RC(RTEnvGetEx(hEnvNoEq, k_pszPathVar, szBuf, sizeof(szBuf), &cch), VERR_ENV_VAR_NOT_FOUND);
109 CHECK_RC(RTEnvGetEx(hEnvNoEq, k_pszPathVar, szBuf, 1, NULL), VERR_ENV_VAR_NOT_FOUND);
110 RTTestDisableAssertions(hTest);
111 CHECK_RC(RTEnvGetEx(hEnvNoEq, "=D:", szBuf, 1, NULL), VERR_ENV_INVALID_VAR_NAME);
112 RTTestRestoreAssertions(hTest);
113
114 /*
115 * Set and Unset
116 */
117 CHECK_RC(RTEnvSetEx(RTENV_DEFAULT, "IPRTMyNewVar", "MyValue1"), VINF_SUCCESS);
118 CHECK_RC(RTEnvGetEx(RTENV_DEFAULT, "IPRTMyNewVar", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
119 CHECK_STR(szBuf, "MyValue1");
120 CHECK_RC(RTEnvSetEx(RTENV_DEFAULT, "IPRTMyNewVar", "MyValue2"), VINF_SUCCESS);
121 CHECK_RC(RTEnvGetEx(RTENV_DEFAULT, "IPRTMyNewVar", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
122 CHECK_STR(szBuf, "MyValue2");
123
124 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar", "MyValue1"), VINF_SUCCESS);
125 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
126 CHECK_STR(szBuf, "MyValue1");
127 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar", "MyValue2"), VINF_SUCCESS);
128 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
129 CHECK_STR(szBuf, "MyValue2");
130
131 CHECK_RC(RTEnvUnsetEx(Env, "IPRTMyNewVar"), VINF_SUCCESS);
132 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar", szBuf, sizeof(szBuf), &cch), VERR_ENV_VAR_NOT_FOUND);
133 CHECK_RC(RTEnvUnsetEx(Env, "IPRTMyNewVar"), VINF_ENV_VAR_NOT_FOUND);
134
135 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar0", "MyValue0"), VINF_SUCCESS);
136 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar1", "MyValue1"), VINF_SUCCESS);
137 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar2", "MyValue2"), VINF_SUCCESS);
138 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar3", "MyValue3"), VINF_SUCCESS);
139 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar4", "MyValue4"), VINF_SUCCESS);
140 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar5", "MyValue5"), VINF_SUCCESS);
141 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar6", "MyValue6"), VINF_SUCCESS);
142 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar7", "MyValue7"), VINF_SUCCESS);
143 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar8", "MyValue8"), VINF_SUCCESS);
144 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar9", "MyValue9"), VINF_SUCCESS);
145 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar10", "MyValue10"), VINF_SUCCESS);
146 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar11", "MyValue11"), VINF_SUCCESS);
147 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar12", "MyValue12"), VINF_SUCCESS);
148 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar13", "MyValue13"), VINF_SUCCESS);
149 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar14", "MyValue14"), VINF_SUCCESS);
150 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar15", "MyValue15"), VINF_SUCCESS);
151 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar16", "MyValue16"), VINF_SUCCESS);
152 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar17", "MyValue17"), VINF_SUCCESS);
153 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar18", "MyValue18"), VINF_SUCCESS);
154 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar19", "MyValue19"), VINF_SUCCESS);
155 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar20", "MyValue20"), VINF_SUCCESS);
156 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar21", "MyValue21"), VINF_SUCCESS);
157 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar22", "MyValue22"), VINF_SUCCESS);
158 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar23", "MyValue23"), VINF_SUCCESS);
159 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar24", "MyValue24"), VINF_SUCCESS);
160 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar25", "MyValue25"), VINF_SUCCESS);
161 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar26", "MyValue26"), VINF_SUCCESS);
162 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar27", "MyValue27"), VINF_SUCCESS);
163 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar28", "MyValue28"), VINF_SUCCESS);
164 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar29", "MyValue29"), VINF_SUCCESS);
165 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar30", "MyValue30"), VINF_SUCCESS);
166 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar31", "MyValue31"), VINF_SUCCESS);
167 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar32", "MyValue32"), VINF_SUCCESS);
168 CHECK_RC(RTEnvSetEx(Env, "IPRTMyNewVar33", "MyValue33"), VINF_SUCCESS);
169 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar30", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
170 CHECK_STR(szBuf, "MyValue30");
171 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar31", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
172 CHECK_STR(szBuf, "MyValue31");
173 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar32", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
174 CHECK_STR(szBuf, "MyValue32");
175 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar33", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
176 CHECK_STR(szBuf, "MyValue33");
177
178 CHECK_RC(RTEnvUnsetEx(Env, "IPRTMyNewVar33"), VINF_SUCCESS);
179 CHECK(!RTEnvExistEx(Env, "IPRTMyNewVar33"));
180 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar33", szBuf, sizeof(szBuf), &cch), VERR_ENV_VAR_NOT_FOUND);
181 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar32", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
182 CHECK_STR(szBuf, "MyValue32");
183 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar15", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
184 CHECK_STR(szBuf, "MyValue15");
185
186 CHECK_RC(RTEnvUnsetEx(Env, "IPRTMyNewVar3"), VINF_SUCCESS);
187 CHECK(!RTEnvExistEx(Env, "IPRTMyNewVar3"));
188 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar3", szBuf, sizeof(szBuf), &cch), VERR_ENV_VAR_NOT_FOUND);
189 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar32", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
190 CHECK_STR(szBuf, "MyValue32");
191 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar15", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
192 CHECK_STR(szBuf, "MyValue15");
193
194 CHECK_RC(RTEnvUnsetEx(Env, k_pszPathVar), VINF_SUCCESS);
195 CHECK(!RTEnvExistEx(Env, k_pszPathVar));
196 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar32", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
197 CHECK_STR(szBuf, "MyValue32");
198 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar15", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
199 CHECK_STR(szBuf, "MyValue15");
200
201 RTTestDisableAssertions(hTest);
202#ifdef RT_OS_WINDOWS
203 CHECK_RC(RTEnvSetEx(Env, "=C:", "C:\\Temp"), VINF_SUCCESS);
204 CHECK_RC(RTEnvGetEx(Env, "=C:", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
205 CHECK_STR(szBuf, "C:\\Temp");
206#else
207 CHECK_RC(RTEnvSetEx(Env, "=C:", "C:\\Temp"), VERR_ENV_INVALID_VAR_NAME);
208 CHECK_RC(RTEnvSetEx(Env, "=", ""), VERR_ENV_INVALID_VAR_NAME);
209#endif
210 CHECK_RC(RTEnvSetEx(Env, "", ""), VERR_ENV_INVALID_VAR_NAME);
211 RTTestRestoreAssertions(hTest);
212
213 CHECK_RC(RTEnvSetEx(hEnvEq, "=D:", "D:\\TMP"), VINF_SUCCESS);
214 CHECK_RC(RTEnvGetEx(hEnvEq, "=D:", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
215 CHECK_STR(szBuf, "D:\\TMP");
216 RTTESTI_CHECK(RTEnvExistEx(hEnvEq, "=D:") == true);
217 CHECK_RC(RTEnvUnsetEx(hEnvEq, "=D:"), VINF_SUCCESS);
218 CHECK_RC(RTEnvUnsetEx(hEnvEq, "=D:"), VINF_ENV_VAR_NOT_FOUND);
219 RTTESTI_CHECK(RTEnvExistEx(hEnvEq, "=D:") == false);
220
221 RTTestDisableAssertions(hTest);
222 CHECK_RC(RTEnvSetEx(hEnvNoEq, "=D:", "D:\\TMP"), VERR_ENV_INVALID_VAR_NAME);
223 CHECK_RC(RTEnvGetEx(hEnvNoEq, "=D:", szBuf, sizeof(szBuf), &cch), VERR_ENV_INVALID_VAR_NAME);
224 CHECK_RC(RTEnvUnsetEx(hEnvNoEq, "=D:"), VERR_ENV_INVALID_VAR_NAME);
225 RTTESTI_CHECK(RTEnvExistEx(hEnvNoEq, "=D:") == false);
226 RTTestRestoreAssertions(hTest);
227
228 /*
229 * Put.
230 */
231 RTTestSub(hTest, "RTEnvPutEx");
232 CHECK_RC(RTEnvPutEx(Env, "IPRTMyNewVar28"), VINF_SUCCESS);
233 CHECK(!RTEnvExistEx(Env, "IPRTMyNewVar28"));
234 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar32", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
235 CHECK_STR(szBuf, "MyValue32");
236 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar15", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
237 CHECK_STR(szBuf, "MyValue15");
238
239 CHECK_RC(RTEnvPutEx(Env, "IPRTMyNewVar28=MyValue28"), VINF_SUCCESS);
240 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar28", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
241 CHECK_STR(szBuf, "MyValue28");
242 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar32", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
243 CHECK_STR(szBuf, "MyValue32");
244 CHECK_RC(RTEnvGetEx(Env, "IPRTMyNewVar15", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
245 CHECK_STR(szBuf, "MyValue15");
246
247 RTTestDisableAssertions(hTest);
248#ifdef RT_OS_WINDOWS
249 CHECK_RC(RTEnvPutEx(Env, "=D:=D:\\Temp"), VINF_SUCCESS);
250 CHECK_RC(RTEnvGetEx(Env, "=D:", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
251 CHECK_STR(szBuf, "D:\\Temp");
252#else
253 CHECK_RC(RTEnvPutEx(Env, "=D:=D:\\Temp"), VERR_ENV_INVALID_VAR_NAME);
254 CHECK_RC(RTEnvPutEx(Env, "="), VERR_ENV_INVALID_VAR_NAME);
255#endif
256 CHECK_RC(RTEnvPutEx(Env, ""), VERR_ENV_INVALID_VAR_NAME);
257 RTTestRestoreAssertions(hTest);
258
259 CHECK_RC(RTEnvPutEx(hEnvEq, "=C:=C:\\"), VINF_SUCCESS);
260 CHECK_RC(RTEnvPutEx(hEnvEq, "=E:=E:\\TEMP"), VINF_SUCCESS);
261 CHECK_RC(RTEnvGetEx(hEnvEq, "=E:", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
262 CHECK_STR(szBuf, "E:\\TEMP");
263 RTTESTI_CHECK(RTEnvExistEx(hEnvEq, "=E:") == true);
264 CHECK_RC(RTEnvPutEx(hEnvEq, "=E:"), VINF_SUCCESS);
265 CHECK_RC(RTEnvPutEx(hEnvEq, "=E:"), VINF_ENV_VAR_NOT_FOUND);
266 CHECK_RC(RTEnvGetEx(hEnvEq, "=E:", szBuf, sizeof(szBuf), &cch), VERR_ENV_VAR_NOT_FOUND);
267 CHECK_RC(RTEnvGetEx(hEnvEq, "=C:", szBuf, sizeof(szBuf), &cch), VINF_SUCCESS);
268 CHECK_STR(szBuf, "C:\\");
269 CHECK_RC(RTEnvGetByIndexEx(hEnvEq, 0, szBuf2, sizeof(szBuf2), szBuf, sizeof(szBuf)), VINF_SUCCESS);
270 CHECK_STR(szBuf2, "=C:");
271 CHECK_STR(szBuf, "C:\\");
272 CHECK_RC(RTEnvGetByIndexEx(hEnvEq, 1, szBuf2, sizeof(szBuf2), szBuf, sizeof(szBuf)), VERR_ENV_VAR_NOT_FOUND);
273 RTTESTI_CHECK(RTEnvExistEx(hEnvEq, "=C:") == true);
274
275 RTTestDisableAssertions(hTest);
276 CHECK_RC(RTEnvPutEx(hEnvNoEq, "=C:=C:\\"), VERR_ENV_INVALID_VAR_NAME);
277 CHECK_RC(RTEnvPutEx(hEnvNoEq, "=E:=E:\\TEMP"), VERR_ENV_INVALID_VAR_NAME);
278 CHECK_RC(RTEnvPutEx(hEnvNoEq, "=E:"), VERR_ENV_INVALID_VAR_NAME);
279 RTTESTI_CHECK(RTEnvExistEx(hEnvNoEq, "=C:") == false);
280 RTTestRestoreAssertions(hTest);
281
282 /*
283 * Dup.
284 */
285 RTTestSub(hTest, "RTEnvDupEx");
286 char *psz1;
287 CHECK(RTEnvDupEx(Env, "NonExistantVariable") == NULL);
288 psz1 = RTEnvDupEx(Env, "IPRTMyNewVar15");
289 CHECK(psz1);
290 if (psz1)
291 CHECK_STR(psz1, "MyValue15");
292 RTStrFree(psz1);
293
294 static char s_szBigValue[10999];
295 memset(s_szBigValue, 'a', sizeof(s_szBigValue));
296 s_szBigValue[sizeof(s_szBigValue) - 1] = '\0';
297 CHECK_RC(RTEnvSetEx(Env, "IPRTBigValue", s_szBigValue), VINF_SUCCESS);
298 psz1 = RTEnvDupEx(Env, "IPRTBigValue");
299 CHECK(psz1);
300 if (psz1)
301 CHECK_STR(psz1, s_szBigValue);
302 RTStrFree(psz1);
303
304 /*
305 * Another cloning.
306 */
307 RTTestSub(hTest, "RTEnvClone");
308 RTENV Env2;
309 CHECK_RC(RTEnvClone(&Env2, Env), VINF_SUCCESS);
310 CHECK_RC(RTEnvDestroy(Env2), VINF_SUCCESS);
311
312 /*
313 * execve envp and we're done.
314 */
315#ifndef RT_OS_WINDOWS
316 RTTestSub(hTest, "RTEnvGetExecEnvP");
317 char const * const *papsz = RTEnvGetExecEnvP(RTENV_DEFAULT);
318 CHECK(papsz != NULL);
319 papsz = RTEnvGetExecEnvP(RTENV_DEFAULT);
320 CHECK(papsz != NULL);
321
322 papsz = RTEnvGetExecEnvP(Env);
323 CHECK(papsz != NULL);
324 papsz = RTEnvGetExecEnvP(Env);
325 CHECK(papsz != NULL);
326#endif
327
328 CHECK_RC(RTEnvDestroy(Env), VINF_SUCCESS);
329
330 /*
331 * Cleanups.
332 */
333 RTTESTI_CHECK_RC(RTEnvDestroy(hEnvEq), VINF_SUCCESS);
334 RTTESTI_CHECK_RC(RTEnvDestroy(hEnvNoEq), VINF_SUCCESS);
335
336 /*
337 * Summary
338 */
339 return RTTestSummaryAndDestroy(hTest);
340}
341
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette