00001 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c: 00002 /* 00003 * Copyright (C) 2005 Dell Inc. 00004 * by Michael Brown <Michael_E_Brown@dell.com> 00005 * Licensed under the Open Software License version 2.1 00006 * 00007 * Alternatively, you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published 00009 * by the Free Software Foundation; either version 2 of the License, 00010 * or (at your option) any later version. 00011 00012 * This program is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00015 * See the GNU General Public License for more details. 00016 */ 00017 00018 00019 #ifndef _TESTPLATFORM_H 00020 #define _TESTPLATFORM_H 00021 00022 #include "smbios/compat.h" 00023 00024 #include <cppunit/extensions/HelperMacros.h> 00025 #include <typeinfo> 00026 #include <string> 00027 00028 #include "smbios/ISmbios.h" 00029 #include "smbios/ICmosRW.h" 00030 #include "smbios/IToken.h" 00031 #include "smbios/SystemInfo.h" 00032 00033 #include "XmlUtils.h" 00034 00035 #include "outputctl.h" 00036 00037 extern int global_argc; 00038 extern char ** global_argv; 00039 00040 class testPlatform : public CppUnit::TestFixture 00041 { 00042 protected: 00043 virtual std::string getCppunitTopDirectory() 00044 { 00045 //return TEST_DIR; 00046 return global_argv[1]; 00047 } 00048 virtual std::string getWritableDirectory() 00049 { 00050 //return DEFAULT_TEST_DIR; 00051 return global_argv[2]; 00052 }; 00053 00054 virtual std::string getTestName() 00055 { 00056 //return TEST_DIR; 00057 return global_argv[3]; 00058 } 00059 virtual std::string getTestDirectory() 00060 { 00061 //return DEFAULT_TEST_DIR; 00062 return global_argv[4]; 00063 }; 00064 00065 std::string getTestInputString( std::string toFind, std::string section="systemInfo" ); 00066 00067 void checkSkipTest( std::string testName); 00068 00069 // parser owns all XML entities. When it is deleted, everything 00070 // goes with it. 00071 XML_NAMESPACE DOMBuilder *parser; 00072 00073 // The doc is owned by the parser. We do not have to clean it up 00074 // it is deleted when the parser is released. We keep a ref 00075 // here for speed purposes 00076 XML_NAMESPACE DOMDocument *doc; 00077 00078 public: 00079 virtual void setUp(); 00080 virtual void tearDown(); 00081 00082 // item tests 00083 void testGetBoundaries(); 00084 00085 // cmos token tests 00086 void testCmosChecksum(); 00087 void testCmosWriting(); 00088 00089 // systeminfo tests 00090 void testSystemInfo(); 00091 00092 // testInput.xml tests 00093 void testIdByte(); 00094 void testServiceTag(); 00095 void testServiceTagWriting(); 00096 void testAssetTag(); 00097 void testSystemName(); 00098 void testBiosVersion(); 00099 void testIsDell(); 00100 void testVariousAccessors(); 00101 void testOutOfBounds(); 00102 void testConstructionOffset1(); 00103 void testConstructionOffset2(); 00104 00105 // other 00106 void testStateBytes(); 00107 void testUpBoot(); 00108 00109 // make sure to put this at the end... 00110 CPPUNIT_TEST_SUITE (testPlatform); 00111 00112 CPPUNIT_TEST (testCmosChecksum); 00113 CPPUNIT_TEST (testCmosWriting); 00114 00115 CPPUNIT_TEST (testSystemInfo); 00116 00117 CPPUNIT_TEST (testIdByte); 00118 CPPUNIT_TEST (testServiceTag); 00119 CPPUNIT_TEST (testServiceTagWriting); 00120 CPPUNIT_TEST (testAssetTag); 00121 CPPUNIT_TEST (testSystemName); 00122 00123 00124 00125 CPPUNIT_TEST (testBiosVersion); 00126 CPPUNIT_TEST (testIsDell); 00127 CPPUNIT_TEST (testVariousAccessors); 00128 CPPUNIT_TEST (testOutOfBounds); 00129 CPPUNIT_TEST (testConstructionOffset1); 00130 CPPUNIT_TEST (testConstructionOffset2); 00131 00132 CPPUNIT_TEST (testStateBytes); 00133 CPPUNIT_TEST (testUpBoot); 00134 00135 CPPUNIT_TEST_SUITE_END (); 00136 }; 00137 00138 #endif