TestCPU.cpp

Go to the documentation of this file.
00001 
00002 //
00003 // This source file is a part of ParCompMark
00004 // Parallel Compositing Benchmark Framework
00005 //
00006 // for latest info see http://parcompmark.sourceforge.net
00007 
00008 //
00009 // Copyright (C) 2006 IT2 ParCompMark Dev. Team
00010 // 
00011 // This program is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License
00013 // as published by the Free Software Foundation; either version 2
00014 // of the License, or (at your option) any later version.
00015 // 
00016 // This program is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 // GNU General Public License for more details.
00020 // 
00021 // You should have received a copy of the GNU General Public License
00022 // along with this program; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 
00027 
00028 #include "../include/TestCPU.h"
00029 //#include "tinyxml/tinyxml.h"
00030 
00031 namespace ParCompMarkTest
00032 {
00033 
00034   void TestCPU::setUp()
00035   {
00036 
00037         std::string currentLogFile = "logs/TestCPU.log";
00038 
00039         if(Logger::getInstance() && Logger::getInstance()->getLogFileName() != currentLogFile)
00040          Logger::destroyInstance();
00041 
00042         if(!FileSystemManager::getInstance())
00043         {
00044          FileSystemManager::createInstance();
00045          FileSystemManager::getInstance()->setAppDirectory("./");
00046          FileSystemManager::getInstance()->initialize();
00047         }
00048 
00049         if(!Logger::getInstance())
00050         {
00051          Logger::createInstance();
00052          Logger::getInstance()->setLogFileName(currentLogFile);
00053          Logger::getInstance()->initialize();
00054         }
00055 
00056   }
00057 
00058  /*----------------------------------------------------------------------*/
00059 
00060   void TestCPU::tearDown()
00061   {
00062   }
00063 
00064  /*----------------------------------------------------------------------*/
00065 
00066   //
00067   // Constructor & destructor tests
00068   //
00069 
00070   void TestCPU::test_constructor_cstd__string_cOutputNode__NodeType()
00071   {
00072 
00073         /*
00074          * You have to verify the following:
00075          * 
00076          * Creates CPU node.
00077          */
00078 
00079         CPPUNIT_FAIL("Implement this test!");
00080   }
00081 
00082  /*----------------------------------------------------------------------*/
00083 
00084   void TestCPU::test_destructor()
00085   {
00086 
00087         CPPUNIT_FAIL("Implement this test!");
00088   }
00089 
00090  /*----------------------------------------------------------------------*/
00091 
00092   //
00093   // Class method tests
00094   //
00095 
00096   void TestCPU::test_parseXML_TiXmlElement_p()
00097   {
00098 
00099         /*
00100          * You have to verify the following:
00101          * 
00102          * Creates a CPU class instance based on xml
00103          */
00104 
00105         //TODO: test with other CPU with more parameters
00106 
00107         std::
00108          string
00109          xml
00110          ("<info:CPU id=\"0\"><info:param name=\"vendor-id\" value=\"GenuineIntel\"/><info:param name=\"flags\" value=\"fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni monitor ds_cpl cid xtpr\"/><info:param name=\"bogomips\" value=\"6002.94\"/></info:CPU>");
00111 
00112         TiXmlDocument tiDocument;
00113 
00114         tiDocument.Parse(xml.c_str());
00115 
00116         TiXmlElement *tiCPU = tiDocument.RootElement();
00117 
00118         CPU::Pointer myCPU = CPU::parseXML(tiCPU);
00119 
00120         CPPUNIT_ASSERT(myCPU->mVendor.compare("GenuineIntel") == 0);
00121         CPPUNIT_ASSERT(myCPU->mFlags.
00122                    compare
00123                    ("fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni monitor ds_cpl cid xtpr")
00124                    == 0);
00125         CPPUNIT_ASSERT(::fabs(myCPU->mBogomips - 6002.94) < 1e-2);
00126 
00127   }
00128 
00129  /*----------------------------------------------------------------------*/
00130 
00131   //
00132   // Method tests
00133   //
00134 
00135   void TestCPU::test_refreshData()
00136   {
00137 
00138         /*
00139          * You have to verify the following:
00140          * 
00141          * Refresh CPU datas.
00142          */
00143 
00144         CPPUNIT_FAIL("Implement this test!");
00145   }
00146 
00147  /*----------------------------------------------------------------------*/
00148 
00149   // To register the suite we add:
00151   CPPUNIT_TEST_SUITE_REGISTRATION(TestCPU);
00152 }