vbox的更動 46554 路徑 trunk/src/VBox/VMM/testcase
- 時間撮記:
- 2013-6-14 下午12:29:38 (11 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/VMM/testcase/Instructions/InstructionTestGen.py
r46550 r46554 232 232 return 8; 233 233 234 def randGRegNoSp(self): 235 """ Returns a random general register number, excluding the SP register. """ 236 iReg = randU16(); 237 return iReg % (16 if self.is64Bit() else 8); 238 234 239 235 240 … … 276 281 self.acbOpVars = [ 1, 2, 4, 8 ] if not acbOpVars else list(acbOpVars); 277 282 278 def generateInputs(self, cbEffOp, cbMaxOp ):283 def generateInputs(self, cbEffOp, cbMaxOp, oGen, fLong = False): 279 284 """ Generate a list of inputs. """ 280 # Fixed ranges. 281 auRet = [0, 1, ]; 282 if cbEffOp == 1: 283 auRet += [ UINT8_MAX / 2, UINT8_MAX / 2 + 1, UINT8_MAX ]; 284 elif cbEffOp == 2: 285 auRet += [ UINT16_MAX / 2, UINT16_MAX / 2 + 1, UINT16_MAX ]; 286 elif cbEffOp == 4: 287 auRet += [ UINT32_MAX / 2, UINT32_MAX / 2 + 1, UINT32_MAX ]; 288 elif cbEffOp == 8: 289 auRet += [ UINT64_MAX / 2, UINT64_MAX / 2 + 1, UINT64_MAX ]; 285 if fLong: 286 # 287 # Try do extremes as well as different ranges of random numbers. 288 # 289 auRet = [0, 1, ]; 290 if cbMaxOp >= 1: 291 auRet += [ UINT8_MAX / 2, UINT8_MAX / 2 + 1, UINT8_MAX ]; 292 if cbMaxOp >= 2: 293 auRet += [ UINT16_MAX / 2, UINT16_MAX / 2 + 1, UINT16_MAX ]; 294 if cbMaxOp >= 4: 295 auRet += [ UINT32_MAX / 2, UINT32_MAX / 2 + 1, UINT32_MAX ]; 296 if cbMaxOp >= 8: 297 auRet += [ UINT64_MAX / 2, UINT64_MAX / 2 + 1, UINT64_MAX ]; 298 299 if oGen.oOptions.sTestSize == InstructionTestGen.ksTestSize_Tiny: 300 for cBits, cValues in ( (8, 4), (16, 4), (32, 8), (64, 8) ): 301 if cBits < cbMaxOp * 8: 302 auRet += randUxxList(cBits, cValues); 303 cWanted = 16; 304 elif oGen.oOptions.sTestSize == InstructionTestGen.ksTestSize_Medium: 305 for cBits, cValues in ( (8, 8), (16, 8), (24, 2), (32, 16), (40, 1), (48, 1), (56, 1), (64, 16) ): 306 if cBits < cbMaxOp * 8: 307 auRet += randUxxList(cBits, cValues); 308 cWanted = 64; 309 else: 310 for cBits, cValues in ( (8, 16), (16, 16), (24, 4), (32, 64), (40, 4), (48, 4), (56, 4), (64, 64) ): 311 if cBits < cbMaxOp * 8: 312 auRet += randUxxList(cBits, cValues); 313 cWanted = 168; 314 if len(auRet) < cWanted: 315 auRet += randUxxList(cbEffOp * 8, cWanted - len(auRet)); 290 316 else: 291 assert False; 292 293 # Append some random values as well. 294 auRet += randUxxList(cbEffOp * 8, 4); 295 auRet += randUxxList(cbMaxOp * 8, 4); 296 317 # 318 # Short list, just do some random numbers. 319 # 320 auRet = []; 321 if oGen.oOptions.sTestSize == InstructionTestGen.ksTestSize_Tiny: 322 auRet += randUxxList(cbMaxOp, 1); 323 elif oGen.oOptions.sTestSize == InstructionTestGen.ksTestSize_Medium: 324 auRet += randUxxList(cbMaxOp, 2); 325 else: 326 auRet = []; 327 for cBits in (8, 16, 32, 64): 328 if cBits < cbMaxOp * 8: 329 auRet += randUxxList(cBits, 1); 297 330 return auRet; 298 331 … … 323 356 """ Generate standard tests. """ 324 357 325 cbDefOp = oGen.oTarget.getDefOpBytes(); 326 cbMaxOp = oGen.oTarget.getMaxOpBytes(); 327 auInputs = self.generateInputs(cbDefOp, cbMaxOp); 328 329 358 # Parameters. 359 cbDefOp = oGen.oTarget.getDefOpBytes(); 360 cbMaxOp = oGen.oTarget.getMaxOpBytes(); 361 auShortInputs = self.generateInputs(cbDefOp, cbMaxOp, oGen); 362 auLongInputs = self.generateInputs(cbDefOp, cbMaxOp, oGen, fLong = True); 363 iLongOp1 = oGen.oTarget.randGRegNoSp(); 364 iLongOp2 = oGen.oTarget.randGRegNoSp(); 365 oOp2Range = range(oGen.oTarget.getGRegCount()); 366 if oGen.oOptions.sTestSize == InstructionTestGen.ksTestSize_Tiny: 367 oOp2Range = [iLongOp2,]; 368 369 # Register tests. 330 370 for cbEffOp in self.acbOpVars: 331 371 if cbEffOp > cbMaxOp: … … 334 374 if oGen.oTarget.asGRegsNoSp[iOp1] is None: 335 375 continue; 336 for iOp2 in range(oGen.oTarget.getGRegCount()):376 for iOp2 in oOp2Range: 337 377 if oGen.oTarget.asGRegsNoSp[iOp2] is None: 338 378 continue; 339 for uInput in auInputs:379 for uInput in (auLongInputs if iOp1 == iLongOp1 and iOp2 == iLongOp2 else auShortInputs): 340 380 uResult = self.fnCalcResult(cbEffOp, uInput, oGen.auRegValues[iOp1] if iOp1 != iOp2 else uInput, oGen); 341 381 oGen.newSubTest(); 342 382 self.generateOneStdTest(oGen, cbEffOp, cbMaxOp, iOp1, iOp2, uInput, uResult); 383 343 384 return True; 344 385 … … 405 446 Instruction Test Generator. 406 447 """ 448 449 ## @name Test size 450 ## @{ 451 ksTestSize_Large = 'large'; 452 ksTestSize_Medium = 'medium'; 453 ksTestSize_Tiny = 'tiny'; 454 ## @} 455 kasTestSizes = ( ksTestSize_Large, ksTestSize_Medium, ksTestSize_Tiny ); 456 407 457 408 458 … … 777 827 help = 'The target environment. Choices: %s' 778 828 % (', '.join(sorted(g_dTargetEnvs.keys())),)); 829 oParser.add_option('--test-size', dest = 'sTestSize', default = InstructionTestGen.ksTestSize_Medium, 830 choices = InstructionTestGen.kasTestSizes, 831 help = 'Selects the test size.'); 779 832 780 833 (oOptions, asArgs) = oParser.parse_args();
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器