Index: trunk/src/VBox/Runtime/testcase/tstRTProcCreateEx.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstRTProcCreateEx.cpp	(revision 42972)
+++ trunk/src/VBox/Runtime/testcase/tstRTProcCreateEx.cpp	(revision 42973)
@@ -68,4 +68,13 @@
     /* 8 */ "\\\"\\",
     /* 9 */ "\\\\\"\\",
+    /*10 */ "%TEMP%",
+    /*11 */ "%TEMP%\filename",
+    /*12 */ "%TEMP%postfix",
+    /*13 */ "Prefix%TEMP%postfix",
+    /*14 */ "%",
+    /*15 */ "%%",
+    /*16 */ "%%%",
+    /*17 */ "%X",
+    /*18 */ "%%X",
     NULL
 };
@@ -75,5 +84,5 @@
 {
     int rc = RTR3InitExeNoArguments(0);
-    if (rc)
+    if (RT_FAILURE(rc))
         return RTMsgInitFailure(rc);
 
@@ -85,56 +94,52 @@
     {
         RTPrintf("GetUserName failed with last error=%ld\n", GetLastError());
-        return VERR_AUTHENTICATION_FAILURE;
-    }
-    else
-    {
-/* Does not work on NT4 (yet). */
-#if 0
-        DWORD cbSid = 0;
-        DWORD cbDomain = 0;
-        SID_NAME_USE sidUse;
-        /* First try to figure out how much space for SID + domain name we need. */
-        BOOL bRet = LookupAccountName(NULL /* current system*/,
-                                      szUser,
-                                      NULL,
-                                      &cbSid,
-                                      NULL,
-                                      &cbDomain,
-                                      &sidUse);
-        if (!bRet)
+        return RTEXITCODE_FAILURE;
+    }
+# if 0 /* Does not work on NT4 (yet). */
+    DWORD cbSid = 0;
+    DWORD cbDomain = 0;
+    SID_NAME_USE sidUse;
+    /* First try to figure out how much space for SID + domain name we need. */
+    BOOL bRet = LookupAccountName(NULL /* current system*/,
+                                  szUser,
+                                  NULL,
+                                  &cbSid,
+                                  NULL,
+                                  &cbDomain,
+                                  &sidUse);
+    if (!bRet)
+    {
+        DWORD dwErr = GetLastError();
+        if (dwErr != ERROR_INSUFFICIENT_BUFFER)
         {
-            DWORD dwErr = GetLastError();
-            if (dwErr != ERROR_INSUFFICIENT_BUFFER)
-            {
-                RTPrintf("LookupAccountName(1) failed with last error=%ld\n", dwErr);
-                return VERR_AUTHENTICATION_FAILURE;
-            }
+            RTPrintf("LookupAccountName(1) failed with last error=%ld\n", dwErr);
+            return RTEXITCODE_FAILURE;
         }
-
-        /* Now try getting the real SID + domain name. */
-        SID *pSid = (SID *)RTMemAlloc(cbSid);
-        AssertPtr(pSid);
-        char *pszDomain = (char *)RTMemAlloc(cbDomain); /* Size in TCHAR! */
-        AssertPtr(pszDomain);
-
-        if (!LookupAccountName(NULL /* Current system */,
-                               szUser,
-                               pSid,
-                               &cbSid,
-                               pszDomain,
-                               &cbDomain,
-                               &sidUse))
-        {
-            RTPrintf("LookupAccountName(2) failed with last error=%ld\n", GetLastError());
-            return VERR_AUTHENTICATION_FAILURE;
-        }
-        RTMemFree(pSid);
-        RTMemFree(pszDomain);
-#endif
-    }
+    }
+
+    /* Now try getting the real SID + domain name. */
+    SID *pSid = (SID *)RTMemAlloc(cbSid);
+    AssertPtr(pSid);
+    char *pszDomain = (char *)RTMemAlloc(cbDomain); /* Size in TCHAR! */
+    AssertPtr(pszDomain);
+
+    if (!LookupAccountName(NULL /* Current system */,
+                           szUser,
+                           pSid,
+                           &cbSid,
+                           pszDomain,
+                           &cbDomain,
+                           &sidUse))
+    {
+        RTPrintf("LookupAccountName(2) failed with last error=%ld\n", GetLastError());
+        return RTEXITCODE_FAILURE;
+    }
+    RTMemFree(pSid);
+    RTMemFree(pszDomain);
+# endif
 #else
     /** @todo Lookup UID/effective UID, maybe GID? */
 #endif
-    return rc;
+    return RTEXITCODE_SUCCESS;
 }
 
