Changeset 42973 in vbox for trunk/src/VBox
- Timestamp:
- Aug 24, 2012 12:30:32 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTProcCreateEx.cpp
r39835 r42973 68 68 /* 8 */ "\\\"\\", 69 69 /* 9 */ "\\\\\"\\", 70 /*10 */ "%TEMP%", 71 /*11 */ "%TEMP%\filename", 72 /*12 */ "%TEMP%postfix", 73 /*13 */ "Prefix%TEMP%postfix", 74 /*14 */ "%", 75 /*15 */ "%%", 76 /*16 */ "%%%", 77 /*17 */ "%X", 78 /*18 */ "%%X", 70 79 NULL 71 80 }; … … 75 84 { 76 85 int rc = RTR3InitExeNoArguments(0); 77 if ( rc)86 if (RT_FAILURE(rc)) 78 87 return RTMsgInitFailure(rc); 79 88 … … 85 94 { 86 95 RTPrintf("GetUserName failed with last error=%ld\n", GetLastError()); 87 return VERR_AUTHENTICATION_FAILURE;88 } 89 else 90 {91 /* Does not work on NT4 (yet). */ 92 #if 0 93 DWORD cbSid = 0;94 DWORD cbDomain = 0;95 SID_NAME_USE sidUse;96 /* First try to figure out how much space for SID + domain name we need. */97 BOOL bRet = LookupAccountName(NULL /* current system*/,98 szUser,99 NULL,100 &cbSid,101 NULL,102 &cbDomain,103 &sidUse);104 if ( !bRet)96 return RTEXITCODE_FAILURE; 97 } 98 # if 0 /* Does not work on NT4 (yet). */ 99 DWORD cbSid = 0; 100 DWORD cbDomain = 0; 101 SID_NAME_USE sidUse; 102 /* First try to figure out how much space for SID + domain name we need. */ 103 BOOL bRet = LookupAccountName(NULL /* current system*/, 104 szUser, 105 NULL, 106 &cbSid, 107 NULL, 108 &cbDomain, 109 &sidUse); 110 if (!bRet) 111 { 112 DWORD dwErr = GetLastError(); 113 if (dwErr != ERROR_INSUFFICIENT_BUFFER) 105 114 { 106 DWORD dwErr = GetLastError(); 107 if (dwErr != ERROR_INSUFFICIENT_BUFFER) 108 { 109 RTPrintf("LookupAccountName(1) failed with last error=%ld\n", dwErr); 110 return VERR_AUTHENTICATION_FAILURE; 111 } 115 RTPrintf("LookupAccountName(1) failed with last error=%ld\n", dwErr); 116 return RTEXITCODE_FAILURE; 112 117 } 113 114 /* Now try getting the real SID + domain name. */ 115 SID *pSid = (SID *)RTMemAlloc(cbSid);116 AssertPtr(pSid);117 char *pszDomain = (char *)RTMemAlloc(cbDomain); /* Size in TCHAR! */118 AssertPtr(pszDomain);119 120 if (!LookupAccountName(NULL /* Current system */, 121 szUser,122 pSid,123 &cbSid,124 pszDomain,125 &cbDomain,126 &sidUse))127 {128 RTPrintf("LookupAccountName(2) failed with last error=%ld\n", GetLastError());129 return VERR_AUTHENTICATION_FAILURE;130 }131 RTMemFree(pSid);132 RTMemFree(pszDomain);133 #endif 134 } 118 } 119 120 /* Now try getting the real SID + domain name. */ 121 SID *pSid = (SID *)RTMemAlloc(cbSid); 122 AssertPtr(pSid); 123 char *pszDomain = (char *)RTMemAlloc(cbDomain); /* Size in TCHAR! */ 124 AssertPtr(pszDomain); 125 126 if (!LookupAccountName(NULL /* Current system */, 127 szUser, 128 pSid, 129 &cbSid, 130 pszDomain, 131 &cbDomain, 132 &sidUse)) 133 { 134 RTPrintf("LookupAccountName(2) failed with last error=%ld\n", GetLastError()); 135 return RTEXITCODE_FAILURE; 136 } 137 RTMemFree(pSid); 138 RTMemFree(pszDomain); 139 # endif 135 140 #else 136 141 /** @todo Lookup UID/effective UID, maybe GID? */ 137 142 #endif 138 return rc;143 return RTEXITCODE_SUCCESS; 139 144 } 140 145 … … 174 179 { 175 180 int rc = RTR3InitExeNoArguments(0); 176 if ( rc)181 if (RT_FAILURE(rc)) 177 182 return RTMsgInitFailure(rc); 178 183 184 int cErrors = 0; 179 185 for (int i = 0; i < argc; i++) 180 186 if (strcmp(argv[i], g_apszArgs4[i])) … … 184 190 "child4: expected='%s'\n", 185 191 i, argv[i], g_apszArgs4[i]); 186 rc++;192 cErrors++; 187 193 } 188 return rc; 189 } 190 191 static void tstRTCreateProcEx4(void) 194 195 return cErrors == 0 ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 196 } 197 198 static void tstRTCreateProcEx4(const char *pszAsUser, const char *pszPassword) 192 199 { 193 200 RTTestISub("Argument with spaces and stuff"); … … 195 202 RTPROCESS hProc; 196 203 RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, g_apszArgs4, RTENV_DEFAULT, 0 /*fFlags*/, NULL, 197 NULL, NULL, NULL, NULL, &hProc), VINF_SUCCESS);204 NULL, NULL, pszAsUser, pszPassword, &hProc), VINF_SUCCESS); 198 205 RTPROCSTATUS ProcStatus = { -1, RTPROCEXITREASON_ABEND }; 199 206 RTTESTI_CHECK_RC(RTProcWait(hProc, RTPROCWAIT_FLAGS_BLOCK, &ProcStatus), VINF_SUCCESS); … … 209 216 { 210 217 int rc = RTR3InitExeNoArguments(0); 211 if ( rc)218 if (RT_FAILURE(rc)) 212 219 return RTMsgInitFailure(rc); 213 220 … … 218 225 RTStrmPrintf(g_pStdOut, "s"); 219 226 220 return 0;221 } 222 223 static void tstRTCreateProcEx3( void)227 return RTEXITCODE_SUCCESS; 228 } 229 230 static void tstRTCreateProcEx3(const char *pszAsUser, const char *pszPassword) 224 231 { 225 232 RTTestISub("Standard Out+Err"); … … 238 245 RTPROCESS hProc; 239 246 RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL, 240 &Handle, &Handle, NULL, NULL, &hProc), VINF_SUCCESS);247 &Handle, &Handle, pszAsUser, pszPassword, &hProc), VINF_SUCCESS); 241 248 RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS); 242 249 … … 279 286 { 280 287 int rc = RTR3InitExeNoArguments(0); 281 if ( rc)288 if (RT_FAILURE(rc)) 282 289 return RTMsgInitFailure(rc); 283 290 … … 285 292 RTStrmPrintf(g_pStdOut, "ignore this output\n"); 286 293 287 return 0;288 } 289 290 static void tstRTCreateProcEx2( void)294 return RTEXITCODE_SUCCESS; 295 } 296 297 static void tstRTCreateProcEx2(const char *pszAsUser, const char *pszPassword) 291 298 { 292 299 RTTestISub("Standard Err"); … … 305 312 RTPROCESS hProc; 306 313 RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL, 307 NULL, &Handle, NULL, NULL, &hProc), VINF_SUCCESS);314 NULL, &Handle, pszAsUser, pszPassword, &hProc), VINF_SUCCESS); 308 315 RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS); 309 316 … … 346 353 { 347 354 int rc = RTR3InitExeNoArguments(0); 348 if ( rc)355 if (RT_FAILURE(rc)) 349 356 return RTMsgInitFailure(rc); 357 350 358 RTPrintf("it works"); 351 359 RTStrmPrintf(g_pStdErr, "ignore this output\n"); 352 return 0; 353 } 354 355 356 static void tstRTCreateProcEx1(void) 360 361 return RTEXITCODE_SUCCESS; 362 } 363 364 365 static void tstRTCreateProcEx1(const char *pszAsUser, const char *pszPassword) 357 366 { 358 367 RTTestISub("Standard Out"); … … 371 380 RTPROCESS hProc; 372 381 RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL, 373 &Handle, NULL, NULL, NULL, &hProc), VINF_SUCCESS);382 &Handle, NULL, pszAsUser, pszPassword, &hProc), VINF_SUCCESS); 374 383 RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS); 375 384 … … 442 451 * The tests. 443 452 */ 444 tstRTCreateProcEx1( );445 tstRTCreateProcEx2( );446 tstRTCreateProcEx3( );447 tstRTCreateProcEx4( );453 tstRTCreateProcEx1(pszAsUser, pszPassword); 454 tstRTCreateProcEx2(pszAsUser, pszPassword); 455 tstRTCreateProcEx3(pszAsUser, pszPassword); 456 tstRTCreateProcEx4(pszAsUser, pszPassword); 448 457 if (pszAsUser) 449 458 tstRTCreateProcEx5(pszAsUser, pszPassword);
Note:
See TracChangeset
for help on using the changeset viewer.