diff options
author | Daniel Burrows <Daniel Burrows Daniel_Burrows@alumni.brown.edu> | 2010-05-16 21:30:47 -0700 |
---|---|---|
committer | Daniel Burrows <Daniel Burrows Daniel_Burrows@alumni.brown.edu> | 2010-05-16 21:30:47 -0700 |
commit | e5cd66479d3412d825676c9d2725c87591584251 (patch) | |
tree | 165e38c04925236b137d21bd16926598c5bdbefc /tests/cppunit_test_main.cc | |
parent | 2e6f25716145d14d541f40cb9efbb9e42aad1f6c (diff) | |
download | aptitude-e5cd66479d3412d825676c9d2725c87591584251.tar.gz |
Imported Upstream version 0.6.2
Diffstat (limited to 'tests/cppunit_test_main.cc')
-rw-r--r-- | tests/cppunit_test_main.cc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/cppunit_test_main.cc b/tests/cppunit_test_main.cc new file mode 100644 index 00000000..6bc9cea0 --- /dev/null +++ b/tests/cppunit_test_main.cc @@ -0,0 +1,59 @@ +// Main test program for the generic aptitude code. +// +// Copyright (C) 2005, 2009-2010 Daniel Burrows +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; see the file COPYING. If not, write to +// the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +#include <cppunit/extensions/TestFactoryRegistry.h> +#include <cppunit/ui/text/TestRunner.h> + +#include <log4cxx/basicconfigurator.h> +#include <log4cxx/level.h> +#include <log4cxx/logger.h> + +#include <stdio.h> +#include <string.h> + +int main(int argc, char **argv) +{ + bool debug = false; + for(int i = 1; i < argc; ++i) + { + if(!strcmp(argv[i], "--debug")) + debug = true; + else + { + fprintf(stderr, "Invalid argument \"%s\".", argv[i]); + return -1; + } + } + + if(debug) + log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getTrace()); + else + log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getWarn()); + log4cxx::BasicConfigurator::configure(); + + CppUnit::TextTestRunner runner; + CppUnit::TestFactoryRegistry ®istry = + CppUnit::TestFactoryRegistry::getRegistry(); + + runner.addTest(registry.makeTest()); + + bool wasSuccessful = runner.run("", false); + + return wasSuccessful ? 0 : -255; +} |