- Timestamp:
- Jan 21, 2023 1:01:48 PM (2 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Makefile.kmk
r98171 r98172 1483 1483 # EEPROM device unit test requires cppunit 1484 1484 # 1485 ifdef VBOX_WITH_CPPUNIT_TESTCASES 1486 ifdef VBOX_WITH_E1000 1487 PROGRAMS += tstDevEEPROM 1488 tstDevEEPROM_TEMPLATE = VBOXCPPUNITEXE 1489 tstDevEEPROM_SOURCES = \ 1485 if defined(VBOX_WITH_E1000) && defined(VBOX_WITH_TESTCASES) 1486 PROGRAMS += tstDevEEPROM 1487 tstDevEEPROM_TEMPLATE = VBoxR3TstExe 1488 tstDevEEPROM_SOURCES = \ 1490 1489 Network/testcase/tstDevEEPROM.cpp \ 1491 1490 Network/DevEEPROM.cpp 1492 tstDevEEPROM_LIBS = \ 1493 $(TARGET_VBoxDD) 1494 1495 PROGRAMS += tstDevPhy 1496 tstDevPhy_TEMPLATE = VBOXCPPUNITEXE 1497 tstDevPhy_SOURCES = \ 1491 1492 PROGRAMS += tstDevPhy 1493 tstDevPhy_TEMPLATE = VBoxR3TstExe 1494 tstDevPhy_DEFS = PHY_UNIT_TEST 1495 tstDevPhy_SOURCES = \ 1498 1496 Network/testcase/tstDevPhy.cpp \ 1499 1497 Network/DevE1000Phy.cpp 1500 tstDevPhy_DEFS = PHY_UNIT_TEST1501 endif1502 1498 endif 1503 1499 -
trunk/src/VBox/Devices/Network/DevE1000Phy.cpp
r98171 r98172 51 51 /* Little helpers ************************************************************/ 52 52 #ifdef PHY_UNIT_TEST 53 # include <stdio.h> 54 # define PhyLog(a) printf a 55 #else /* PHY_UNIT_TEST */ 53 # ifdef CPP_UNIT 54 # include <stdio.h> 55 # define PhyLog(a) printf a 56 # else 57 # include <iprt/test.h> 58 # define PhyLogC99(...) RTTestIPrintf(RTTESTLVL_ALWAYS, __VA_ARGS__) 59 # define PhyLog(a) PhyLogC99 a 60 # endif 61 #else /* !PHY_UNIT_TEST */ 56 62 # define PhyLog(a) Log(a) 57 #endif /* PHY_UNIT_TEST */63 #endif /* !PHY_UNIT_TEST */ 58 64 59 65 #define REG(x) pPhy->au16Regs[x##_IDX] -
trunk/src/VBox/Devices/Network/DevEEPROM.cpp
r98103 r98172 43 43 void EEPROM93C46::init(const uint16_t *pu16Initial) 44 44 { 45 if ( pu16Initial ) {45 if ( pu16Initial ) 46 46 memcpy(this->m_au16Data, pu16Initial, sizeof(this->m_au16Data)); 47 } else {47 else 48 48 memset(this->m_au16Data, 0, sizeof(this->m_au16Data)); 49 }50 49 m_fWriteEnabled = false; 51 50 m_u32InternalWires = 0; -
trunk/src/VBox/Devices/Network/testcase/tstDevEEPROM.cpp
r98171 r98172 26 26 */ 27 27 28 #include <cppunit/ui/text/TestRunner.h> 29 #include <cppunit/extensions/HelperMacros.h> 30 28 29 /********************************************************************************************************************************* 30 * Header Files * 31 *********************************************************************************************************************************/ 32 #ifdef USE_CPPUNIT 33 # include <cppunit/ui/text/TestRunner.h> 34 # include <cppunit/extensions/HelperMacros.h> 35 #else 36 # include "CppUnitEmulation.h" 37 #endif 31 38 #include <VBox/vmm/pdmdev.h> 32 39 #include "../DevEEPROM.h" 33 40 34 static const uint16_t initialContent[] = { 41 42 /********************************************************************************************************************************* 43 * Global Variables * 44 *********************************************************************************************************************************/ 45 static const uint16_t g_abInitialContent[] = 46 { 35 47 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 36 48 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, … … 43 55 }; 44 56 57 45 58 /** 46 59 * Test fixture for 93C46-compatible EEPROM device emulation. 47 60 */ 48 class EEPROMTest : public CppUnit::TestFixture { 49 CPPUNIT_TEST_SUITE( EEPROMTest ); 61 class EEPROMTest 62 #ifdef USE_CPPUNIT 63 : public CppUnit::TestFixture 64 #endif 65 { 66 CPPUNIT_TEST_SUITE( tstDevEEPROM ); 50 67 51 68 CPPUNIT_TEST( testRead ); … … 106 123 { 107 124 eeprom = new EEPROM93C46; 108 eeprom->init( initialContent);125 eeprom->init(g_abInitialContent); 109 126 } 110 127 … … 116 133 void testSize() 117 134 { 118 CPPUNIT_ASSERT_EQUAL( sizeof( initialContent), (size_t)EEPROM93C46::SIZE );135 CPPUNIT_ASSERT_EQUAL( sizeof(g_abInitialContent), (size_t)EEPROM93C46::SIZE ); 119 136 } 120 137 … … 126 143 shiftOutBits(wordAddr, READ_ADDR_BITS); 127 144 128 CPPUNIT_ASSERT_EQUAL( initialContent[wordAddr], (uint16_t)wordAddr );129 CPPUNIT_ASSERT_EQUAL( initialContent[wordAddr], shiftInBits(DATA_BITS) );145 CPPUNIT_ASSERT_EQUAL( g_abInitialContent[wordAddr], (uint16_t)wordAddr ); 146 CPPUNIT_ASSERT_EQUAL( g_abInitialContent[wordAddr], shiftInBits(DATA_BITS) ); 130 147 standby(); 131 148 } … … 139 156 shiftOutBits(0, READ_ADDR_BITS); 140 157 for ( int wordAddr=0; wordAddr < EEPROM93C46::SIZE; wordAddr++ ) { 141 CPPUNIT_ASSERT_EQUAL( initialContent[wordAddr], shiftInBits(DATA_BITS) );158 CPPUNIT_ASSERT_EQUAL( g_abInitialContent[wordAddr], shiftInBits(DATA_BITS) ); 142 159 } 143 160 stop(); … … 520 537 } 521 538 522 // Create text test runner and run all tests.523 539 int main() 524 540 { 541 #ifdef USE_CPPUNIT 525 542 CppUnit::TextUi::TestRunner runner; 526 543 runner.addTest( EEPROMTest::suite() ); 527 544 return runner.run() ? 0 : 1; 528 } 529 545 #else 546 EEPROMTest Test; 547 return Test.run(); 548 #endif 549 } 550 -
trunk/src/VBox/Devices/Network/testcase/tstDevPhy.cpp
r98171 r98172 26 26 */ 27 27 28 #include <cppunit/ui/text/TestRunner.h> 29 #include <cppunit/extensions/HelperMacros.h> 28 29 /********************************************************************************************************************************* 30 * Header Files * 31 *********************************************************************************************************************************/ 32 #ifdef USE_CPPUNIT 33 # include <cppunit/ui/text/TestRunner.h> 34 # include <cppunit/extensions/HelperMacros.h> 35 #else 36 # include "CppUnitEmulation.h" 37 #endif 30 38 31 39 #include "../DevE1000Phy.h" 40 32 41 33 42 /** 34 43 * Test fixture for PHY MDIO/MDC interface emulation. 35 44 */ 36 class PhyTest : public CppUnit::TestFixture { 37 CPPUNIT_TEST_SUITE( PhyTest ); 45 class PhyTest 46 #ifdef USE_CPPUNIT 47 : public CppUnit::TestFixture 48 #endif 49 { 50 CPPUNIT_TEST_SUITE( tstDevPhy ); 38 51 39 52 CPPUNIT_TEST(testSize); … … 168 181 int main() 169 182 { 183 #ifdef USE_CPPUNIT 170 184 CppUnit::TextUi::TestRunner runner; 171 185 runner.addTest( PhyTest::suite() ); 172 186 return runner.run() ? 0 : 1; 187 #else 188 PhyTest Test; 189 return Test.run(); 190 #endif 173 191 } 174 192
Note:
See TracChangeset
for help on using the changeset viewer.