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 _TESTRBU_H 00020 #define _TESTRBU_H 00021 00022 #include "smbios/compat.h" 00023 00024 #include <cppunit/extensions/HelperMacros.h> 00025 #include <string> 00026 00027 #include "smbios/DellRbu.h" 00028 #include "XmlUtils.h" 00029 00030 #include "outputctl.h" 00031 00032 extern int global_argc; 00033 extern char ** global_argv; 00034 00035 class testRbu : public CppUnit::TestFixture 00036 { 00037 protected: 00038 virtual std::string getCppunitTopDirectory() 00039 { 00040 //return TEST_DIR; 00041 return global_argv[1]; 00042 } 00043 virtual std::string getWritableDirectory() 00044 { 00045 //return DEFAULT_TEST_DIR; 00046 return global_argv[2]; 00047 }; 00048 virtual std::string getTestName() 00049 { 00050 //return TEST_DIR; 00051 return global_argv[3]; 00052 } 00053 virtual std::string getTestDirectory() 00054 { 00055 //return DEFAULT_TEST_DIR; 00056 return global_argv[4]; 00057 }; 00058 virtual std::string getXmlFile() 00059 { 00060 return "/../doc/smbios23.xml"; 00061 }; 00062 00063 std::string getTestInputString( std::string toFind, std::string section="systemInfo" ); 00064 00065 // parser owns all XML entities. When it is deleted, everything 00066 // goes with it. 00067 XML_NAMESPACE DOMBuilder *parser; 00068 00069 // The doc is owned by the parser. We do not have to clean it up 00070 // it is deleted when the parser is released. We keep a ref 00071 // here for speed purposes 00072 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc; 00073 00074 00075 public: 00076 virtual void setUp(); 00077 virtual void tearDown(); 00078 00079 // helper functions 00080 std::auto_ptr<rbu::IRbuHdr> checkHdrInfo(std::string name); 00081 00082 // table tests 00083 void testRbuBasic(); 00084 void testRbuBadData(); 00085 void testRbuOldVerCompare(); 00086 void testRbuNewVerCompare(); 00087 void testRbuNewVerSplit(); 00088 void testRbuOutput(); 00089 00090 // make sure to put this at the end... 00091 CPPUNIT_TEST_SUITE (testRbu); 00092 00093 CPPUNIT_TEST (testRbuBasic); 00094 CPPUNIT_TEST (testRbuBadData); 00095 CPPUNIT_TEST (testRbuOldVerCompare); 00096 CPPUNIT_TEST (testRbuNewVerCompare); 00097 CPPUNIT_TEST (testRbuNewVerSplit); 00098 CPPUNIT_TEST (testRbuOutput); 00099 00100 CPPUNIT_TEST_SUITE_END (); 00101 }; 00102 00103 #endif