TestMain.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 
00025 
00028 
00029 //
00031 //
00032 
00033 // CppUnit includes
00034 #include <cppunit/extensions/TestFactoryRegistry.h>
00035 #include <cppunit/ui/text/TestRunner.h>
00036 #include <cppunit/CompilerOutputter.h>
00037 
00038 //
00039 // Test suite includes
00040 //
00041 
00042 #include "../include/TestNetwork.h"
00043 #include "../include/TestThread.h"
00044 #include "../include/TestApplication.h"
00045 #include "../include/TestLogger.h"
00046 #include "../include/TestException.h"
00047 #include "../include/TestSingleton.h"
00048 #include "../include/TestPointer.h"
00049 #include "../include/TestLock.h"
00050 #include "../include/TestDummyLock.h"
00051 #include "../include/TestMutex.h"
00052 #include "../include/TestHandleClient.h"
00053 #include "../include/TestCluster.h"
00054 #include "../include/TestHost.h"
00055 #include "../include/TestName.h"
00056 #include "../include/TestDynLoad.h"
00057 #include "../include/TestBuffer.h"
00058 #include "../include/TestContext.h"
00059 #include "../include/TestNode.h"
00060 #include "../include/TestProcess.h"
00061 #include "../include/TestGLXGLContext.h"
00062 #include "../include/TestGLXRenderWindow.h"
00063 #include "../include/TestXDisplay.h"
00064 #include "../include/TestSqVM.h"
00065 #include "../include/TestOutputNode.h"
00066 #include "../include/TestContainer.h"
00067 #include "../include/TestTimer.h"
00068 #include "../include/TestHostInfo.h"
00069 #include "../include/TestOpenGLRenderingEngine.h"
00070 #include "../include/TestFileSystemManager.h"
00071 #include "../include/TestCPU.h"
00072 #include "../include/TestGPU.h"
00073 #include "../include/TestStringConverter.h"
00074 #include "../include/TestConfigOptions.h"
00075 #include "../include/TestNetServer.h"
00076 #include "../include/TestNetClient.h"
00077 #include "../include/TestClient.h"
00078 #include "../include/TestPluginManager.h"
00079 #include "../include/TestPlugin.h"
00080 #include "../include/TestRendererPlugin.h"
00081 #include "../include/TestRenderer.h"
00082 #include "../include/TestOpenGLExtensionLoader.h"
00083 
00084 
00085 // Check for QtTestRunner compatibility
00086 #if defined(HAVE_QT3_QAPPLICATION_H) && defined(HAVE_LIBQTTESTRUNNER)
00087 #define WITH_QTTESTRUNNER 1     
00088 #endif
00089         
00090 #ifdef WITH_QTTESTRUNNER
00091 // Qt and GLX compatibility hack
00092 #undef CursorShape
00093 #undef None
00094 #undef KeyPress
00095 #undef KeyRelease
00096 #undef FocusIn
00097 #undef FocusOut
00098         
00099 // QtTestRunner includes
00100 #include <qt3/qapplication.h>
00101 #include <cppunit/ui/qt/TestRunner.h>
00102 #endif
00103 
00104 using namespace ParCompMarkTest;
00105 
00109 int textRunner() {
00110     CppUnit::TextUi::TestRunner runner;
00111 
00112     // First, we retreive the instance of the TestFactoryRegistry
00113     CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
00114 
00115     // Then, we obtain and add a new TestSuite  created by the
00116     // TestFactoryRegistry  that contains all the test suite registered
00117     // using CPPUNIT_TEST_SUITE_REGISTRATION()
00118     runner.addTest(registry.makeTest());
00119                 
00120     // Set compiler readable output
00121     runner.setOutputter( new CppUnit::CompilerOutputter(&runner.result(), std::cout ) );
00122 
00123     // Run the tests
00124     return runner.run() ? 0 : 1;
00125 }
00126 
00130 #ifdef WITH_QTTESTRUNNER
00131 int guiRunner(int argc, char **argv) {
00132 
00133         // Create Qt application and test runner
00134         QApplication app(argc, argv);
00135         CppUnit::QtTestRunner runner;
00136 
00137     // First, we retreive the instance of the TestFactoryRegistry
00138     CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
00139 
00140     // Then, we obtain and add a new TestSuite  created by the
00141     // TestFactoryRegistry  that contains all the test suite registered
00142     // using CPPUNIT_TEST_SUITE_REGISTRATION()
00143     runner.addTest(registry.makeTest());
00144                 
00145     // Run the tests
00146     runner.run(true);
00147     
00148     return 0;
00149 }
00150 #endif
00151                 
00204 int main(int argc, char **argv)
00205 {
00206 #ifdef WITH_QTTESTRUNNER
00207         // Try to initialize multithreading for QtRunner
00208         XInitThreads();
00209         
00210         if(argc > 1 && !strcmp(argv[1], "--gui"))
00211                 return guiRunner(argc, argv);
00212         else
00213 #endif
00214                 return textRunner();
00215 }
00216