Changeset 26608 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Feb 17, 2010 12:48:33 PM (15 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 1 added
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r26600 r26608 471 471 generic/RTFileMove-generic.cpp \ 472 472 generic/RTLogWriteDebugger-generic.cpp \ 473 generic/RTSystemQueryDmiString-generic.cpp \474 473 generic/RTTimeLocalNow-generic.cpp \ 475 474 generic/RTTimerCreate-generic.cpp \ … … 485 484 r3/linux/time-linux.cpp \ 486 485 r3/linux/RTProcIsRunningByName-linux.cpp \ 486 r3/linux/RTSystemQueryDmiString-linux.cpp \ 487 487 r3/posix/RTFileQueryFsSizes-posix.cpp \ 488 488 r3/posix/RTSystemQueryOSInfo-posix.cpp \ -
trunk/src/VBox/Runtime/generic/RTSystemQueryDmiString-generic.cpp
r26600 r26608 42 42 RTDECL(int) RTSystemQueryDmiString(RTSYSDMISTR enmString, char *pszBuf, size_t cbBuf) 43 43 { 44 AssertReturn(enmString > RTSYSDMISTR_INVALID && enmString < RTSYSDMISTR_END, VERR_INVALID_PARAMETER);45 44 AssertPtrReturn(pszBuf, VERR_INVALID_POINTER); 46 45 AssertReturn(cbBuf > 0, VERR_INVALID_PARAMETER); 46 *pszBuf = '\0'; 47 AssertReturn(enmString > RTSYSDMISTR_INVALID && enmString < RTSYSDMISTR_END, VERR_INVALID_PARAMETER); 47 48 return VERR_NOT_SUPPORTED; 48 49 } -
trunk/src/VBox/Runtime/r3/linux/sysfs.cpp
r26253 r26608 208 208 pszBuf[cchRead >= 0 ? cchRead : 0] = '\0'; 209 209 return cchRead; 210 } 211 212 213 RTDECL(int) RTLinuxSysFsReadFile(int fd, void *pvBuf, size_t cbBuf, size_t *pcbRead) 214 { 215 int rc; 216 ssize_t cbRead = read(fd, pvBuf, cbBuf); 217 if (cbRead >= 0) 218 { 219 if (pcbRead) 220 *pcbRead = cbRead; 221 if ((size_t)cbRead < cbBuf) 222 rc = VINF_SUCCESS; 223 else 224 { 225 /* Check for EOF */ 226 char ch; 227 off_t off = lseek(fd, 0, SEEK_CUR); 228 ssize_t cbRead2 = read(fd, &ch, 1); 229 if (cbRead2 == 0) 230 rc = VINF_SUCCESS; 231 else if (cbRead2 > 0) 232 { 233 lseek(fd, off, SEEK_SET); 234 rc = VERR_BUFFER_OVERFLOW; 235 } 236 else 237 rc = RTErrConvertFromErrno(errno); 238 } 239 } 240 else 241 rc = RTErrConvertFromErrno(errno); 242 return rc; 210 243 } 211 244 -
trunk/src/VBox/Runtime/testcase/Makefile.kmk
r26605 r26608 104 104 tstStrToNum \ 105 105 tstRTStrVersion \ 106 tstRTSystemQueryDmi \ 106 107 tstRTSystemQueryOsInfo \ 107 108 tstRTTemp \ … … 408 409 tstRTStrVersion_SOURCES = tstRTStrVersion.cpp 409 410 411 tstRTSystemQueryDmi_TEMPLATE = VBOXR3TSTEXE 412 tstRTSystemQueryDmi_SOURCES = tstRTSystemQueryDmi.cpp 413 410 414 tstRTSystemQueryOsInfo_TEMPLATE = VBOXR3TSTEXE 411 415 tstRTSystemQueryOsInfo_SOURCES = tstRTSystemQueryOsInfo.cpp -
trunk/src/VBox/Runtime/testcase/tstRTSystemQueryDmi.cpp
r26605 r26608 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT Testcase - RTSystemQuery OSInfo.3 * IPRT Testcase - RTSystemQueryDmi*. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 33 33 *******************************************************************************/ 34 34 #include <iprt/system.h> 35 36 #include <iprt/assert.h> 35 37 #include <iprt/string.h> 36 38 #include <iprt/test.h> 37 38 39 /*******************************************************************************40 * Global Variables *41 *******************************************************************************/42 static int g_cErrors = 0;43 39 44 40 … … 46 42 { 47 43 RTTEST hTest; 48 int rc = RTTestInitAndCreate("tstRTSystemQuery OsInfo", &hTest);44 int rc = RTTestInitAndCreate("tstRTSystemQueryDmi", &hTest); 49 45 if (rc) 50 46 return rc; … … 56 52 char szInfo[256]; 57 53 58 rc = RTSystemQuery OSInfo(RTSYSOSINFO_PRODUCT, szInfo, sizeof(szInfo));59 RTTestIPrintf(RTTESTLVL_ALWAYS, "PRODUCT : \"%s\", rc=%Rrc\n", szInfo, rc);54 rc = RTSystemQueryDmiString(RTSYSDMISTR_PRODUCT_NAME, szInfo, sizeof(szInfo)); 55 RTTestIPrintf(RTTESTLVL_ALWAYS, "PRODUCT_NAME: \"%s\", rc=%Rrc\n", szInfo, rc); 60 56 61 rc = RTSystemQuery OSInfo(RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));62 RTTestIPrintf(RTTESTLVL_ALWAYS, " RELEASE: \"%s\", rc=%Rrc\n", szInfo, rc);57 rc = RTSystemQueryDmiString(RTSYSDMISTR_PRODUCT_VERSION, szInfo, sizeof(szInfo)); 58 RTTestIPrintf(RTTESTLVL_ALWAYS, "PRODUCT_VERSION: \"%s\", rc=%Rrc\n", szInfo, rc); 63 59 64 rc = RTSystemQuery OSInfo(RTSYSOSINFO_VERSION, szInfo, sizeof(szInfo));65 RTTestIPrintf(RTTESTLVL_ALWAYS, " VERSION: \"%s\", rc=%Rrc\n", szInfo, rc);60 rc = RTSystemQueryDmiString(RTSYSDMISTR_PRODUCT_UUID, szInfo, sizeof(szInfo)); 61 RTTestIPrintf(RTTESTLVL_ALWAYS, "PRODUCT_UUID: \"%s\", rc=%Rrc\n", szInfo, rc); 66 62 67 rc = RTSystemQuery OSInfo(RTSYSOSINFO_SERVICE_PACK, szInfo, sizeof(szInfo));68 RTTestIPrintf(RTTESTLVL_ALWAYS, " SERVICE_PACK: \"%s\", rc=%Rrc\n", szInfo, rc);63 rc = RTSystemQueryDmiString(RTSYSDMISTR_PRODUCT_SERIAL, szInfo, sizeof(szInfo)); 64 RTTestIPrintf(RTTESTLVL_ALWAYS, "PRODUCT_SERIAL: \"%s\", rc=%Rrc\n", szInfo, rc); 69 65 70 66 /* 71 67 * Check that unsupported stuff is terminated correctly. 72 68 */ 73 for (int i = RTSYS OSINFO_INVALID + 1; i < RTSYSOSINFO_END; i++)69 for (int i = RTSYSDMISTR_INVALID + 1; i < RTSYSDMISTR_END; i++) 74 70 { 75 71 memset(szInfo, ' ', sizeof(szInfo)); 76 rc = RTSystemQuery OSInfo((RTSYSOSINFO)i, szInfo, sizeof(szInfo));72 rc = RTSystemQueryDmiString((RTSYSDMISTR)i, szInfo, sizeof(szInfo)); 77 73 if ( rc == VERR_NOT_SUPPORTED 78 74 && szInfo[0] != '\0') 79 75 RTTestIFailed("level=%d; unterminated buffer on VERR_NOT_SUPPORTED\n", i); 80 else if (RT_SUCCESS(rc) || rc == VERR_BUFFER_OVERFLOW )76 else if (RT_SUCCESS(rc) || rc == VERR_BUFFER_OVERFLOW || rc == VERR_ACCESS_DENIED) 81 77 RTTESTI_CHECK(memchr(szInfo, '\0', sizeof(szInfo)) != NULL); 82 78 else if (rc != VERR_NOT_SUPPORTED) … … 87 83 * Check buffer overflow 88 84 */ 89 for (int i = RTSYSOSINFO_INVALID + 1; i < RTSYSOSINFO_END; i++) 85 RTAssertSetQuiet(true); 86 RTAssertSetMayPanic(false); 87 for (int i = RTSYSDMISTR_INVALID + 1; i < RTSYSDMISTR_END; i++) 90 88 { 91 89 rc = VERR_BUFFER_OVERFLOW; … … 93 91 { 94 92 memset(szInfo, 0x7f, sizeof(szInfo)); 95 rc = RTSystemQuery OSInfo((RTSYSOSINFO)i, szInfo, cch);93 rc = RTSystemQueryDmiString((RTSYSDMISTR)i, szInfo, cch); 96 94 97 95 /* check the padding. */ … … 109 107 && cch > 0 110 108 && !memchr(szInfo, '\0', cch)) 111 {112 113 109 RTTestIFailed("level=%d, rc=%Rrc, cch=%zu: Buffer not terminated!\n", i, rc, cch); 114 g_cErrors++;115 }116 110 } 117 111 }
Note:
See TracChangeset
for help on using the changeset viewer.