Changeset 57916 in vbox for trunk/src/VBox/Runtime/testcase
- Timestamp:
- Sep 27, 2015 8:36:38 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTProcQueryUsername.cpp
r57358 r57916 35 35 #include <iprt/test.h> 36 36 37 37 38 static void tstRTProcQueryUsername(void) 38 39 { 39 char abUser[1024];40 size_t cbUser;41 char *pszUser = NULL;42 43 40 RTTestISub("Basics"); 44 41 45 memset(abUser, 0, sizeof(abUser)); 42 size_t cbUser; 43 char szUser[1024]; 44 memset(szUser, '-', sizeof(szUser)); 45 46 /* negative stuff that may assert: */ 47 bool fMayPanic = RTAssertSetMayPanic(false); 48 bool fQuiet = RTAssertSetQuiet(true); 49 46 50 RTTESTI_CHECK_RC(RTProcQueryUsername(RTProcSelf(), NULL, 8, &cbUser), VERR_INVALID_PARAMETER); 47 RTTESTI_CHECK_RC(RTProcQueryUsername(RTProcSelf(), abUser, 0, &cbUser), VERR_INVALID_PARAMETER); 48 RTTESTI_CHECK_RC(RTProcQueryUsername(RTProcSelf(), NULL, 0, NULL), VERR_BUFFER_OVERFLOW); 51 RTTESTI_CHECK_RC(RTProcQueryUsername(RTProcSelf(), szUser, 0, &cbUser), VERR_INVALID_PARAMETER); 52 RTTESTI_CHECK_RC(RTProcQueryUsername(RTProcSelf(), NULL, 0, NULL), VERR_INVALID_PARAMETER); 53 RTTESTI_CHECK_RC(RTProcQueryUsernameA(RTProcSelf(), NULL), VERR_INVALID_POINTER); 54 55 RTAssertSetMayPanic(fMayPanic); 56 RTAssertSetQuiet(fQuiet); 57 49 58 RTTESTI_CHECK_RC(RTProcQueryUsername(RTProcSelf(), NULL, 0, &cbUser), VERR_BUFFER_OVERFLOW); 59 memset(szUser, '-', sizeof(szUser)); 60 RTTESTI_CHECK_RC(RTProcQueryUsername(RTProcSelf(), szUser, cbUser - 1, &cbUser), VERR_BUFFER_OVERFLOW); 61 memset(szUser, '-', sizeof(szUser)); 62 RTTESTI_CHECK_RC(RTProcQueryUsername(RTProcSelf(), szUser, sizeof(szUser), &cbUser), VINF_SUCCESS); 63 RTTestPrintf(NULL, RTTESTLVL_ALWAYS, "Username: %s\n", szUser); /* */ 50 64 51 RTTESTI_CHECK_RC(RTProcQueryUsername(RTProcSelf(), abUser, sizeof(abUser), &cbUser), VINF_SUCCESS); 52 RTTestPrintf(NULL, RTTESTLVL_ALWAYS, "Username: %s\n", abUser); 53 RTTESTI_CHECK_RC(RTProcQueryUsername(RTProcSelf(), abUser, cbUser - 1, &cbUser), VERR_BUFFER_OVERFLOW); 54 55 RTTESTI_CHECK_RC(RTProcQueryUsernameA(RTProcSelf(), NULL), VERR_INVALID_POINTER); 65 char *pszUser = NULL; 56 66 RTTESTI_CHECK_RC(RTProcQueryUsernameA(RTProcSelf(), &pszUser), VINF_SUCCESS); 57 67 RTTestPrintf(NULL, RTTESTLVL_ALWAYS, "Username: %s\n", pszUser); 68 RTTESTI_CHECK(strcmp(pszUser, szUser) == 0); 58 69 RTStrFree(pszUser); 59 70 } 71 60 72 61 73 int main(int argc, char **argv)
Note:
See TracChangeset
for help on using the changeset viewer.