From 378b0bca03431a3736b4324b133136aebf3053a0 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 14 Nov 2013 13:20:15 +0100 Subject: [PATCH 1/3] Add test script for Jenkins. Refs #4635 --- test/jenkins/README | 1 + test/jenkins/bootstrap-vm.sh | 14 ++++++++++++++ test/jenkins/run-tests.py | 34 ++++++++++++++++++++++++++++++++++ test/jenkins/v1.test | 3 +++ 4 files changed, 52 insertions(+) create mode 100644 test/jenkins/README create mode 100755 test/jenkins/bootstrap-vm.sh create mode 100755 test/jenkins/run-tests.py create mode 100755 test/jenkins/v1.test diff --git a/test/jenkins/README b/test/jenkins/README new file mode 100644 index 000000000..23495e8f2 --- /dev/null +++ b/test/jenkins/README @@ -0,0 +1 @@ +These scripts are used by build.icinga.org to set up a test VM. diff --git a/test/jenkins/bootstrap-vm.sh b/test/jenkins/bootstrap-vm.sh new file mode 100755 index 000000000..30d8f5d31 --- /dev/null +++ b/test/jenkins/bootstrap-vm.sh @@ -0,0 +1,14 @@ +#!/bin/sh +if [ "$1" != "run-by-jenkins" ]; then + echo "This script should not be run manually." + exit 1 +fi + +echo "10.10.27.1 packages.icinga.org" >> /etc/hosts + +groupadd vagrant + +rmdir /vagrant && ln -s /root/icinga2 /vagrant +puppet apply --modulepath=/vagrant/.vagrant-puppet/modules /vagrant/.vagrant-puppet/manifests/default.pp + +exit 0 diff --git a/test/jenkins/run-tests.py b/test/jenkins/run-tests.py new file mode 100755 index 000000000..e96395553 --- /dev/null +++ b/test/jenkins/run-tests.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +import sys +from xml.dom.minidom import getDOMImplementation +from subprocess import Popen, PIPE + +impl = getDOMImplementation() +result = impl.createDocument(None, "testsuite", None) +testsuite = result.documentElement + +for fn in sys.argv[1:]: + process = Popen(["./" + fn], stdout=PIPE, stderr=PIPE) + (stdoutdata, stderrdata) = process.communicate() + + testcase = result.createElement("testcase") + testcase.setAttribute("classname", "vm") + testcase.setAttribute("name", fn) + + systemout = result.createElement("system-out") + systemout.appendChild(result.createTextNode(stdoutdata)) + testcase.appendChild(systemout) + + systemerr = result.createElement("system-err") + systemerr.appendChild(result.createTextNode(stderrdata)) + testcase.appendChild(systemerr) + + if process.returncode != 0: + failure = result.createElement("failure") + failure.setAttribute("type", "returncode") + failure.appendChild(result.createTextNode("code: " + str(process.returncode))) + testcase.appendChild(failure) + + testsuite.appendChild(testcase) + +print result.toxml() diff --git a/test/jenkins/v1.test b/test/jenkins/v1.test new file mode 100755 index 000000000..f0c0fcd40 --- /dev/null +++ b/test/jenkins/v1.test @@ -0,0 +1,3 @@ +#!/bin/sh +echo "Hello World!" +exit 1 From e368c430817c3c8b4fc109d17c482b89fcfaddae Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 15 Nov 2013 09:04:29 +0100 Subject: [PATCH 2/3] Remove unused file. Refs #4635 --- test/run-tests.sh | 2 -- 1 file changed, 2 deletions(-) delete mode 100755 test/run-tests.sh diff --git a/test/run-tests.sh b/test/run-tests.sh deleted file mode 100755 index c9379c24d..000000000 --- a/test/run-tests.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec ./icinga2_test --log_format=XML --log_sink=results.xml --log_level=all --report_level=no From 4ed798385d4ca6a5a69b5e55938102274d00dee6 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 15 Nov 2013 09:04:39 +0100 Subject: [PATCH 3/3] Improve bug messages. Refs #4635 --- CMakeLists.txt | 2 +- lib/base/application.cpp | 40 +++++++++++++++++++++++++++++++++------- lib/base/application.h | 1 + 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b3f8e632..2da2eca0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ check_function_exists(pipe2 HAVE_PIPE2) check_library_exists(crypto BIO_f_zlib "" HAVE_BIOZLIB) include(GNUInstallDirs) -configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) +configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ESCAPE_QUOTES) install( FILES README COPYING COPYING.Exceptions AUTHORS ChangeLog INSTALL NEWS diff --git a/lib/base/application.cpp b/lib/base/application.cpp index 548b7ade7..f6220be8e 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -311,17 +311,32 @@ bool Application::IsDebugging(void) return m_Debugging; } +/** + * Display version information. + */ +void Application::DisplayVersionMessage(void) +{ + std::cerr << "***" << std::endl + << "* Application version: " << GetVersion() << std::endl + << "* Installation root: " << GetPrefixDir() << std::endl + << "* Local state directory: " << GetLocalStateDir() << std::endl + << "* Package data directory: " << GetPkgDataDir() << std::endl + << "* State path: " << GetStatePath() << std::endl + << "* PID path: " << GetPidPath() << std::endl + << "* Application type: " << GetApplicationType() << std::endl + << "***" << std::endl; +} + /** * Displays a message that tells users what to do when they encounter a bug. */ void Application::DisplayBugMessage(void) { std::cerr << "***" << std::endl - << "*** This would indicate a runtime problem or configuration error. If you believe this is a bug in Icinga 2" << std::endl - << "*** please submit a bug report at https://dev.icinga.org/ and include this stack trace as well as any other" << std::endl - << "*** information that might be useful in order to reproduce this problem." << std::endl - << "***" << std::endl - << std::endl; + << "* This would indicate a runtime problem or configuration error. If you believe this is a bug in Icinga 2" << std::endl + << "* please submit a bug report at https://dev.icinga.org/ and include this stack trace as well as any other" << std::endl + << "* information that might be useful in order to reproduce this problem." << std::endl + << "***" << std::endl; } #ifndef _WIN32 @@ -360,7 +375,10 @@ void Application::SigAbrtHandler(int) sigaction(SIGABRT, &sa, NULL); #endif /* _WIN32 */ - std::cerr << "Caught SIGABRT." << std::endl; + std::cerr << "Caught SIGABRT." << std::endl + << std::endl; + + DisplayVersionMessage(); StackTrace trace; std::cerr << "Stacktrace:" << std::endl; @@ -399,6 +417,11 @@ void Application::ExceptionHandler(void) sigaction(SIGABRT, &sa, NULL); #endif /* _WIN32 */ + std::cerr << "Caught unhandled exception." << std::endl + << std::endl; + + DisplayVersionMessage(); + try { throw; } catch (const std::exception& ex) { @@ -415,7 +438,10 @@ void Application::ExceptionHandler(void) #ifdef _WIN32 LONG CALLBACK Application::SEHUnhandledExceptionFilter(PEXCEPTION_POINTERS exi) { - std::cerr << "Unhandled SEH exception." << std::endl; + DisplayVersionMessage(); + + std::cerr << "Caught unhandled SEH exception." << std::endl + << std::endl; StackTrace trace(exi); std::cerr << "Stacktrace:" << std::endl; diff --git a/lib/base/application.h b/lib/base/application.h index 0904ad28a..98e7ee1e5 100644 --- a/lib/base/application.h +++ b/lib/base/application.h @@ -122,6 +122,7 @@ private: static LONG WINAPI SEHUnhandledExceptionFilter(PEXCEPTION_POINTERS exi); #endif /* _WIN32 */ + static void DisplayVersionMessage(void); static void DisplayBugMessage(void); static void SigAbrtHandler(int signum);