diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2016-12-21 18:10:22 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2017-01-03 15:23:48 +0000 |
commit | 01e3d73acea6e05d10b055cfffc41345eaab7806 (patch) | |
tree | 480023a8e73a79da935b78268040d8a3ac5c8503 /tests | |
parent | f37a00f83f831830cae7ae5abd2b859cb2a89cd1 (diff) |
Add first auto test for the elfmap
This test simply checks that the non-overlapping mmap regions
are handled correctly.
Change-Id: I2e07e099aa331b3adf0a1b7bb6d3673d971a4b81
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/auto.pro | 2 | ||||
-rw-r--r-- | tests/auto/auto.qbs | 9 | ||||
-rw-r--r-- | tests/auto/elfmap/elfmap.pro | 14 | ||||
-rw-r--r-- | tests/auto/elfmap/elfmap.qbs | 11 | ||||
-rw-r--r-- | tests/auto/elfmap/tst_elfmap.cpp | 74 | ||||
-rw-r--r-- | tests/tests.pro | 2 | ||||
-rw-r--r-- | tests/tests.qbs | 6 |
7 files changed, 118 insertions, 0 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro new file mode 100644 index 0000000..6f71b2a --- /dev/null +++ b/tests/auto/auto.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = elfmap diff --git a/tests/auto/auto.qbs b/tests/auto/auto.qbs new file mode 100644 index 0000000..5b18b6e --- /dev/null +++ b/tests/auto/auto.qbs @@ -0,0 +1,9 @@ +import qbs + +Project { + name: "PerfParserAutotests" + condition: project.withAutotests + references: [ + "elfmap" + ] +} diff --git a/tests/auto/elfmap/elfmap.pro b/tests/auto/elfmap/elfmap.pro new file mode 100644 index 0000000..502b628 --- /dev/null +++ b/tests/auto/elfmap/elfmap.pro @@ -0,0 +1,14 @@ +QT += testlib + +CONFIG += testcase strict_flags warn_on + +INCLUDEPATH += ../../../app + +TARGET = tst_elfmap + +SOURCES += \ + tst_elfmap.cpp \ + ../../../app/perfelfmap.cpp + +HEADERS += \ + ../../../app/perfelfmap.h diff --git a/tests/auto/elfmap/elfmap.qbs b/tests/auto/elfmap/elfmap.qbs new file mode 100644 index 0000000..f5d478d --- /dev/null +++ b/tests/auto/elfmap/elfmap.qbs @@ -0,0 +1,11 @@ +import qbs + +QtcAutotest { + name: "Elfmap Autotest" + files: [ + "tst_elfmap.cpp", + "../../../app/perfelfmap.cpp", + "../../../app/perfelfmap.h" + ] + cpp.includePaths: base.concat(["../../../app"]) +} diff --git a/tests/auto/elfmap/tst_elfmap.cpp b/tests/auto/elfmap/tst_elfmap.cpp new file mode 100644 index 0000000..3da7eea --- /dev/null +++ b/tests/auto/elfmap/tst_elfmap.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com> +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Enterprise Perf Profiler Add-on. +** +** GNU General Public License Usage +** This file may be used under the terms of the GNU General Public License +** version 3 as published by the Free Software Foundation and appearing in +** the file LICENSE.GPLv3 included in the packaging of this file. Please +** review the following information to ensure the GNU General Public License +** requirements will be met: https://www.gnu.org/licenses/gpl.html. +** +** If you have questions regarding the use of this file, please use +** contact form at http://www.qt.io/contact-us +** +****************************************************************************/ + +#include <QObject> +#include <QTest> +#include <QDebug> + +#include "perfelfmap.h" + +class TestElfMap : public QObject +{ + Q_OBJECT +private slots: + void testNoOverlap() + { + PerfElfMap map; + QVERIFY(map.isEmpty()); + + QVERIFY(!map.registerElf(100, 10, 0, {})); + QVERIFY(!map.isEmpty()); + + QCOMPARE(map.constBegin().key(), 100ull); + QCOMPARE(map.constBegin()->length, 10ull); + QCOMPARE(map.constBegin()->timeAdded, 0ull); + + QCOMPARE(map.findElf(99, 0), map.constEnd()); + QCOMPARE(map.findElf(100, 0), map.constBegin()); + QCOMPARE(map.findElf(109, 0), map.constBegin()); + QCOMPARE(map.findElf(110, 0), map.constEnd()); + QCOMPARE(map.findElf(105, 1), map.constBegin()); + + QVERIFY(!map.registerElf(0, 10, 1, {})); + + QCOMPARE(map.constBegin().key(), 0ull); + QCOMPARE(map.constBegin()->length, 10ull); + QCOMPARE(map.constBegin()->timeAdded, 1ull); + + auto first = map.constBegin(); + auto second = first + 1; + + QCOMPARE(map.findElf(0, 0), map.constEnd()); + QCOMPARE(map.findElf(0, 1), first); + QCOMPARE(map.findElf(5, 1), first); + QCOMPARE(map.findElf(9, 1), first); + QCOMPARE(map.findElf(10, 0), map.constEnd()); + QCOMPARE(map.findElf(5, 2), first); + + QCOMPARE(map.findElf(99, 0), map.constEnd()); + QCOMPARE(map.findElf(100, 0), second); + QCOMPARE(map.findElf(109, 0), second); + QCOMPARE(map.findElf(110, 0), map.constEnd()); + QCOMPARE(map.findElf(105, 1), second); + } +}; + +QTEST_MAIN(TestElfMap) + +#include "tst_elfmap.moc" diff --git a/tests/tests.pro b/tests/tests.pro new file mode 100644 index 0000000..7fbc8a9 --- /dev/null +++ b/tests/tests.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = auto diff --git a/tests/tests.qbs b/tests/tests.qbs new file mode 100644 index 0000000..365a337 --- /dev/null +++ b/tests/tests.qbs @@ -0,0 +1,6 @@ +import qbs + +Project { + name: "Tests" + references: ["auto"] +} |