VirtualBox

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

Last change on this file since 90918 was 86379, checked in by vboxsync, 4 years ago

IPRT/tstRTEnv: cleanup leak. bugref:9841

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