summaryrefslogtreecommitdiffstats
path: root/QA
diff options
context:
space:
mode:
Diffstat (limited to 'QA')
-rw-r--r--QA/Checker/IO.cpp82
-rw-r--r--QA/Checker/SConscript32
-rw-r--r--QA/Checker/checker.cpp131
-rwxr-xr-xQA/CrossDistributionTest/VagrantCrossDistributionTest.py90
-rw-r--r--QA/CrossDistributionTest/playbook.yml33
-rw-r--r--QA/SConscript6
-rw-r--r--QA/UnitTest/SConscript48
-rw-r--r--QA/UnitTest/template/FooTest.cpp20
8 files changed, 286 insertions, 156 deletions
diff --git a/QA/Checker/IO.cpp b/QA/Checker/IO.cpp
index ad9f877..4b43635 100644
--- a/QA/Checker/IO.cpp
+++ b/QA/Checker/IO.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -10,56 +10,56 @@
#include <iostream>
std::ostream& operator<<(std::ostream& os, const Swift::ByteArray& s) {
- std::ios::fmtflags oldFlags = os.flags();
- os << std::hex;
- for (Swift::ByteArray::const_iterator i = s.begin(); i != s.end(); ++i) {
- if (*i >= 32 && *i < 127) {
- os << *i;
- }
- else {
- os << "\\x" << static_cast<unsigned int>(static_cast<unsigned char>(*i));
- }
- }
- os << std::endl;
- os.flags(oldFlags);
- return os;
+ std::ios::fmtflags oldFlags = os.flags();
+ os << std::hex;
+ for (unsigned char i : s) {
+ if (i >= 32 && i < 127) {
+ os << i;
+ }
+ else {
+ os << "\\x" << static_cast<unsigned int>(static_cast<unsigned char>(i));
+ }
+ }
+ os << std::endl;
+ os.flags(oldFlags);
+ return os;
}
std::ostream& operator<<(std::ostream& os, const Swift::SafeByteArray& s) {
- std::ios::fmtflags oldFlags = os.flags();
- os << std::hex;
- for (Swift::SafeByteArray::const_iterator i = s.begin(); i != s.end(); ++i) {
- if (*i >= 32 && *i < 127) {
- os << *i;
- }
- else {
- os << "\\x" << static_cast<unsigned int>(static_cast<unsigned char>(*i));
- }
- }
- os << std::endl;
- os.flags(oldFlags);
- return os;
+ std::ios::fmtflags oldFlags = os.flags();
+ os << std::hex;
+ for (unsigned char i : s) {
+ if (i >= 32 && i < 127) {
+ os << i;
+ }
+ else {
+ os << "\\x" << static_cast<unsigned int>(static_cast<unsigned char>(i));
+ }
+ }
+ os << std::endl;
+ os.flags(oldFlags);
+ return os;
}
std::ostream& operator<<(std::ostream& os, const std::vector<int>& s) {
- for (std::vector<int>::const_iterator i = s.begin(); i != s.end(); ++i) {
- os << *i << " ";
- }
- os << std::endl;
- return os;
+ for (int i : s) {
+ os << i << " ";
+ }
+ os << std::endl;
+ return os;
}
std::ostream& operator<<(std::ostream& os, const std::vector<size_t>& s) {
- for (std::vector<size_t>::const_iterator i = s.begin(); i != s.end(); ++i) {
- os << *i << " ";
- }
- os << std::endl;
- return os;
+ for (size_t i : s) {
+ os << i << " ";
+ }
+ os << std::endl;
+ return os;
}
bool operator==(const Swift::ByteArray& a, const Swift::ByteArray& b) {
- if (a.size() != b.size()) {
- return false;
- }
- return std::equal(a.begin(), a.end(), b.begin());
+ if (a.size() != b.size()) {
+ return false;
+ }
+ return std::equal(a.begin(), a.end(), b.begin());
}
diff --git a/QA/Checker/SConscript b/QA/Checker/SConscript
index 13dec62..f8a3ce4 100644
--- a/QA/Checker/SConscript
+++ b/QA/Checker/SConscript
@@ -1,17 +1,23 @@
+import os
+
Import("env")
if env["TEST"] :
- if env["SCONS_STAGE"] == "flags" :
- env["CHECKER_FLAGS"] = {
- "CPPPATH" : ["#/3rdParty/HippoMocks"],
- "LIBS": ["Checker"],
- "LIBPATH": [Dir(".")],
- "LINKFLAGS": env["PLATFORM"] == "win32" and ["/SUBSYSTEM:CONSOLE"] or []
- }
+ if env["SCONS_STAGE"] == "flags" :
+ env["CHECKER_FLAGS"] = {
+ "LIBS": ["Checker"],
+ "LIBPATH": [Dir(".")],
+ "LINKFLAGS": env["PLATFORM"] == "win32" and ["/SUBSYSTEM:CONSOLE"] or []
+ }
+
+ if os.path.basename(env["CC"]) in ("clang", "gcc"):
+ env["CHECKER_FLAGS"]["CPPFLAGS"] = ["-isystem" + Dir("#/3rdParty/HippoMocks").abspath]
+ else :
+ env["CHECKER_FLAGS"]["CPPPATH"] = ["#/3rdParty/HippoMocks"]
- if env["SCONS_STAGE"] == "build" :
- checker_env = env.Clone()
- checker_env.UseFlags(env["SWIFTEN_FLAGS"])
- checker_env.UseFlags(env["BOOST_FLAGS"])
- checker_env.UseFlags(env["CPPUNIT_FLAGS"])
- checker_env.Library("Checker", ["checker.cpp", "IO.cpp"])
+ if env["SCONS_STAGE"] == "build" :
+ checker_env = env.Clone()
+ checker_env.UseFlags(env["SWIFTEN_FLAGS"])
+ checker_env.UseFlags(env["BOOST_FLAGS"])
+ checker_env.UseFlags(env["CPPUNIT_FLAGS"])
+ checker_env.Library("Checker", ["checker.cpp", "IO.cpp"])
diff --git a/QA/Checker/checker.cpp b/QA/Checker/checker.cpp
index 2cb00d3..f1186cc 100644
--- a/QA/Checker/checker.cpp
+++ b/QA/Checker/checker.cpp
@@ -1,86 +1,87 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <string>
-#include <cppunit/ui/text/TestRunner.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/XmlOutputter.h>
-#include <cppunit/TextTestResult.h>
+
#include <cppunit/BriefTestProgressListener.h>
-#include <cppunit/TextTestProgressListener.h>
#include <cppunit/TextOutputter.h>
+#include <cppunit/TextTestProgressListener.h>
+#include <cppunit/TextTestResult.h>
+#include <cppunit/XmlOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
#include <Swiften/Base/Log.h>
int main(int argc, char* argv[]) {
- bool verbose = false;
- bool outputXML = false;
+ bool verbose = false;
+ bool outputXML = false;
- Swift::Log::setLogLevel(Swift::Log::error);
+ Swift::Log::setLogLevel(Swift::Log::error);
- // Parse parameters
- std::vector<std::string> testsToRun;
- for (int i = 1; i < argc; ++i) {
- std::string param(argv[i]);
- if (param == "--verbose") {
- verbose = true;
- }
- else if (param == "--xml") {
- outputXML = true;
- }
- else if (param == "--debug") {
- Swift::Log::setLogLevel(Swift::Log::debug);
- }
- else {
- testsToRun.push_back(param);
- }
- }
- if (testsToRun.empty()) {
- testsToRun.push_back("");
- }
+ // Parse parameters
+ std::vector<std::string> testsToRun;
+ for (int i = 1; i < argc; ++i) {
+ std::string param(argv[i]);
+ if (param == "--verbose") {
+ verbose = true;
+ }
+ else if (param == "--xml") {
+ outputXML = true;
+ }
+ else if (param == "--debug") {
+ Swift::Log::setLogLevel(Swift::Log::debug);
+ }
+ else {
+ testsToRun.push_back(param);
+ }
+ }
+ if (testsToRun.empty()) {
+ testsToRun.push_back("");
+ }
- // Set up the listeners
- CppUnit::TestResult controller;
+ // Set up the listeners
+ CppUnit::TestResult controller;
- CppUnit::TestResultCollector result;
- controller.addListener(&result);
+ CppUnit::TestResultCollector result;
+ controller.addListener(&result);
- CppUnit::TextTestProgressListener progressListener;
- CppUnit::BriefTestProgressListener verboseListener;
- if (!outputXML) {
- if (verbose) {
- controller.addListener(&verboseListener);
- }
- else {
- controller.addListener(&progressListener);
- }
- }
+ CppUnit::TextTestProgressListener progressListener;
+ CppUnit::BriefTestProgressListener verboseListener;
+ if (!outputXML) {
+ if (verbose) {
+ controller.addListener(&verboseListener);
+ }
+ else {
+ controller.addListener(&progressListener);
+ }
+ }
- // Run the tests
- CppUnit::TestRunner runner;
- runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
- for (std::vector<std::string>::const_iterator i = testsToRun.begin(); i != testsToRun.end(); ++i) {
- try {
- runner.run(controller, *i);
- }
- catch (const std::exception& e) {
- std::cerr << "Error: " << e.what() << std::endl;
- return -1;
- }
- }
+ // Run the tests
+ CppUnit::TestRunner runner;
+ runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
+ for (std::vector<std::string>::const_iterator i = testsToRun.begin(); i != testsToRun.end(); ++i) {
+ try {
+ runner.run(controller, *i);
+ }
+ catch (const std::exception& e) {
+ std::cerr << "Error: " << e.what() << std::endl;
+ return -1;
+ }
+ }
- // Output the results
- if (outputXML) {
- CppUnit::XmlOutputter outputter(&result, std::cout);
- outputter.write();
- }
- else {
- CppUnit::TextOutputter outputter(&result, std::cerr);
- outputter.write();
- }
+ // Output the results
+ if (outputXML) {
+ CppUnit::XmlOutputter outputter(&result, std::cout);
+ outputter.write();
+ }
+ else {
+ CppUnit::TextOutputter outputter(&result, std::cerr);
+ outputter.write();
+ }
- return result.wasSuccessful() ? 0 : 1;
+ return result.wasSuccessful() ? 0 : 1;
}
diff --git a/QA/CrossDistributionTest/VagrantCrossDistributionTest.py b/QA/CrossDistributionTest/VagrantCrossDistributionTest.py
new file mode 100755
index 0000000..3530fe5
--- /dev/null
+++ b/QA/CrossDistributionTest/VagrantCrossDistributionTest.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+
+# Required Python libraries:
+#
+# pip install python-vagrant tqdm
+#
+# Purpose of this script:
+#
+# This script tests
+# a) InstallSwiftDependencies.sh installs all required packages for Swift and Swiften on system and
+# b) all Swift projects build successfully on the system and their tests pass.
+
+from tqdm import tqdm
+from time import sleep
+import sys
+import vagrant
+
+testSystems = [
+ "bento/ubuntu-16.04",
+ "bento/ubuntu-15.04",
+ "bento/debian-8.5",
+ "bento/opensuse-leap-42.1",
+ "bento/fedora-24",
+ "Sabayon/spinbase-amd64"
+]
+
+progressBar = tqdm(testSystems)
+
+successfulSystems = []
+failedSystems = []
+
+for testSystem in progressBar :
+ v = vagrant.Vagrant(quiet_stdout=False)
+ try :
+ progressBar.set_description("create Vagrantfile for %s" % testSystem)
+ with open('Vagrantfile', 'w') as vagrantfile :
+ vagrantfile.write("""
+Vagrant.configure("2") do |config|
+ config.vm.box = "%s"
+
+ config.ssh.insert_key = false
+
+ config.vm.provider "virtualbox" do |v|
+ v.memory = 4096
+ v.cpus = 2
+ end
+
+ # This is needed because Fedora only comes with Python 3 and Ansible needs Python 2
+ # on the target system for some features.
+ if config.vm.box.include? "fedora"
+ config.vm.provision "shell", inline: "sudo dnf install -y python2 python2-dnf libselinux-python"
+ end
+
+ if config.vm.box.include? "Sabayon"
+ config.vm.provision "shell", inline: "sudo equo update && sudo env ACCEPT_LICENSE=* equo install dev-vcs/git sys-apps/lsb-release"
+ end
+
+ config.vm.synced_folder "../..", "/home/vagrant/swift-host", type: "rsync"
+ config.vm.synced_folder ".", "/vagrant", type: "rsync"
+
+ config.vm.provision "ansible" do |ansible|
+ #ansible.verbose = "vvv"
+ ansible.playbook = "playbook.yml"
+ end
+end""" % testSystem)
+
+ progressBar.set_description("vagrant up")
+ v.up(testSystem, provision=True )
+
+ progressBar.set_description("start building swift on %s" % testSystem)
+ # unset QTDIR is needed, because Fedora 24 sets QTDIR to Qt 3, even though Qt 5 is installed.
+ # SCons will pick up the Qt installation from QTDIR if QTDIR is set.
+ v._call_vagrant_command(["ssh", "-c", "cd /home/vagrant/swift && unset QTDIR && ./scons test=unit -j 2"])
+
+ progressBar.set_description("vagrant destory %s" % testSystem)
+ v.destroy()
+ successfulSystems.append(testSystem)
+ except :
+ e = sys.exc_info()[0]
+ print("Exception: %s" % e)
+ progressBar.set_description("vagrant destory %s" % testSystem)
+ v.destroy()
+ failedSystems.append(testSystem)
+
+for system in successfulSystems:
+ print("SUCCESS: %s" % system)
+for system in failedSystems:
+ print("FAILED: %s" % system)
+
+exit(len(failedSystems)) \ No newline at end of file
diff --git a/QA/CrossDistributionTest/playbook.yml b/QA/CrossDistributionTest/playbook.yml
new file mode 100644
index 0000000..aa4b8f5
--- /dev/null
+++ b/QA/CrossDistributionTest/playbook.yml
@@ -0,0 +1,33 @@
+- hosts: all
+ tasks:
+ - name: Install required packages via apt
+ apt: name=git state=latest update_cache=yes
+ become: true
+ when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
+ - name: Install required packages via dnf
+ dnf: name={{item}} state=latest
+ with_items:
+ - git
+ - redhat-lsb
+ become: true
+ when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'RedHat' or ansible_distribution == 'Fedora'
+ - name: 'Install required packages via zypper'
+ zypper: name={{item}} state=latest
+ with_items:
+ - git-core
+ - lsb-release
+ become: true
+ when: ansible_distribution == 'openSUSE Leap'
+ - name: Clone git from host working directory
+ git: repo=/home/vagrant/swift-host dest=/home/vagrant/swift
+
+ - name: 'Install Swift dependencies for openSUSE Leap'
+ shell: ./BuildTools/InstallSwiftDependencies.sh --non-interactive chdir=/home/vagrant/swift
+ become: true
+ when: ansible_distribution == 'openSUSE Leap'
+ - name: 'Install Swift dependencies'
+ environment:
+ ACCEPT_LICENSE: '*'
+ shell: yes | ./BuildTools/InstallSwiftDependencies.sh chdir=/home/vagrant/swift
+ become: true
+ when: ansible_distribution != 'openSUSE Leap'
diff --git a/QA/SConscript b/QA/SConscript
index 5c626e3..b4125cf 100644
--- a/QA/SConscript
+++ b/QA/SConscript
@@ -1,4 +1,4 @@
SConscript(dirs = [
- "Checker",
- "UnitTest"
- ])
+ "Checker",
+ "UnitTest"
+ ])
diff --git a/QA/UnitTest/SConscript b/QA/UnitTest/SConscript
index 0cacc7c..1874f99 100644
--- a/QA/UnitTest/SConscript
+++ b/QA/UnitTest/SConscript
@@ -3,27 +3,27 @@ import os
Import("env")
if env["TEST"] :
- if env["SCONS_STAGE"] == "flags" :
- env["UNITTEST_SOURCES"] = []
- env["UNITTEST_OBJECTS"] = []
- if env["SCONS_STAGE"] == "build" :
- myenv = env.Clone()
- myenv.UseFlags(env.get("CHECKER_FLAGS",""))
- myenv.UseFlags(env.get("INJECTED_UNITTEST_FLAGS","")) # So things that piggy-back our build system can piggy-back our test system too
- myenv.UseFlags(env.get("SLIMBER_FLAGS",""))
- myenv.UseFlags(env.get("SWIFT_CONTROLLERS_FLAGS",""))
- myenv.UseFlags(env.get("SWIFTOOLS_FLAGS",""))
- myenv.UseFlags(env.get("LIMBER_FLAGS",""))
- myenv.UseFlags(env.get("SWIFTEN_FLAGS",""))
- myenv.UseFlags(env.get("CPPUNIT_FLAGS",""))
- myenv.UseFlags(env.get("SWIFTEN_DEP_FLAGS", ""))
- if env.get("HAVE_LIBXML") :
- myenv.Append(CPPDEFINES = ["HAVE_LIBXML"])
- if env.get("HAVE_EXPAT") :
- myenv.Append(CPPDEFINES = ["HAVE_EXPAT"])
- if env["TEST_CREATE_LIBRARIES"] :
- lib = myenv.StaticLibrary("Swift_UnitTests", env["UNITTEST_SOURCES"] + env["UNITTEST_OBJECTS"])
- myenv.Program("checker", lib)
- else :
- checker = myenv.Program("checker", env["UNITTEST_SOURCES"] + env["UNITTEST_OBJECTS"])
- myenv.Test(checker, is_checker = True)
+ if env["SCONS_STAGE"] == "flags" :
+ env["UNITTEST_SOURCES"] = []
+ env["UNITTEST_OBJECTS"] = []
+ if env["SCONS_STAGE"] == "build" :
+ myenv = env.Clone()
+ myenv.UseFlags(env.get("CHECKER_FLAGS",""))
+ myenv.UseFlags(env.get("INJECTED_UNITTEST_FLAGS","")) # So things that piggy-back our build system can piggy-back our test system too
+ myenv.UseFlags(env.get("SLIMBER_FLAGS",""))
+ myenv.UseFlags(env.get("SWIFT_CONTROLLERS_FLAGS",""))
+ myenv.UseFlags(env.get("SWIFTOOLS_FLAGS",""))
+ myenv.UseFlags(env.get("LIMBER_FLAGS",""))
+ myenv.UseFlags(env.get("SWIFTEN_FLAGS",""))
+ myenv.UseFlags(env.get("CPPUNIT_FLAGS",""))
+ myenv.UseFlags(env.get("SWIFTEN_DEP_FLAGS", ""))
+ if env.get("HAVE_LIBXML") :
+ myenv.Append(CPPDEFINES = ["HAVE_LIBXML"])
+ if env.get("HAVE_EXPAT") :
+ myenv.Append(CPPDEFINES = ["HAVE_EXPAT"])
+ if env["TEST_CREATE_LIBRARIES"] :
+ lib = myenv.StaticLibrary("Swift_UnitTests", env["UNITTEST_SOURCES"] + env["UNITTEST_OBJECTS"])
+ myenv.Program("checker", lib)
+ else :
+ checker = myenv.Program("checker", env["UNITTEST_SOURCES"] + env["UNITTEST_OBJECTS"])
+ myenv.Test(checker, is_checker = True)
diff --git a/QA/UnitTest/template/FooTest.cpp b/QA/UnitTest/template/FooTest.cpp
index 854c24a..adddb5b 100644
--- a/QA/UnitTest/template/FooTest.cpp
+++ b/QA/UnitTest/template/FooTest.cpp
@@ -10,19 +10,19 @@
using namespace Swift;
class FooTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(FooTest);
- CPPUNIT_TEST(testBar);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(FooTest);
+ CPPUNIT_TEST(testBar);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void setUp() {
- }
+ public:
+ void setUp() {
+ }
- void tearDown() {
- }
+ void tearDown() {
+ }
- void testBar() {
- }
+ void testBar() {
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(FooTest);