summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2013-04-02 22:57:25 +0100
committerRoger Leigh <rleigh@debian.org>2013-04-02 22:57:25 +0100
commitdffe4c5711e0624f1bfe72e5da1eb89775d9ebc7 (patch)
tree8b18450cdfb5449df36d12ac640a497ae4d1ea7e /lib
parent4dc94f89285bec05b290e5ecc6d1e0bfa4a899c4 (diff)
downloadschroot-dffe4c5711e0624f1bfe72e5da1eb89775d9ebc7.tar.gz
lib: Move libtest to lib
Diffstat (limited to 'lib')
-rw-r--r--lib/test/Makefile.am26
-rw-r--r--lib/test/testmain.cc47
2 files changed, 73 insertions, 0 deletions
diff --git a/lib/test/Makefile.am b/lib/test/Makefile.am
new file mode 100644
index 00000000..8de09f20
--- /dev/null
+++ b/lib/test/Makefile.am
@@ -0,0 +1,26 @@
+# Copyright © 2004-2013 Roger Leigh <rleigh@debian.org>
+#
+# schroot 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 3 of the License, or
+# (at your option) any later version.
+#
+# schroot 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. If not, see
+# <http://www.gnu.org/licenses/>.
+#
+#####################################################################
+
+if USE_UNIT_TESTS
+noinst_LTLIBRARIES += lib/test/libtest.la
+endif
+
+lib_test_libtest_la_SOURCES = \
+ lib/test/testmain.cc
+lib_test_libtest_la_LIBADD = $(top_builddir)/lib/sbuild/libsbuild.la $(CPPUNIT_LIBS)
+
diff --git a/lib/test/testmain.cc b/lib/test/testmain.cc
new file mode 100644
index 00000000..9f8ff5e1
--- /dev/null
+++ b/lib/test/testmain.cc
@@ -0,0 +1,47 @@
+/* Copyright © 2006-2013 Roger Leigh <rleigh@debian.org>
+ *
+ * schroot 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * schroot 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. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ *********************************************************************/
+
+#include <config.h>
+
+#include <sbuild/log.h>
+
+#include <cstdlib>
+
+#include <cppunit/ui/text/TestRunner.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+using namespace CppUnit;
+
+int
+main()
+{
+#ifdef SBUILD_DEBUG
+ sbuild::debug_log_level = sbuild::DEBUG_NOTICE;
+#else
+ sbuild::debug_log_level = sbuild::DEBUG_NONE;
+#endif
+
+ TextUi::TestRunner runner;
+
+ TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
+ runner.addTest(registry.makeTest());
+
+ bool ok = runner.run();
+
+ return (ok) ? EXIT_SUCCESS : EXIT_FAILURE;
+}