Fennel: CalcCastTest Class Reference (original) (raw)
Inheritance diagram for CalcCastTest:

| Public Member Functions | |
|---|---|
| CalcCastTest () | |
| virtual | ~CalcCastTest () |
| TestSuite * | releaseTestSuite () |
| void | beforeTestCase (std::string testCaseName) |
| void | afterTestCase (std::string testCaseName) |
| virtual void | testCaseSetUp () |
| Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked. | |
| virtual void | testCaseTearDown () |
| Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked. | |
| virtual void | notifyTrace (std::string source, TraceLevel level, std::string message) |
| Receives notification when a trace event occurs. | |
| virtual TraceLevel | getSourceTraceLevel (std::string source) |
| Gets the level at which a particular source should be traced. | |
| virtual void | initTraceSource (SharedTraceTarget pTraceTarget, std::string name) |
| For use when initialization has to be deferred until after construction. | |
| void | trace (TraceLevel level, std::string message) const |
| Records a trace message. | |
| bool | isTracing () const |
| **Returns:**true iff tracing is enabled for this source | |
| bool | isTracingLevel (TraceLevel level) const |
| Determines whether a particular level is being traced. | |
| TraceTarget & | getTraceTarget () const |
| **Returns:**the TraceTarget for this source | |
| SharedTraceTarget | getSharedTraceTarget () const |
| **Returns:**the SharedTraceTarget for this source | |
| std::string | getTraceSourceName () const |
| Gets the name of this source. | |
| void | setTraceSourceName (std::string const &n) |
| Sets the name of this source. | |
| TraceLevel | getMinimumTraceLevel () const |
| void | disableTracing () |
| Static Public Member Functions | |
| static void | readParams (int argc, char **argv) |
| Parses the command line. | |
| Static Public Attributes | |
| static ParamName | paramTestSuiteName |
| static ParamName | paramTraceFileName |
| static ParamName | paramDictionaryFileName |
| static ParamName | paramTraceLevel |
| static ParamName | paramStatsFileName |
| static ParamName | paramTraceStdout |
| static ParamName | paramDegreeOfParallelism |
| static ConfigMap | configMap |
| Configuration parameters. | |
| Protected Member Functions | |
| void | snooze (uint nSeconds) |
| Protected Attributes | |
| TestSuite * | pTestSuite |
| Boost test suite. | |
| boost::shared_ptr< TestBase > | pTestObj |
| std::ofstream | traceStream |
| Output file stream for tracing. | |
| StrictMutex | traceMutex |
| Protects traceStream. | |
| std::string | testName |
| Name of test. | |
| TraceLevel | traceLevel |
| Level at which to trace test execution. | |
| FileStatsTarget | statsTarget |
| Output for stats. | |
| StatsTimer | statsTimer |
| Timer for stats collection. | |
| bool | traceStdout |
| Copy trace output to stdout. | |
| bool | traceFile |
| Copy trace output to file. | |
| TestCaseGroup | defaultTests |
| TestCaseGroup | extraTests |
| Static Protected Attributes | |
| static bool | runAll |
| Run all test cases, including the extra tests. | |
| static std::string | runSingle |
| Run only the test case of this name. | |
| Private Types | |
| typedef void(*) | SetFunction (TupleDataWithBuffer &inTuple) |
| typedef void(*) | CheckFunction (TupleDataWithBuffer const &inTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings) |
| Private Member Functions | |
| void | PassAll () |
| void | NegValues () |
| void | Round () |
| void | Overflow () |
| void | Underflow () |
| void | testRoundInstruction () |
| Static Private Member Functions | |
| static void | testExe (SetFunction setF, CheckFunction checkF, char const *const srcTypeStr, int numSrcTypes, char const *const destTypeStr, int numDestTypes, int warningCombos[][2], bool roundValues) |
| static bool | shouldWarn (int warningCombos[][2], int srcIdx, int destIdx) |
| static void | checkWarnings (deque< CalcMessage > &warnings, vector< int > const &expectedWarnings) |
| static void | PassAllSet (TupleDataWithBuffer &inTuple) |
| static void | PassAllCheck (TupleDataWithBuffer const &outTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings) |
| static void | NegValuesSet (TupleDataWithBuffer &inTuple) |
| static void | NegValuesCheck (TupleDataWithBuffer const &outTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings) |
| static void | RoundSet (TupleDataWithBuffer &inTuple) |
| static void | RoundCheck (TupleDataWithBuffer const &outTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings) |
| static void | OverflowSet (TupleDataWithBuffer &inTuple) |
| static void | OverflowCheck (TupleDataWithBuffer const &outTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings) |
| static void | UnderflowSet (TupleDataWithBuffer &inTuple) |
| static void | UnderflowCheck (TupleDataWithBuffer const &outTuple, int numSrcTypes, deque< CalcMessage > &warnings, vector< int > const &expectedWarnings) |
Detailed Description
Definition at line 42 of file CalcCastTest.cpp.
Member Typedef Documentation
Constructor & Destructor Documentation
| CalcCastTest::CalcCastTest | ( | | ) | [inline, explicit] | | -------------------------- | - | | - | -------------------- |
| virtual CalcCastTest::~CalcCastTest | ( | | ) | [inline, virtual] | | ------------------------------------ | - | | - | ------------------- |
Member Function Documentation
| void CalcCastTest::testExe | ( | SetFunction | setF, |
|---|---|---|---|
| CheckFunction | checkF, | ||
| char const *const | srcTypeStr, | ||
| int | numSrcTypes, | ||
| char const *const | destTypeStr, | ||
| int | numDestTypes, | ||
| int | _warningCombos_[][2], | ||
| bool | roundValues | ||
| ) | [static, private] |
Definition at line 278 of file CalcCastTest.cpp.
References FennelExcn::getMessage(), and shouldWarn().
Referenced by NegValues(), Overflow(), PassAll(), Round(), and Underflow().
00287 {
00288 ostringstream pg(""), typeProduct("");
00289
00290 int destIdx, srcIdx, idx, pc;
00291 bool warn;
00292 vector expectedWarnings;
00293
00294
00295 for (idx = 0; idx < numSrcTypes; idx++) {
00296 if (idx != 0) {
00297 typeProduct << "," << endl << " ";
00298 }
00299 typeProduct << destTypeStr;
00300 }
00301 typeProduct << ";" << endl;
00302
00303 pg << "L " << typeProduct.str();
00304 pg << "O " << typeProduct.str();
00305 pg << "I " << srcTypeStr << ";" << endl;
00306
00307 pg << "S " << srcTypeStr << ";" << endl;
00308 pg << "T;" << endl;
00309
00310 if (roundValues) {
00311 for (srcIdx = 0; srcIdx < numSrcTypes; srcIdx++) {
00312 pg << "ROUND S" << srcIdx << ", I" << srcIdx << ";" << endl;
00313 }
00314 }
00315
00316 destIdx = 0;
00317 pc = 0;
00318 for (srcIdx = 0; srcIdx < numSrcTypes; srcIdx++) {
00319 for (idx = 0; idx < numDestTypes; idx++) {
00320 warn = shouldWarn(warningCombos, srcIdx, idx);
00321 if (warn) {
00322 expectedWarnings.push_back(pc);
00323 BOOST_MESSAGE(
00324 "ShouldWarn PC=" << pc << " size="
00325 << expectedWarnings.size());
00326 }
00327 pg << "CAST L" << destIdx;
00328 if (roundValues) {
00329 pg << ", S";
00330 } else {
00331 pg << ", I";
00332 }
00333 pg << srcIdx << ";";
00334 pg << " /* " << pc++ << (warn ? " WARN" : "");
00335 pg << " src=" << srcIdx << " dest=" << idx << " /" << endl;
00336 pg << "REF O" << destIdx << ", L" << destIdx << ";";
00337 pg << " / " << pc++ << " */" << endl;
00338 destIdx++;
00339 }
00340 }
00341
00342 BOOST_MESSAGE(pg.str());
00343
00344 Calculator calc(0);
00345
00346 try {
00347 calc.assemble(pg.str().c_str());
00348 } catch (FennelExcn& ex) {
00349 BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00350 BOOST_REQUIRE(0);
00351 }
00352
00353 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00354 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00355
00356 calc.bind(&inTuple, &outTuple);
00357
00358 setF(inTuple);
00359
00360 calc.exec();
00361 BOOST_MESSAGE("Calculator Warnings: |" << calc.warnings() << "|");
00362 checkF(outTuple, numSrcTypes, calc.mWarnings, expectedWarnings);
00363 }
| bool CalcCastTest::shouldWarn | ( | int | _warningCombos_[][2], |
|---|---|---|---|
| int | srcIdx, | ||
| int | destIdx | ||
| ) | [static, private] |
Definition at line 366 of file CalcCastTest.cpp.
Referenced by testExe().
00370 {
00371 int idx = 0;
00372
00373 while (warningCombos[idx][0] >= 0 &&
00374 warningCombos[idx][1] >= 0) {
00375 if (warningCombos[idx][0] == srcIdx &&
00376 warningCombos[idx][1] == destIdx) {
00377 return true;
00378 }
00379 idx++;
00380 }
00381 return false;
00382 }
| void CalcCastTest::checkWarnings | ( | deque< CalcMessage > & | warnings, |
|---|---|---|---|
| vector< int > const & | expectedWarnings | ||
| ) | [static, private] |
Definition at line 385 of file CalcCastTest.cpp.
Referenced by NegValuesCheck(), OverflowCheck(), PassAllCheck(), RoundCheck(), and UnderflowCheck().
00388 { 00389 deque::iterator iter = warnings.begin(); 00390 deque::iterator end = warnings.end(); 00391 00392 int idx = 0; 00393 ostringstream ew(""); 00394 ew << "Expected Warnings: (PC=) |"; 00395 while (idx < expectedWarnings.size()) { 00396 ew << expectedWarnings[idx++] << ", "; 00397 } 00398 ew << "|" << endl; 00399 BOOST_MESSAGE(ew.str()); 00400 00401 idx = 0; 00402 while (idx < expectedWarnings.size()) { 00403 BOOST_CHECK(iter != end); 00404 BOOST_CHECK_EQUAL(iter->pc, expectedWarnings[idx]); 00405 BOOST_CHECK_EQUAL(0, strcmp(iter->str, "22003")); 00406 iter++; 00407 idx++; 00408 } 00409 BOOST_CHECK(iter == end); 00410 }
| void CalcCastTest::PassAll | ( | | ) | [private] | | -------------------------- | - | | - | ----------- |
Definition at line 518 of file CalcCastTest.cpp.
References PassAllCheck(), PassAllSet(), and testExe().
Referenced by CalcCastTest().
00519 {
00520 char const * const all =
00521 "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00522
00523
00524 int warningCombos[][2] = {
00525
00526 { -1, -1 }
00527 };
00528
00529 testExe(
00530 CalcCastTest::PassAllSet,
00531 CalcCastTest::PassAllCheck,
00532 all, 10,
00533 all, 10,
00534 warningCombos,
00535 false);
00536 }
Definition at line 413 of file CalcCastTest.cpp.
Referenced by PassAll().
00414 { 00415 uint64_t exact = 10; 00416 double approx = 20.0; 00417 int idx = 0; 00418 00419 *(reinterpret_cast<int8_t *> 00420 (const_cast(inTuple[idx++].pData))) = exact; 00421 *(reinterpret_cast<uint8_t *> 00422 (const_cast(inTuple[idx++].pData))) = exact; 00423 *(reinterpret_cast<int16_t *> 00424 (const_cast(inTuple[idx++].pData))) = exact; 00425 *(reinterpret_cast<uint16_t *> 00426 (const_cast(inTuple[idx++].pData))) = exact; 00427 *(reinterpret_cast<int32_t *> 00428 (const_cast(inTuple[idx++].pData))) = exact; 00429 *(reinterpret_cast<uint32_t *> 00430 (const_cast(inTuple[idx++].pData))) = exact; 00431 *(reinterpret_cast<int64_t *> 00432 (const_cast(inTuple[idx++].pData))) = exact; 00433 *(reinterpret_cast<uint64_t *> 00434 (const_cast(inTuple[idx++].pData))) = exact; 00435 00436 *(reinterpret_cast<float *> 00437 (const_cast(inTuple[idx++].pData))) = approx; 00438 *(reinterpret_cast<double *> 00439 (const_cast(inTuple[idx++].pData))) = approx; 00440 00441 }
| void CalcCastTest::PassAllCheck | ( | TupleDataWithBuffer const & | outTuple, |
|---|---|---|---|
| int | numSrcTypes, | ||
| deque< CalcMessage > & | warnings, | ||
| vector< int > const & | expectedWarnings | ||
| ) | [static, private] |
Definition at line 444 of file CalcCastTest.cpp.
References checkWarnings().
Referenced by PassAll().
00449 { 00450 checkWarnings(warnings, expectedWarnings); 00451 00452 uint64_t exact; 00453 double approx; 00454 int i, idx = 0; 00455 00456 for (i = 0; i < numSrcTypes; i++) { 00457 if (i < 8) { 00458 exact = 10; 00459 approx = 10; 00460 } else { 00461 exact = 20; 00462 approx = 20; 00463 } 00464 BOOST_CHECK_EQUAL( 00465 *(reinterpret_cast<int8_t *>( 00466 const_cast(outTuple[idx++].pData))), 00467 exact); 00468 00469 BOOST_CHECK_EQUAL( 00470 *(reinterpret_cast<uint8_t *>( 00471 const_cast(outTuple[idx++].pData))), 00472 exact); 00473 00474 BOOST_CHECK_EQUAL( 00475 *(reinterpret_cast<int16_t *>( 00476 const_cast(outTuple[idx++].pData))), 00477 exact); 00478 00479 BOOST_CHECK_EQUAL( 00480 *(reinterpret_cast<uint16_t *>( 00481 const_cast(outTuple[idx++].pData))), 00482 exact); 00483 00484 BOOST_CHECK_EQUAL( 00485 *(reinterpret_cast<int32_t *>( 00486 const_cast(outTuple[idx++].pData))), 00487 exact); 00488 00489 BOOST_CHECK_EQUAL( 00490 *(reinterpret_cast<uint32_t *>( 00491 const_cast(outTuple[idx++].pData))), 00492 exact); 00493 00494 BOOST_CHECK_EQUAL( 00495 *(reinterpret_cast<int64_t *>( 00496 const_cast(outTuple[idx++].pData))), 00497 exact); 00498 00499 BOOST_CHECK_EQUAL( 00500 *(reinterpret_cast<uint64_t *>( 00501 const_cast(outTuple[idx++].pData))), 00502 exact); 00503 00504 BOOST_CHECK_EQUAL( 00505 *(reinterpret_cast<float *>( 00506 const_cast(outTuple[idx++].pData))), 00507 approx); 00508 00509 BOOST_CHECK_EQUAL( 00510 *(reinterpret_cast<double *>( 00511 const_cast(outTuple[idx++].pData))), 00512 approx); 00513 } 00514 }
| void CalcCastTest::NegValues | ( | | ) | [private] | | ---------------------------- | - | | - | ----------- |
Definition at line 628 of file CalcCastTest.cpp.
References NegValuesCheck(), NegValuesSet(), and testExe().
Referenced by CalcCastTest().
00629 {
00630 char const * const src =
00631 "s1, s2, s4, s8, r, d";
00632
00633
00634 char const * const dest =
00635 "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00636
00637
00638
00639 int warningCombos[][2] = {
00640
00641 {0, 1 },
00642 { 0, 3 },
00643 { 0, 5 },
00644 { 0, 7 },
00645 { 1, 1 },
00646 { 1, 3 },
00647 { 1, 5 },
00648 { 1, 7 },
00649 { 2, 1 },
00650 { 2, 3 },
00651 { 2, 5 },
00652 { 2, 7 },
00653 { 3, 1 },
00654 { 3, 3 },
00655 { 3, 5 },
00656 { 3, 7 },
00657 { 4, 1 },
00658 { 4, 3 },
00659 { 4, 5 },
00660 { 4, 7 },
00661 { 5, 1 },
00662 { 5, 3 },
00663 { 5, 5 },
00664 { 5, 7 },
00665 { -1, -1 }
00666 };
00667
00668 testExe(
00669 CalcCastTest::NegValuesSet,
00670 CalcCastTest::NegValuesCheck,
00671 src, 6,
00672 dest, 10,
00673 warningCombos,
00674 false);
00675 }
Definition at line 540 of file CalcCastTest.cpp.
Referenced by NegValues().
00541 { 00542 int64_t exact = -10; 00543 double approx = -20.0; 00544 int idx = 0; 00545 00546 *(reinterpret_cast<int8_t *> 00547 (const_cast(inTuple[idx++].pData))) = exact; 00548 *(reinterpret_cast<int16_t *> 00549 (const_cast(inTuple[idx++].pData))) = exact; 00550 *(reinterpret_cast<int32_t *> 00551 (const_cast(inTuple[idx++].pData))) = exact; 00552 *(reinterpret_cast<int64_t *> 00553 (const_cast(inTuple[idx++].pData))) = exact; 00554 00555 *(reinterpret_cast<float *> 00556 (const_cast(inTuple[idx++].pData))) = approx; 00557 *(reinterpret_cast<double *> 00558 (const_cast(inTuple[idx++].pData))) = approx; 00559 }
| void CalcCastTest::NegValuesCheck | ( | TupleDataWithBuffer const & | outTuple, |
|---|---|---|---|
| int | numSrcTypes, | ||
| deque< CalcMessage > & | warnings, | ||
| vector< int > const & | expectedWarnings | ||
| ) | [static, private] |
Definition at line 562 of file CalcCastTest.cpp.
References checkWarnings().
Referenced by NegValues().
00567 {
00568 checkWarnings(warnings, expectedWarnings);
00569
00570 int64_t exact = -10;
00571 double approx = -20.0;
00572 int i, idx = 0;
00573
00574 for (i = 0; i < numSrcTypes; i++) {
00575 if (i < 4) {
00576 exact = -10;
00577 approx = -10;
00578 } else {
00579 exact = -20;
00580 approx = -20;
00581 }
00582 BOOST_CHECK_EQUAL(
00583 *(reinterpret_cast<int8_t *>(
00584 const_cast(outTuple[idx++].pData))),
00585 exact);
00586
00587
00588 idx++;
00589
00590 BOOST_CHECK_EQUAL(
00591 *(reinterpret_cast<int16_t *>(
00592 const_cast(outTuple[idx++].pData))),
00593 exact);
00594
00595
00596 idx++;
00597
00598 BOOST_CHECK_EQUAL(
00599 *(reinterpret_cast<int32_t *>(
00600 const_cast(outTuple[idx++].pData))),
00601 exact);
00602
00603
00604 idx++;
00605
00606 BOOST_CHECK_EQUAL(
00607 *(reinterpret_cast<int64_t *>(
00608 const_cast(outTuple[idx++].pData))),
00609 exact);
00610
00611
00612 idx++;
00613
00614 BOOST_CHECK_EQUAL(
00615 *(reinterpret_cast<float *>(
00616 const_cast(outTuple[idx++].pData))),
00617 approx);
00618
00619 BOOST_CHECK_EQUAL(
00620 *(reinterpret_cast<double *>(
00621 const_cast(outTuple[idx++].pData))),
00622 approx);
00623 }
00624 }
| void CalcCastTest::Round | ( | | ) | [private] | | ------------------------ | - | | - | ----------- |
Definition at line 754 of file CalcCastTest.cpp.
References RoundCheck(), RoundSet(), and testExe().
Referenced by CalcCastTest().
00755 {
00756 char const * const src =
00757 "r, d, r, d, r, d";
00758
00759
00760 char const * const dest =
00761 "s1, u1, s2, u2, s4, u4, s8, u8";
00762
00763
00764
00765 int warningCombos[][2] = {
00766
00767 { -1, -1 }
00768 };
00769
00770 testExe(
00771 CalcCastTest::RoundSet,
00772 CalcCastTest::RoundCheck,
00773 src, 6,
00774 dest, 8,
00775 warningCombos,
00776 true);
00777 }
Definition at line 679 of file CalcCastTest.cpp.
Referenced by Round().
00680 {
00681
00682 double val[3] = { 20.2, 20.5, 20.7 };
00683
00684 int idx = 0, group;
00685
00686 for (group = 0; group < 3; group++) {
00687 *(reinterpret_cast<float *>
00688 (const_cast(inTuple[idx++].pData))) = val[group];
00689 *(reinterpret_cast<double *>
00690 (const_cast(inTuple[idx++].pData))) = val[group];
00691 }
00692 }
| void CalcCastTest::RoundCheck | ( | TupleDataWithBuffer const & | outTuple, |
|---|---|---|---|
| int | numSrcTypes, | ||
| deque< CalcMessage > & | warnings, | ||
| vector< int > const & | expectedWarnings | ||
| ) | [static, private] |
Definition at line 695 of file CalcCastTest.cpp.
References checkWarnings().
Referenced by Round().
00700 { 00701 checkWarnings(warnings, expectedWarnings); 00702 00703 int64_t valE[3] = { 20, 21, 21 }, exact; 00704 int group, srcI, idx = 0; 00705 00706 for (group = 0; group < 3; group++) { 00707 exact = valE[group]; 00708 for (srcI = 0; srcI < 2; srcI++) { 00709 BOOST_CHECK_EQUAL( 00710 *(reinterpret_cast<int8_t *>( 00711 const_cast(outTuple[idx++].pData))), 00712 exact); 00713 00714 BOOST_CHECK_EQUAL( 00715 *(reinterpret_cast<uint8_t *>( 00716 const_cast(outTuple[idx++].pData))), 00717 exact); 00718 00719 BOOST_CHECK_EQUAL( 00720 *(reinterpret_cast<int16_t *>( 00721 const_cast(outTuple[idx++].pData))), 00722 exact); 00723 00724 BOOST_CHECK_EQUAL( 00725 *(reinterpret_cast<uint16_t *>( 00726 const_cast(outTuple[idx++].pData))), 00727 exact); 00728 00729 BOOST_CHECK_EQUAL( 00730 *(reinterpret_cast<int32_t *>( 00731 const_cast(outTuple[idx++].pData))), 00732 exact); 00733 00734 BOOST_CHECK_EQUAL( 00735 *(reinterpret_cast<uint32_t *>( 00736 const_cast(outTuple[idx++].pData))), 00737 exact); 00738 00739 BOOST_CHECK_EQUAL( 00740 *(reinterpret_cast<int64_t *>( 00741 const_cast(outTuple[idx++].pData))), 00742 exact); 00743 00744 BOOST_CHECK_EQUAL( 00745 *(reinterpret_cast<uint64_t *>( 00746 const_cast(outTuple[idx++].pData))), 00747 exact); 00748 } 00749 } 00750 }
| void CalcCastTest::Overflow | ( | | ) | [private] | | --------------------------- | - | | - | ----------- |
Definition at line 832 of file CalcCastTest.cpp.
References OverflowCheck(), OverflowSet(), and testExe().
Referenced by CalcCastTest().
00833 {
00834 char const * const src =
00835 "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00836
00837
00838 char const * const dest =
00839 "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00840
00841
00842
00843 int warningCombos[][2] = {
00844
00845 { 1, 0 },
00846 { 2, 0 },
00847 { 2, 1 },
00848 { 3, 0 },
00849 { 3, 1 },
00850 { 3, 2 },
00851 { 4, 0 },
00852 { 4, 1 },
00853 { 4, 2 },
00854 { 4, 3 },
00855 { 5, 0 },
00856 { 5, 1 },
00857 { 5, 2 },
00858 { 5, 3 },
00859 { 5, 4 },
00860 { 6, 0 },
00861 { 6, 1 },
00862 { 6, 2 },
00863 { 6, 3 },
00864 { 6, 4 },
00865 { 6, 5 },
00866 { 7, 0 },
00867 { 7, 1 },
00868 { 7, 2 },
00869 { 7, 3 },
00870 { 7, 4 },
00871 { 7, 5 },
00872 { 7, 6 },
00873
00874
00875
00876
00877
00878
00879
00880
00881 { 8, 0 },
00882 { 8, 1 },
00883 { 8, 2 },
00884 { 8, 3 },
00885 { 8, 4 },
00886 { 8, 5 },
00887 { 8, 6 },
00888 { 8, 7 },
00889 { 9, 0 },
00890 { 9, 1 },
00891 { 9, 2 },
00892 { 9, 3 },
00893 { 9, 4 },
00894 { 9, 5 },
00895 { 9, 6 },
00896 { 9, 7 },
00897 { 9, 8 },
00898
00899 { -1, -1 }
00900 };
00901
00902 testExe(
00903 CalcCastTest::OverflowSet,
00904 CalcCastTest::OverflowCheck,
00905 src, 10,
00906 dest, 10,
00907 warningCombos,
00908 false);
00909 }
| void CalcCastTest::OverflowCheck | ( | TupleDataWithBuffer const & | outTuple, |
|---|---|---|---|
| int | numSrcTypes, | ||
| deque< CalcMessage > & | warnings, | ||
| vector< int > const & | expectedWarnings | ||
| ) | [static, private] |
| void CalcCastTest::Underflow | ( | | ) | [private] | | ---------------------------- | - | | - | ----------- |
Definition at line 969 of file CalcCastTest.cpp.
References testExe(), UnderflowCheck(), and UnderflowSet().
Referenced by CalcCastTest().
00970 {
00971 char const * const src =
00972 "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00973
00974
00975 char const * const dest =
00976 "s1, u1, s2, u2, s4, u4, s8, u8, r, d";
00977
00978
00979
00980 int warningCombos[][2] = {
00981
00982 { 0, 1 },
00983 { 0, 3 },
00984 { 0, 5 },
00985 { 0, 7 },
00986
00987 { 2, 0 },
00988 { 2, 1 },
00989 { 2, 3 },
00990 { 2, 5 },
00991 { 2, 7 },
00992
00993 { 4, 0 },
00994 { 4, 1 },
00995 { 4, 2 },
00996 { 4, 3 },
00997 { 4, 5 },
00998 { 4, 7 },
00999
01000 { 6, 0 },
01001 { 6, 1 },
01002 { 6, 2 },
01003 { 6, 3 },
01004 { 6, 4 },
01005 { 6, 5 },
01006 { 6, 7 },
01007
01008 { 8, 0 },
01009 { 8, 1 },
01010 { 8, 2 },
01011 { 8, 3 },
01012 { 8, 4 },
01013 { 8, 5 },
01014 { 8, 6 },
01015 { 8, 7 },
01016
01017 { 9, 0 },
01018 { 9, 1 },
01019 { 9, 2 },
01020 { 9, 3 },
01021 { 9, 4 },
01022 { 9, 5 },
01023 { 9, 6 },
01024 { 9, 7 },
01025 { 9, 8 },
01026
01027 { -1, -1 }
01028 };
01029
01030 testExe(
01031 CalcCastTest::UnderflowSet,
01032 CalcCastTest::UnderflowCheck,
01033 src, 10,
01034 dest, 10,
01035 warningCombos,
01036 false);
01037 }
| void CalcCastTest::UnderflowCheck | ( | TupleDataWithBuffer const & | outTuple, |
|---|---|---|---|
| int | numSrcTypes, | ||
| deque< CalcMessage > & | warnings, | ||
| vector< int > const & | expectedWarnings | ||
| ) | [static, private] |
| void CalcCastTest::testRoundInstruction | ( | | ) | [private] | | --------------------------------------- | - | | - | ----------- |
Definition at line 144 of file CalcCastTest.cpp.
References FennelExcn::getMessage().
Referenced by CalcCastTest().
00145 {
00146 ostringstream pg("");
00147 int idx;
00148
00149 const char * const all =
00150 "s1, u1, s2, u2, s4, u4, s8, u8, r, r, r, r, r, d, d, d, d, d";
00151
00152
00153 pg << "O " << all << ";" << endl;
00154 pg << "L " << all << ";" << endl;
00155 pg << "C " << all << ";" << endl;
00156 pg << "V 2, 2, 2, 2, 2, 2, 2, 2,";
00157 pg << " -0.5, -0.25, 0.0, 0.25, 0.5,";
00158 pg << " -0.5, -0.25, 0.0, 0.25, 0.5;" << endl;
00159 pg << "T;" << endl;
00160
00161 for (idx = 0; idx < 18; idx++) {
00162 pg << "ROUND L" << idx << ", C" << idx << ";" << endl;
00163 pg << "REF O" << idx << ", L" << idx << ";" << endl;
00164 }
00165
00166 BOOST_MESSAGE(pg.str());
00167
00168 Calculator calc(0);
00169
00170 try {
00171 calc.assemble(pg.str().c_str());
00172 } catch (FennelExcn& ex) {
00173 BOOST_MESSAGE("Assemble exception " << ex.getMessage());
00174 BOOST_REQUIRE(0);
00175 }
00176
00177 TupleDataWithBuffer outTuple(calc.getOutputRegisterDescriptor());
00178 TupleDataWithBuffer inTuple(calc.getInputRegisterDescriptor());
00179
00180 calc.bind(&inTuple, &outTuple);
00181 calc.exec();
00182
00183 int64_t exact = 2;
00184 idx = 0;
00185
00186 BOOST_CHECK_EQUAL(
00187 *(reinterpret_cast<int8_t *>(
00188 const_cast(outTuple[idx++].pData))),
00189 exact);
00190
00191 BOOST_CHECK_EQUAL(
00192 *(reinterpret_cast<uint8_t *>(
00193 const_cast(outTuple[idx++].pData))),
00194 exact);
00195
00196 BOOST_CHECK_EQUAL(
00197 *(reinterpret_cast<int16_t *>(
00198 const_cast(outTuple[idx++].pData))),
00199 exact);
00200
00201 BOOST_CHECK_EQUAL(
00202 *(reinterpret_cast<uint16_t *>(
00203 const_cast(outTuple[idx++].pData))),
00204 exact);
00205
00206 BOOST_CHECK_EQUAL(
00207 *(reinterpret_cast<int32_t *>(
00208 const_cast(outTuple[idx++].pData))),
00209 exact);
00210
00211 BOOST_CHECK_EQUAL(
00212 *(reinterpret_cast<uint32_t *>(
00213 const_cast(outTuple[idx++].pData))),
00214 exact);
00215
00216 BOOST_CHECK_EQUAL(
00217 *(reinterpret_cast<int64_t *>(
00218 const_cast(outTuple[idx++].pData))),
00219 exact);
00220
00221 BOOST_CHECK_EQUAL(
00222 *(reinterpret_cast<uint64_t *>(
00223 const_cast(outTuple[idx++].pData))),
00224 exact);
00225
00226 BOOST_CHECK_EQUAL(
00227 *(reinterpret_cast<float *>(
00228 const_cast(outTuple[idx++].pData))),
00229 -1.0);
00230
00231 BOOST_CHECK_EQUAL(
00232 *(reinterpret_cast<float *>(
00233 const_cast(outTuple[idx++].pData))),
00234 0.0);
00235
00236 BOOST_CHECK_EQUAL(
00237 *(reinterpret_cast<float *>(
00238 const_cast(outTuple[idx++].pData))),
00239 0.0);
00240
00241 BOOST_CHECK_EQUAL(
00242 *(reinterpret_cast<float *>(
00243 const_cast(outTuple[idx++].pData))),
00244 0.0);
00245
00246 BOOST_CHECK_EQUAL(
00247 *(reinterpret_cast<float *>(
00248 const_cast(outTuple[idx++].pData))),
00249 1.0);
00250
00251 BOOST_CHECK_EQUAL(
00252 *(reinterpret_cast<double *>(
00253 const_cast(outTuple[idx++].pData))),
00254 -1.0);
00255
00256 BOOST_CHECK_EQUAL(
00257 *(reinterpret_cast<double *>(
00258 const_cast(outTuple[idx++].pData))),
00259 0.0);
00260
00261 BOOST_CHECK_EQUAL(
00262 *(reinterpret_cast<double *>(
00263 const_cast(outTuple[idx++].pData))),
00264 0.0);
00265
00266 BOOST_CHECK_EQUAL(
00267 *(reinterpret_cast<double *>(
00268 const_cast(outTuple[idx++].pData))),
00269 0.0);
00270
00271 BOOST_CHECK_EQUAL(
00272 *(reinterpret_cast<double *>(
00273 const_cast(outTuple[idx++].pData))),
00274 1.0);
00275 }
| void TestBase::snooze | ( | uint | nSeconds | ) | [protected, inherited] |
|---|
| void TestBase::readParams | ( | int | argc, |
|---|---|---|---|
| char ** | argv | ||
| ) | [static, inherited] |
Parses the command line.
format: [-v] [-t TEST | -all] {param=val}* [CONFIGFILE | -] Normally, the test program runs the default test cases. With the option "-all", runs the extra test cases as well. With the option "-t TEST", runs only the single test case named TEST. CONFIGFILE is read to load configuration parameters. Configuration parameters can also be set ad hoc, from the command line, as pairs name=val. These take precedence.
Definition at line 108 of file TestBase.cpp.
References TestBase::configMap, ConfigMap::dumpParams(), ConfigMap::isParamSet(), ConfigMap::mergeFrom(), TestBase::paramDictionaryFileName, ConfigMap::readParams(), TestBase::runAll, TestBase::runSingle, ConfigMap::setStringParam(), and verbose.
00109 {
00110 bool verbose = false;
00111 ConfigMap adhocMap;
00112
00113 for (int i = 1; i < argc; ++i) {
00114 std::string arg = argv[i];
00115 if (argv[i][0] == '-') {
00116 if (arg == "-v") {
00117 verbose = true;
00118 } else if (arg == "-") {
00119 configMap.readParams(std::cin);
00120 } else if (arg == "-all") {
00121 runAll = true;
00122 } else if (arg == "-t") {
00123 permAssert(i + 1 < argc);
00124 runSingle = argv[++i];
00125 } else if (arg[1] == 't') {
00126 runSingle = arg.substr(2);
00127 }
00128 } else {
00129 int i = arg.find("=");
00130 if ((0 < i) && (i < arg.size())) {
00131
00132 std::string key = arg.substr(0,i);
00133 std::string val = arg.substr(i + 1);
00134 adhocMap.setStringParam(key,val);
00135 } else {
00136
00137 std::ifstream configFile(arg.c_str());
00138 assert(configFile.good());
00139 configMap.readParams(configFile);
00140 }
00141 }
00142 }
00143 configMap.mergeFrom(adhocMap);
00144
00145
00146
00147 if (.isParamSet(paramDictionaryFileName)) {
00148 std::string dictFileName = "dictWords";
00149 configMap.setStringParam(paramDictionaryFileName,dictFileName);
00150 }
00151
00152 if (verbose) {
00153 configMap.dumpParams(std::cout);
00154 }
00155 }
| TestSuite * TestBase::releaseTestSuite | ( | | ) | [inherited] | | ---------------------------------------------------------------------------------------------- | - | | - | ------------- |
| void TestBase::beforeTestCase | ( | std::string | testCaseName | ) | [inherited] |
|---|
| void TestBase::afterTestCase | ( | std::string | testCaseName | ) | [inherited] |
|---|
| void TestBase::testCaseSetUp | ( | | ) | [virtual, inherited] | | ---------------------------- | - | | - | ---------------------- |
Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked.
Default is no-op.
Reimplemented in LbmEntryTest, LbmExecStreamTestBase, LbmLoadBitmapTest, LbmSearchTest, LbmSplicerExecStreamTest, LcsClusterAppendExecStreamTest, LcsClusterReplaceExecStreamTest, LcsMultiClusterAppendTest, LcsRowScanExecStreamTest, BTreeReadersTest, BTreeTest, BTreeTxnTest, ExecStreamGovernorTest, ExecStreamTestBase, ExecStreamUnitTestBase, ExternalSortExecStreamTest, LhxHashTableTest, LogicalTxnTest, and SnapshotSegmentTestBase.
Definition at line 235 of file TestBase.cpp.
Referenced by ExecStreamTestBase::testCaseSetUp().
| void TestBase::testCaseTearDown | ( | | ) | [virtual, inherited] | | ------------------------------- | - | | - | ---------------------- |
Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked.
Default is no-op.
Reimplemented in LbmEntryTest, LbmLoadBitmapTest, LbmSearchTest, LcsClusterAppendExecStreamTest, LcsClusterReplaceExecStreamTest, LcsMultiClusterAppendTest, LcsRowScanExecStreamTest, BTreeReadersTest, BTreeTest, BTreeTxnTest, CacheTestBase, DatabaseTest, ExecStreamTestBase, LhxHashTableTest, RandomAccessFileDeviceTest, and SparseBitmapTest.
Definition at line 239 of file TestBase.cpp.
Referenced by SparseBitmapTest::testCaseTearDown().
| void TestBase::notifyTrace | ( | std::string | source, |
|---|---|---|---|
| TraceLevel | level, | ||
| std::string | message | ||
| ) | [virtual, inherited] |
| TraceLevel TestBase::getSourceTraceLevel | ( | std::string | source | ) | [virtual, inherited] |
|---|
| void TraceSource::initTraceSource | ( | SharedTraceTarget | pTraceTarget, |
|---|---|---|---|
| std::string | name | ||
| ) | [virtual, inherited] |
| void TraceSource::trace | ( | TraceLevel | level, |
|---|---|---|---|
| std::string | message | ||
| ) | const [inherited] |
| bool TraceSource::isTracing | ( | | ) | const [inline, inherited] | | --------------------------- | - | | - | --------------------------- |
| bool TraceSource::isTracingLevel | ( | TraceLevel | level | ) | const [inline, inherited] |
|---|
| TraceTarget& TraceSource::getTraceTarget | ( | | ) | const [inline, inherited] | | ----------------------------------------------------------------- | - | | - | --------------------------- |
| std::string TraceSource::getTraceSourceName | ( | | ) | const [inline, inherited] | | ------------------------------------------- | - | | - | --------------------------- |
| void TraceSource::setTraceSourceName | ( | std::string const & | n | ) | [inline, inherited] |
|---|
Sets the name of this source.
Useful to construct dynamic names for fine-grained filtering.
Definition at line 136 of file TraceSource.h.
00137 { 00138 name = n; 00139 }
| TraceLevel TraceSource::getMinimumTraceLevel | ( | | ) | const [inline, inherited] | | ------------------------------------------------------------------------------------------------------ | - | | - | --------------------------- |
| void TraceSource::disableTracing | ( | | ) | [inherited] | | -------------------------------- | - | | - | ------------- |
Member Data Documentation
Configuration parameters.
The reason this is static is so that no constructor parameters (which burden virtual bases) are needed.
Definition at line 155 of file TestBase.h.
Referenced by TestBase::afterTestCase(), TestBase::beforeTestCase(), BTreeTxnTest::BTreeTxnTest(), CacheTestBase::CacheTestBase(), BackupRestoreTest::createSnapshotData(), DatabaseTest::DatabaseTest(), TestOptionsTest::extra(), DatabaseTest::loadDatabase(), SparseBitmapTest::openStorage(), PagingTestBase::PagingTestBase(), ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest(), RandomAccessFileDeviceTest::RandomAccessFileDeviceTest(), TestBase::readParams(), SegStorageTestBase::SegStorageTestBase(), TestOptionsTest::test1(), TestOptionsTest::test2(), BackupRestoreTest::testBackupCleanup(), TestBase::TestBase(), BTreeTxnTest::testCaseSetUp(), BTreeTxnTest::testCheckpoint(), DatabaseTest::testCreateEmpty(), DatabaseTest::testForceTxns(), BackupRestoreTest::testHeaderBackupRestore(), SegPageEntryIterTest::testIter(), SegStreamTest::testRead(), BTreeTxnTest::testTxns(), SegStreamTest::testWrite(), ThreadedTestBase::ThreadedTestBase(), and TestBase::~TestBase().
The documentation for this class was generated from the following file:
- /home/pub/open/dev/fennel/calctest/CalcCastTest.cpp
