Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

main.cpp

Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  * vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:cindent:textwidth=0:
00003  *
00004  * Copyright (C) 2005 Dell Inc.
00005  *  by Michael Brown <Michael_E_Brown@dell.com>
00006  * Licensed under the Open Software License version 2.1 
00007  * 
00008  * Alternatively, you can redistribute it and/or modify 
00009  * it under the terms of the GNU General Public License as published 
00010  * by the Free Software Foundation; either version 2 of the License, 
00011  * or (at your option) any later version.
00012 
00013  * This program is distributed in the hope that it will be useful, but 
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of 
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
00016  * See the GNU General Public License for more details.
00017  */
00018 
00019 // compat header should always be first header if including system headers
00020 #include "smbios/compat.h"
00021 
00022 #include <string>
00023 #include <string.h>   // strncat, strndup, and friends
00024 #include <fstream>
00025 #include <iostream>
00026 
00027 #include <cppunit/extensions/TestFactoryRegistry.h>
00028 #include <cppunit/ui/text/TestRunner.h>
00029 #include <cppunit/XmlOutputter.h>
00030 
00031 using namespace std;
00032 
00033 int global_argc;
00034 char ** global_argv;
00035 std::string global_programDirname;
00036 std::string global_writeDirectory;
00037 std::string global_testName;
00038 std::string global_testDirectory;
00039 int global_DebugLevel = 9;
00040 
00041 int
00042 main (int argc, char **argv)
00043 {
00044     global_argc = argc;
00045     global_argv = argv;
00046 
00047     if( argc < 5 )
00048     {
00049         cout <<
00050             "\nusage:\n"
00051             "   <program> <cppunit_directory> <writeable_directory>\n"
00052             "   Where both directory names are required arguments.\n"
00053             "      cppunit_directory  - location where platform/ directory is located.\n"
00054             "      writeable_directory- location of a writeable dir for unit test.\n"
00055             "      test_name          - name of test.\n"
00056             "      test_dir           - location of unit test data files.\n"
00057             "\n"
00058         << endl;
00059         exit(1);
00060     }
00061 
00062     // set up this global var. enough stuff uses it to make it a global...
00063     global_programDirname = argv[1];
00064     global_writeDirectory = argv[2];
00065     global_testName = argv[3];
00066     global_testDirectory = argv[4];
00067 
00068     std::ofstream outputFile("testResults.xml");
00069     CppUnit::TextUi::TestRunner runner;
00070 
00071     CppUnit::TestFactoryRegistry & registry =
00072         CppUnit::TestFactoryRegistry::getRegistry ();
00073 
00074     CppUnit::XmlOutputter* outputter = new CppUnit::XmlOutputter( &runner.result(), outputFile );
00075 
00076     runner.setOutputter(outputter);
00077     runner.addTest (registry.makeTest ());
00078 
00079     bool wasSuccessful = runner.run ("",        //std::string testName ="",
00080                                      false, //bool doWait = false, (lets user press <return> after tests)
00081                                      true,  //bool doPrintResult = true,
00082                                      false  //bool doPrintProgress = true );  // prints dots "."
00083                                     );
00084 
00085     outputFile.close();
00086 
00087     // need to use _reverse_ logic here because the shell is backwards!
00088     return !wasSuccessful;
00089 }

Generated on Wed Apr 11 16:25:10 2007 for SMBIOS Library by doxygen 1.3.5