1x90MiscTests.cpp

Go to the documentation of this file.
00001 // Template for a test suite.
00002 #include <config.h>
00003 
00004 #include <cppunit/extensions/HelperMacros.h>
00005 #include <cppunit/Asserter.h>
00006 #include "Asserts.h"
00007 #include "CCAENV1x90.h"
00008 #include "DesignByContract.h"
00009 #include <iostream>
00010 
00011 #ifdef HAVE_STD_NAMESPACE
00012 using namespace std;
00013 #endif
00014 
00015 extern long ModuleBase;
00016 
00017 class MiscTests : public CppUnit::TestFixture {
00018   CPPUNIT_TEST_SUITE(MiscTests);
00019   CPPUNIT_TEST(ChipIdTest);
00020   CPPUNIT_TEST(FWDTimeTest);
00021   CPPUNIT_TEST(ErrorsTest);
00022   CPPUNIT_TEST_SUITE_END();
00023 
00024 
00025 private:
00026   CCAENV1x90* m_pModule;
00027 
00028 public:
00029   // Construct a module in powered up condition:
00030 
00031   void setUp() {
00032     m_pModule = new CCAENV1x90(1, 0, ModuleBase);
00033     m_pModule->Reset();
00034   }
00035   // Delete the module to prevent resource leaks.
00036 
00037   void tearDown() {
00038     delete m_pModule;
00039   }
00040 protected:
00041   void ChipIdTest();
00042   void FWDTimeTest();
00043   void ErrorsTest();
00044  
00045 };
00046 
00047 CPPUNIT_TEST_SUITE_REGISTRATION(MiscTests);
00048 
00049 // Check that the chip id is of the proper form.
00050 void
00051 MiscTests::ChipIdTest()
00052 {
00053   unsigned short nChips = m_pModule->getChipCount();
00054 
00055   for(unsigned short i; i < nChips; i++) {
00056     unsigned int Id = m_pModule->GetChipId(i);
00057     EQ(static_cast<unsigned int>(0x8470da0), (0xfffffff0 & Id));
00058   }
00059 }
00060 // Firmware date time... just print it out, there's not
00061 // much we can do to verify.  Assume the year of the firmware
00062 // is in the 21'st century.
00063 
00064 void 
00065 MiscTests::FWDTimeTest()
00066 {
00067   unsigned short rev, day, mon, year;
00068 
00069   m_pModule->GetuCFirmwareInfo(rev, day, mon, year);
00070 
00071   cerr << "\n Revision: " << hex << rev << dec;
00072   cerr << " Written "     << mon << '/' << day << '/' << year+2000 << endl; 
00073 }
00074 
00075 // Test ability to get the error mask.  After init, I think this
00076 // should have a 0 value:
00077 
00078 void
00079 MiscTests::ErrorsTest()
00080 {
00081   unsigned short nChips = m_pModule->getChipCount();
00082   for(unsigned short i = 0; i < nChips; i++) {
00083     unsigned mask = m_pModule->GetChipErrors(i);
00084     EQ(0U, mask);
00085   }
00086 }

Generated on Wed Sep 17 08:38:09 2008 for NSCL Device support. by  doxygen 1.5.1