Changeset 96583 in vbox
- Timestamp:
- Sep 2, 2022 8:35:17 PM (2 years ago)
- Location:
- trunk/src/VBox/ValidationKit/utils/misc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/misc/Makefile.kmk
r96407 r96583 38 38 include $(KBUILD_PATH)/subheader.kmk 39 39 40 # 41 # Load generator, optionally with an ring-0 IPI generator. 42 # 40 43 PROGRAMS += LoadGenerator 41 LoadGenerator_TEMPLATE = VBoxValidationKitR3SupDrv 42 LoadGenerator_SOURCES = loadgenerator.cpp 44 if1of ($(KBUILD_TARGET_ARCH),amd64) 45 ifdef VBOX_WITH_R0_MODULES 46 ifdef VBOX_WITH_VBOXR0_AS_DLL 47 DLLS += loadgeneratorR0 48 else 49 SYSMODS += loadgeneratorR0 50 endif 51 loadgeneratorR0_TEMPLATE := VBoxValidationKitR0 52 loadgeneratorR0_SOURCES := loadgeneratorR0.cpp 53 endif 54 LoadGenerator_TEMPLATE := VBoxValidationKitR3SupDrv 55 LoadGenerator_DEFS := WITH_IPI_LOAD_GEN 56 else 57 LoadGenerator_TEMPLATE := VBoxValidationKitR3 58 endif 59 LoadGenerator_SOURCES := loadgenerator.cpp 43 60 44 ifdef VBOX_WITH_R0_MODULES 45 ifdef VBOX_WITH_VBOXR0_AS_DLL 46 DLLS += loadgeneratorR0 47 else 48 SYSMODS += loadgeneratorR0 49 endif 50 loadgeneratorR0_TEMPLATE = VBoxValidationKitR0 51 loadgeneratorR0_SOURCES = loadgeneratorR0.cpp 52 endif 53 61 # 62 # vts_rm - Test cleanup utility similar to unix rm. 63 # 54 64 PROGRAMS += vts_rm 55 65 vts_rm_TEMPLATE = VBoxValidationKitR3 56 66 vts_rm_SOURCES = vts_rm.cpp 57 67 68 # 69 # vts_tar - Tar for untarring and tarring test related stuff. 70 # 58 71 PROGRAMS += vts_tar 59 72 vts_tar_TEMPLATE = VBoxValidationKitR3 … … 61 74 vts_tar_SOURCES = vts_tar.cpp 62 75 76 # 77 # vts_shutdown - initiates a guest or host shut down / reboot. 78 # 63 79 PROGRAMS += vts_shutdown 64 80 vts_shutdown_TEMPLATE = VBoxValidationKitR3 -
trunk/src/VBox/ValidationKit/utils/misc/loadgenerator.cpp
r96407 r96583 43 43 #include <iprt/time.h> 44 44 #include <iprt/initterm.h> 45 #include <iprt/message.h> 45 46 #include <iprt/string.h> 46 47 #include <iprt/stream.h> … … 51 52 #include <iprt/asm.h> 52 53 #include <iprt/getopt.h> 53 #include <VBox/sup.h> 54 #ifdef WITH_IPI_LOAD_GEN 55 # include <VBox/sup.h> 56 #endif 54 57 55 58 … … 59 62 /** Whether the threads should quit or not. */ 60 63 static bool volatile g_fQuit = false; 61 static const char *g_pszProgramName = NULL;62 63 64 /*********************************************************************************************************************************65 * Internal Functions *66 *********************************************************************************************************************************/67 static int Error(const char *pszFormat, ...);68 64 69 65 … … 86 82 } 87 83 84 #ifdef WITH_IPI_LOAD_GEN 88 85 89 86 static int LoadGenIpiInit(void) … … 109 106 } 110 107 else 111 Error("SUPR3LoadServiceModule(%s): %Rrc\n", szPath, rc);108 RTMsgError("SUPR3LoadServiceModule(%s): %Rrc", szPath, rc); 112 109 } 113 110 else 114 Error("RTPathAppPrivateArch: %Rrc\n", rc);111 RTMsgError("RTPathAppPrivateArch: %Rrc", rc); 115 112 return rc; 116 113 } … … 126 123 if (RT_FAILURE(rc)) 127 124 { 128 Error("SUPR3CallR0Service: %Rrc\n", rc);125 RTMsgError("SUPR3CallR0Service: %Rrc", rc); 129 126 break; 130 127 } … … 140 137 } 141 138 142 143 static int Error(const char *pszFormat, ...) 144 { 145 va_list va; 146 RTStrmPrintf(g_pStdErr, "%s: error: ", g_pszProgramName); 147 va_start(va, pszFormat); 148 RTStrmPrintfV(g_pStdErr, pszFormat, va); 149 va_end(va); 150 return 1; 151 } 152 153 154 static int SyntaxError(const char *pszFormat, ...) 155 { 156 va_list va; 157 RTStrmPrintf(g_pStdErr, "%s: syntax error: ", g_pszProgramName); 158 va_start(va, pszFormat); 159 RTStrmPrintfV(g_pStdErr, pszFormat, va); 160 va_end(va); 161 return 1; 162 } 139 #endif 163 140 164 141 … … 173 150 { 174 151 { "spin", NULL, LoadGenSpinThreadFunction }, 152 #ifdef WITH_IPI_LOAD_GEN 175 153 { "ipi", LoadGenIpiInit, LoadGenIpiThreadFunction }, 154 #endif 176 155 }; 177 156 unsigned iLoadType = 0; … … 185 164 186 165 RTR3InitExe(argc, &argv, 0); 187 188 /*189 * Set program name.190 */191 g_pszProgramName = RTPathFilename(argv[0]);192 166 193 167 /* … … 213 187 cThreads = ValueUnion.u64; 214 188 if (cThreads == 0 || cThreads > RT_ELEMENTS(s_aThreads)) 215 return SyntaxError("Requested number of threads, %RU32, is out of range (1..%d).\n",189 return RTMsgSyntax("Requested number of threads, %RU32, is out of range (1..%d).", 216 190 cThreads, RT_ELEMENTS(s_aThreads) - 1); 217 191 break; … … 222 196 rc = RTStrToUInt64Ex(ValueUnion.psz, &psz, 0, &cNanoSeconds); 223 197 if (RT_FAILURE(rc)) 224 return SyntaxError("Failed reading the alleged number '%s' (option '%s', rc=%Rrc).\n",198 return RTMsgSyntax("Failed reading the alleged number '%s' (option '%s', rc=%Rrc).", 225 199 ValueUnion.psz, rc); 226 200 while (*psz == ' ' || *psz == '\t') … … 240 214 u64Factor = UINT64_C(3600000000000); 241 215 else 242 return SyntaxError("Unknown time suffix '%s'\n", psz);216 return RTMsgSyntax("Unknown time suffix '%s'", psz); 243 217 uint64_t u64 = cNanoSeconds * u64Factor; 244 218 if (u64 < cNanoSeconds || (u64 < u64Factor && u64)) 245 return SyntaxError("Time representation overflowed! (%RU64 * %RU64)\n",219 return RTMsgSyntax("Time representation overflowed! (%RU64 * %RU64)", 246 220 psz, cNanoSeconds, u64Factor); 247 221 cNanoSeconds = u64; … … 275 249 } 276 250 else 277 return SyntaxError("can't grok thread type '%s'\n",251 return RTMsgSyntax("can't grok thread type '%s'", 278 252 ValueUnion.psz); 279 253 } … … 282 256 enmThreadType = (RTTHREADTYPE)u32; 283 257 if (enmThreadType <= RTTHREADTYPE_INVALID || enmThreadType >= RTTHREADTYPE_END) 284 return SyntaxError("thread type '%d' is out of range (%d..%d)\n",258 return RTMsgSyntax("thread type '%d' is out of range (%d..%d)", 285 259 ValueUnion.psz, RTTHREADTYPE_INVALID + 1, RTTHREADTYPE_END - 1); 286 260 } … … 302 276 } 303 277 if (ValueUnion.psz) 304 return SyntaxError("Unknown load type '%s'.\n", ValueUnion.psz);278 return RTMsgSyntax("Unknown load type '%s'.", ValueUnion.psz); 305 279 break; 306 280 } 307 281 308 282 case 'h': 309 RTStrmPrintf(g_pStdOut, 310 "Usage: %s [-p|--thread-type <type>] [-t|--timeout <sec|xxx[h|m|s|ms|ns]>] \\\n" 311 " %*s [-n|--number-of-threads <threads>] [-l|--load <loadtype>]\n" 312 "\n" 313 "Load types: spin, ipi.\n" 314 , 315 g_pszProgramName, strlen(g_pszProgramName), ""); 283 RTPrintf("Usage: %s [-p|--thread-type <type>] [-t|--timeout <sec|xxx[h|m|s|ms|ns]>] \\\n" 284 " %*s [-n|--number-of-threads <threads>] [-l|--load <loadtype>]\n" 285 "\n" 286 "Load types: " 287 , RTProcShortName(), strlen(RTProcShortName()), ""); 288 for (size_t i = 0; i < RT_ELEMENTS(s_aLoadTypes); i++) 289 RTPrintf(i == 0 ? "%s (default)" : ", %s", s_aLoadTypes[i].pszName); 290 RTPrintf("\n"); 316 291 return 1; 317 292 … … 321 296 322 297 case VINF_GETOPT_NOT_OPTION: 323 return SyntaxError("Unknown argument #%d: '%s'\n", GetState.iNext-1, ValueUnion.psz);298 return RTMsgSyntax("Unknown argument #%d: '%s'", GetState.iNext-1, ValueUnion.psz); 324 299 325 300 default: … … 335 310 const unsigned cCpus = RTMpGetOnlineCount(); 336 311 if (cCpus * cThreads > RT_ELEMENTS(s_aThreads)) 337 return SyntaxError("Requested number of threads, %RU32, is out of range (1..%d) when scaled by %d.\n",312 return RTMsgSyntax("Requested number of threads, %RU32, is out of range (1..%d) when scaled by %d.", 338 313 cThreads, RT_ELEMENTS(s_aThreads) - 1, cCpus); 339 314 cThreads *= cCpus; … … 370 345 { 371 346 ASMAtomicXchgBool(&g_fQuit, true); 372 RT StrmPrintf(g_pStdErr, "%s: failed to create thread #%d, rc=%Rrc\n", g_pszProgramName, i, rc);347 RTMsgError("failed to create thread #%d: %Rrc", i, rc); 373 348 while (i-- > 1) 374 349 RTThreadWait(s_aThreads[i], 1500, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.