Changeset 41555 in vbox
- Timestamp:
- Jun 3, 2012 10:43:15 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstErrUnique.cpp
r41296 r41555 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 31 31 #include <iprt/err.h> 32 32 #include <iprt/string.h> 33 #include <iprt/stream.h> 34 #include <iprt/initterm.h> 35 #include <VBox/err.h> 33 #include <iprt/test.h> 34 #ifdef VBOX 35 # include <VBox/err.h> 36 #endif 36 37 37 38 … … 48 49 49 50 50 static bool strIsPermissibleDuplicate(const RTSTATUSMSG * msg)51 static bool strIsPermissibleDuplicate(const RTSTATUSMSG *pMsg) 51 52 { 52 const char *pszMsgShort = msg->pszMsgShort; 53 const char *pszDefine = msg->pszDefine; 54 size_t cbDefine = strlen(pszDefine); 53 const char *pszDefine = pMsg->pszDefine; 54 size_t cchDefine = strlen(pszDefine); 55 55 56 return (strstr(pszMsgShort, "(mapped to") != 0) 57 || (strstr(pszDefine, "FIRST") == pszDefine + (cbDefine - 5)) 58 || (strstr(pszDefine, "LAST") == pszDefine + (cbDefine - 4)); 56 #define STR_ENDS_WITH(a_psz, a_cch, a_sz) \ 57 ( (a_cch) >= sizeof(a_sz) && !strncmp((a_psz) + (a_cch) - sizeof(a_sz) + 1, RT_STR_TUPLE(a_sz)) ) 58 59 return STR_ENDS_WITH(pszDefine, cchDefine, "_FIRST") 60 || STR_ENDS_WITH(pszDefine, cchDefine, "_LASTX") 61 || STR_ENDS_WITH(pszDefine, cchDefine, "_LOWEST") 62 || STR_ENDS_WITH(pszDefine, cchDefine, "_HIGHEST") 63 || strstr(pMsg->pszMsgShort, "(mapped to") != 0; 59 64 } 60 65 … … 62 67 int main() 63 68 { 64 int cErrors = 0; 65 RTR3InitExeNoArguments(0); 66 RTPrintf("tstErrUnique: TESTING\n"); 69 RTTEST hTest; 70 RTEXITCODE rcExit = RTTestInitAndCreate("tstRTErrUnique", &hTest); 71 if (rcExit != RTEXITCODE_SUCCESS) 72 return rcExit; 73 RTTestBanner(hTest); 67 74 75 RTTestSub(hTest, "IPRT status code"); 68 76 for (uint32_t i = 0; i < RT_ELEMENTS(g_aErrorMessages) - 1; i++) 69 { 70 if (strIsPermissibleDuplicate(&g_aErrorMessages[i])) 71 continue; 77 if (!strIsPermissibleDuplicate(&g_aErrorMessages[i])) 78 for (uint32_t j = i + 1; j < RT_ELEMENTS(g_aErrorMessages); j++) 79 if ( !strIsPermissibleDuplicate(&g_aErrorMessages[j]) 80 && g_aErrorMessages[i].iCode == g_aErrorMessages[j].iCode) 81 RTTestFailed(hTest, "Status code %d can mean both '%s' and '%s'", 82 g_aErrorMessages[i].iCode, 83 g_aErrorMessages[i].pszDefine, 84 g_aErrorMessages[j].pszDefine); 72 85 73 for (uint32_t j = i + 1; j < RT_ELEMENTS(g_aErrorMessages); j++) 74 { 75 if (strIsPermissibleDuplicate(&g_aErrorMessages[j])) 76 continue; 77 78 if (g_aErrorMessages[i].iCode == g_aErrorMessages[j].iCode) 79 { 80 RTPrintf("tstErrUnique: status code %d\n can mean '%s'\n or '%s'\n", g_aErrorMessages[i].iCode, g_aErrorMessages[i].pszMsgShort, g_aErrorMessages[j].pszMsgShort); 81 cErrors++; 82 } 83 } 84 } 85 86 /* 87 * Summary 88 */ 89 if (cErrors == 0) 90 RTPrintf("tstErrUnique: SUCCESS\n"); 91 else 92 RTPrintf("tstErrUnique: FAILURE - %d errors\n", cErrors); 93 return !!cErrors; 86 return RTTestSummaryAndDestroy(hTest); 94 87 } 95 88
Note:
See TracChangeset
for help on using the changeset viewer.