Changeset 80878 in vbox for trunk/src/VBox/Runtime/testcase/tstRTEnv.cpp
- Timestamp:
- Sep 18, 2019 10:32:20 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTEnv.cpp
r80827 r80878 66 66 CHECK(RTEnvGet(k_pszPathVar) != NULL); 67 67 char szBuf[8192]; 68 char szBuf2[1024]; 68 69 size_t cch; 69 70 CHECK_RC(RTEnvGetEx(RTENV_DEFAULT, k_pszPathVar, NULL, 0, &cch), VINF_SUCCESS); … … 77 78 RTENV Env; 78 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); 79 84 80 85 CHECK(RTEnvExistEx(Env, k_pszPathVar)); … … 87 92 CHECK_RC(RTEnvGetEx(Env, k_pszPathVar, szBuf, 1, &cch), VERR_BUFFER_OVERFLOW); 88 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); 89 103 90 104 /* … … 187 201 RTTestRestoreAssertions(hTest); 188 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 189 218 /* 190 219 * Put. … … 218 247 RTTestRestoreAssertions(hTest); 219 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 220 272 /* 221 273 * Dup.
Note:
See TracChangeset
for help on using the changeset viewer.