Changeset 10793 in vbox
- Timestamp:
- Jul 21, 2008 10:33:15 PM (17 years ago)
- Location:
- trunk/src/VBox/Runtime/testcase
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/Makefile.kmk
r10788 r10793 80 80 tstStrFormat \ 81 81 tstStrToNum \ 82 tstThread-1 \ 82 83 tstTime \ 83 84 tstTime-2 \ … … 281 282 tstStrToNum_SOURCES = tstStrToNum.cpp 282 283 284 tstThread-1_SOURCES = tstThread-1.cpp 285 283 286 tstTime_SOURCES = tstTime.cpp 284 287 -
trunk/src/VBox/Runtime/testcase/tstThread-1.cpp
r10791 r10793 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT Testcase - Native Loader.3 * IPRT Testcase - Thread Testcase no.1. 4 4 */ 5 5 … … 30 30 31 31 32 #include <iprt/ldr.h> 32 /******************************************************************************* 33 * Header Files * 34 *******************************************************************************/ 35 #include <iprt/thread.h> 33 36 #include <iprt/stream.h> 34 #include <iprt/ runtime.h>37 #include <iprt/initterm.h> 35 38 #include <iprt/err.h> 39 40 /******************************************************************************* 41 * Global Variables * 42 *******************************************************************************/ 43 static unsigned volatile g_cErrors = 0; 44 45 46 static DECLCALLBACK(int) tstThread1ReturnImmediately(RTTHREAD Thread, void *pvUser) 47 { 48 NOREF(pvUser); 49 return VINF_SUCCESS; 50 } 51 52 36 53 37 54 int main(int argc, const char * const *argv) 38 55 { 39 int rcRet = 0; 40 RTR3Init(); 56 RTR3Init(false, 0); 41 57 42 58 /* 43 * If no args, display usage.59 * A simple testcase for the termination race we used to have. 44 60 */ 45 if (argc <= 1) 61 RTTHREAD ahThreads[128]; 62 RTPrintf("tstThread-1: TESTING - %u waitable immediate return threads\n", RT_ELEMENTS(ahThreads)); 63 for (unsigned j = 0; j < 10; j++) 46 64 { 47 RTPrintf("Syntax: %s [so/dll [so/dll [..]]\n", argv[0]); 48 return 1; 49 } 50 51 /* 52 * Iterate the arguments and treat all of them as so/dll paths. 53 */ 54 for (int i = 1; i < argc; i++) 55 { 56 RTLDRMOD hLdrMod = (RTLDRMOD)0xbaadffaa; 57 int rc = RTLdrLoad(argv[i], &hLdrMod); 58 if (RT_SUCCESS(rc)) 65 RTPrintf("tstThread-1: Iteration %u...\n", j); 66 for (unsigned i = 0; i < RT_ELEMENTS(ahThreads); i++) 59 67 { 60 RTPrintf("tstLdrLoad: %d - %s\n", i, argv[i]); 61 rc = RTLdrClose(hLdrMod); 68 int rc = RTThreadCreate(&ahThreads[i], tstThread1ReturnImmediately, &ahThreads[i], 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "TEST1"); 62 69 if (RT_FAILURE(rc)) 63 70 { 64 RTPrintf("tstLdrLoad: rc=%Rrc RTLdrClose()\n", rc); 65 rcRet++; 71 RTPrintf("tstThread-1: FAILURE(%d) - %d/%d RTThreadCreate failed, rc=%Rrc\n", __LINE__, i, j, rc); 72 g_cErrors++; 73 ahThreads[i] = NIL_RTTHREAD; 66 74 } 67 75 } 68 else 69 { 70 RTPrintf("tstLdrLoad: rc=%Rrc RTLdrOpen('%s')\n", rc, argv[i]); 71 rcRet++; 72 } 76 77 /* 78 * Wait for the threads to complete. 79 */ 80 for (unsigned i = 0; i < RT_ELEMENTS(ahThreads); i++) 81 if (ahThreads[i] != NIL_RTTHREAD) 82 { 83 int rc2; 84 int rc = RTThreadWait(ahThreads[i], RT_INDEFINITE_WAIT, &rc2); 85 if (RT_FAILURE(rc)) 86 { 87 RTPrintf("tstThread-1: FAILURE(%d) - %d/%d RTThreadWait failed, rc=%Rrc\n", __LINE__, j, i, rc); 88 g_cErrors++; 89 } 90 else if (RT_FAILURE(rc2)) 91 { 92 RTPrintf("tstThread-1: FAILURE(%d) - %d/%d Thread failed, rc2=%Rrc\n", __LINE__, j, i, rc2); 93 g_cErrors++; 94 } 95 } 73 96 } 74 97 … … 76 99 * Summary. 77 100 */ 78 if (! rcRet)79 RTPrintf("tst LdrLoad: SUCCESS\n");101 if (!g_cErrors) 102 RTPrintf("tstThread-1: SUCCESS\n"); 80 103 else 81 RTPrintf("tst LdrLoad: FAILURE - %d errors\n", rcRet);104 RTPrintf("tstThread-1: FAILURE - %d errors\n", g_cErrors); 82 105 83 return !! rcRet;106 return !!g_cErrors; 84 107 }
Note:
See TracChangeset
for help on using the changeset viewer.