@@ -174,7 +179,8 @@
 {
     int rc = RTR3InitExeNoArguments(0);
-    if (rc)
+    if (RT_FAILURE(rc))
         return RTMsgInitFailure(rc);
 
+    int cErrors = 0;
     for (int i = 0; i < argc; i++)
         if (strcmp(argv[i], g_apszArgs4[i]))
@@ -184,10 +190,11 @@
                          "child4: expected='%s'\n",
                          i, argv[i], g_apszArgs4[i]);
-            rc++;
+            cErrors++;
         }
-    return rc;
-}
-
-static void tstRTCreateProcEx4(void)
+
+    return cErrors == 0 ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
+}
+
+static void tstRTCreateProcEx4(const char *pszAsUser, const char *pszPassword)
 {
     RTTestISub("Argument with spaces and stuff");
@@ -195,5 +202,5 @@
     RTPROCESS hProc;
     RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, g_apszArgs4, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
-                                         NULL, NULL, NULL, NULL, &hProc), VINF_SUCCESS);
+                                         NULL, NULL, pszAsUser, pszPassword, &hProc), VINF_SUCCESS);
     RTPROCSTATUS ProcStatus = { -1, RTPROCEXITREASON_ABEND };
     RTTESTI_CHECK_RC(RTProcWait(hProc, RTPROCWAIT_FLAGS_BLOCK, &ProcStatus), VINF_SUCCESS);
@@ -209,5 +216,5 @@
 {
     int rc = RTR3InitExeNoArguments(0);
-    if (rc)
+    if (RT_FAILURE(rc))
         return RTMsgInitFailure(rc);
 
@@ -218,8 +225,8 @@
     RTStrmPrintf(g_pStdOut, "s");
 
-    return 0;
-}
-
-static void tstRTCreateProcEx3(void)
+    return RTEXITCODE_SUCCESS;
+}
+
+static void tstRTCreateProcEx3(const char *pszAsUser, const char *pszPassword)
 {
     RTTestISub("Standard Out+Err");
@@ -238,5 +245,5 @@
     RTPROCESS hProc;
     RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
-                                         &Handle, &Handle, NULL, NULL, &hProc), VINF_SUCCESS);
+                                         &Handle, &Handle, pszAsUser, pszPassword, &hProc), VINF_SUCCESS);
     RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
 
@@ -279,5 +286,5 @@
 {
     int rc = RTR3InitExeNoArguments(0);
-    if (rc)
+    if (RT_FAILURE(rc))
         return RTMsgInitFailure(rc);
 
@@ -285,8 +292,8 @@
     RTStrmPrintf(g_pStdOut, "ignore this output\n");
 
-    return 0;
-}
-
-static void tstRTCreateProcEx2(void)
+    return RTEXITCODE_SUCCESS;
+}
+
+static void tstRTCreateProcEx2(const char *pszAsUser, const char *pszPassword)
 {
     RTTestISub("Standard Err");
@@ -305,5 +312,5 @@
     RTPROCESS hProc;
     RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
-                                         NULL, &Handle, NULL, NULL, &hProc), VINF_SUCCESS);
+                                         NULL, &Handle, pszAsUser, pszPassword, &hProc), VINF_SUCCESS);
     RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
 
@@ -346,13 +353,15 @@
 {
     int rc = RTR3InitExeNoArguments(0);
-    if (rc)
+    if (RT_FAILURE(rc))
         return RTMsgInitFailure(rc);
+
     RTPrintf("it works");
     RTStrmPrintf(g_pStdErr, "ignore this output\n");
-    return 0;
-}
-
-
-static void tstRTCreateProcEx1(void)
+
+    return RTEXITCODE_SUCCESS;
+}
+
+
+static void tstRTCreateProcEx1(const char *pszAsUser, const char *pszPassword)
 {
     RTTestISub("Standard Out");
@@ -371,5 +380,5 @@
     RTPROCESS hProc;
     RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
-                                         &Handle, NULL, NULL, NULL, &hProc), VINF_SUCCESS);
+                                         &Handle, NULL, pszAsUser, pszPassword, &hProc), VINF_SUCCESS);
     RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
 
@@ -442,8 +451,8 @@
      * The tests.
      */
-    tstRTCreateProcEx1();
-    tstRTCreateProcEx2();
-    tstRTCreateProcEx3();
-    tstRTCreateProcEx4();
+    tstRTCreateProcEx1(pszAsUser, pszPassword);
+    tstRTCreateProcEx2(pszAsUser, pszPassword);
+    tstRTCreateProcEx3(pszAsUser, pszPassword);
+    tstRTCreateProcEx4(pszAsUser, pszPassword);
     if (pszAsUser)
         tstRTCreateProcEx5(pszAsUser, pszPassword);
