diff --git a/dist/distribute.qbs b/dist/distribute.qbs index d429d2c..65727d8 100644 --- a/dist/distribute.qbs +++ b/dist/distribute.qbs @@ -7,7 +7,6 @@ Product { name: "distribute" type: "installable" condition : qbs.architecture.contains("x86") - builtByDefault: qbs.buildVariant.contains("release") Depends { name: "cpp" } Depends { name: "Qt.core" } @@ -39,6 +38,7 @@ Product { suffix += "d"; return suffix + cpp.dynamicLibrarySuffix; } + files: { function addQtVersions(libs) { var result = []; @@ -61,6 +61,10 @@ Product { "Qt5Qml" + postfix, "Qt5SerialPort" + postfix ); + + if (qbs.buildVariant === "debug") { + list.push("Qt5Test" + postfix); + } } if (qbs.targetOS.contains("linux")) { @@ -78,7 +82,7 @@ Product { } Group { - name: "Runtime DLLs - MinGW on Windows" + name: "Runtime DLLs - MinGW on Windows host" condition: qbs.targetOS.contains("windows") && qbs.hostOS.contains("windows") && qbs.toolchain.contains("mingw") @@ -95,7 +99,7 @@ Product { } Group { - name: "Runtime DLLs - MinGW on Linux" + name: "Runtime DLLs - MinGW on Linux host" condition: qbs.targetOS.contains("windows") && qbs.hostOS.contains("linux") diff --git a/share/qst/imports/ti/UniflashProbe.qml b/share/qst/imports/ti/UniflashProbe.qml index 4f09321..6478423 100644 --- a/share/qst/imports/ti/UniflashProbe.qml +++ b/share/qst/imports/ti/UniflashProbe.qml @@ -17,15 +17,17 @@ Component { property string device property string file + readonly property string host: (Qst.hostOS === "linux") ? "linux" : "win" + signal finished function flash() { Qst.verify(File.exists(uniflash.program), uniflash.program + " not found. Check 'installPath' property."); Qst.verify(File.exists(file), file + " not found. Check 'file' property."); Qst.verify(File.exists((installPath - + "/deskdb/content/TICloudAgent/linux/ccs_base/common/targetdb/devices/" + + "/deskdb/content/TICloudAgent/" + host + "/ccs_base/common/targetdb/devices/" + device + ".xml")), "No db entry for device '"+ device + "' found in '" - + installPath + "/deskdb/content/TICloudAgent/linux/ccs_base/common/targetdb/devices/" + "'."); + + installPath + "/deskdb/content/TICloudAgent/" + host + "/ccs_base/common/targetdb/devices/" + "'."); var configFilePath = test.workingDirectory + "/uniflashprobe" + "-" + device @@ -55,6 +57,11 @@ Component { return reset.waitForFinished(Math.max(milliseconds - (t1 - t0), -1)); } + function reset() { + reset.start(); + reset.waitForStarted(200); + } + ProcessProbe { id: uniflash @@ -64,8 +71,6 @@ Component { Qst.compare(exitCode, 0, "UniflashProbe '" + root.name + "' (dslite) exited with " + exitCode + ": " + readAllStandardError() + readAllStandardOutput()); - reset.start(); - reset.waitForStarted(100); } } diff --git a/src/launchpad-probe/main.cpp b/src/launchpad-probe/main.cpp index f4aeaa3..18908b0 100644 --- a/src/launchpad-probe/main.cpp +++ b/src/launchpad-probe/main.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -37,6 +36,7 @@ #include #include #include +#include #include diff --git a/src/qst/qst.cpp b/src/qst/qst.cpp index 78f663b..ea329b0 100644 --- a/src/qst/qst.cpp +++ b/src/qst/qst.cpp @@ -84,7 +84,7 @@ QmlContext qmlDefinitionContext(const QObject* object) QQmlData* data = QQmlData::get(object); if (data && data->outerContext) { - result["file"] = data->outerContext->url().path(); + result["file"] = data->outerContext->url().toLocalFile(); result["line"] = data->lineNumber; result["column"] = data->columnNumber; } diff --git a/tests/manual/launchpadprobe/cc1310_launchxl.json b/tests/manual/launchpadprobe/cc1310_launchxl_linux.json similarity index 92% rename from tests/manual/launchpadprobe/cc1310_launchxl.json rename to tests/manual/launchpadprobe/cc1310_launchxl_linux.json index b276226..ae9bce5 100644 --- a/tests/manual/launchpadprobe/cc1310_launchxl.json +++ b/tests/manual/launchpadprobe/cc1310_launchxl_linux.json @@ -2,7 +2,7 @@ "UniflashProbe": { "installDirectory": "/opt/ti/uniflash_4.4.0" }, - "qstExecutable": "/opt/qst/bin/qst", + "qstExecutable": "qst", "dut": { "serial": "L400028Q", "device": "cc1310f128", diff --git a/tests/manual/launchpadprobe/cc1310_launchxl_windows.json b/tests/manual/launchpadprobe/cc1310_launchxl_windows.json new file mode 100644 index 0000000..09f1cee --- /dev/null +++ b/tests/manual/launchpadprobe/cc1310_launchxl_windows.json @@ -0,0 +1,18 @@ +{ + "UniflashProbe": { + "installDirectory": "C:/ti/uniflash_4.4.0" + }, + "qstExecutable": "qst.exe", + "dut": { + "serial": "L400028Q", + "device": "cc1310f128", + "firmwarePath": "C:/qst/share/qst/firmware/launchpad-probe-CC1310_LAUNCHXL.elf", + "ioid": 13 + }, + "probe": { + "serial": "L20002HM", + "device": "cc1310f128", + "firmwarePath": "C:/qst/share/qst/firmware/launchpad-probe-CC1310_LAUNCHXL.elf", + "ioid": 23 + } +} diff --git a/tests/manual/launchpadprobe/flash-firmware.qml b/tests/manual/launchpadprobe/flash-firmware.qml index 5007ea3..240beb1 100644 --- a/tests/manual/launchpadprobe/flash-firmware.qml +++ b/tests/manual/launchpadprobe/flash-firmware.qml @@ -25,6 +25,8 @@ LaunchpadProbeTest { board2.flash(); board1.waitForFinished(maxFlashTime); board2.waitForFinished(Math.max(maxFlashTime - test.elapsedTime, 0)); - Qst.wait(666) // Otherwise the following test may not connect properly + board1.reset() + board2.reset() + Qst.wait(666) // Need to wait before the next test can access the board } } diff --git a/tests/manual/launchpadprobe/launchpadprobe.qbs b/tests/manual/launchpadprobe/launchpadprobe.qbs index 0b40ab9..eb0006e 100644 --- a/tests/manual/launchpadprobe/launchpadprobe.qbs +++ b/tests/manual/launchpadprobe/launchpadprobe.qbs @@ -10,12 +10,12 @@ QstAutoTest { "LaunchpadProbeTest.qml", "benchmark-response-time.qml", "BoardConfig.qml", - "cc1310_launchxl.json", + "cc1310_launchxl_linux.json", + "cc1310_launchxl_windows.json", "flash-firmware.qml", "pinprobe-read-write.qml", "reset.qml", "test-launchpadprobe.cpp", - "test-launchpadprobe.h", "watchdog-dut.qml", "watchdog.qml", ] diff --git a/tests/manual/launchpadprobe/test-launchpadprobe.cpp b/tests/manual/launchpadprobe/test-launchpadprobe.cpp index 20589ce..d99977c 100644 --- a/tests/manual/launchpadprobe/test-launchpadprobe.cpp +++ b/tests/manual/launchpadprobe/test-launchpadprobe.cpp @@ -21,55 +21,79 @@ ** ** $END_LICENSE$ ****************************************************************************/ -#include "test-launchpadprobe.h" +#include #include #include -QString LaunchpadProbeTest::dataPath(const QString &fileName) const +#include + +#include +#include +#include + +class test_launchpadprobe : public QstTest +{ + Q_OBJECT + +public: + QString dataPath(const QString &fileName) const; + +private slots: + void init(); + void flashFirmware(); + void pinProbereadWrite(); + void benchmarkPinProbeResponseTime(); + void pinProbeWatchdog(); + +private: + QString profile() const; +}; + +QString test_launchpadprobe::profile() const +{ +#ifdef Q_OS_WIN + return "cc1310_launchxl_windows"; +#elif defined Q_OS_LINUX + return "cc1310_launchxl_linux"; +#endif +} + +void test_launchpadprobe::init() +{ + setTimeoutMs(25000); +} + +QString test_launchpadprobe::dataPath(const QString &fileName) const { return QDir(QString(SOURCE_DIR)).absoluteFilePath(fileName); } -void LaunchpadProbeTest::flashFirmware() +void test_launchpadprobe::flashFirmware() { - QstTestResults results = execQstRun(QStringList{ "-f", dataPath("flash-firmware.qml"), "-p", "cc1310_launchxl" }, 25000); - if (qstProcess().exitCode() != 0) - { - QFAIL(qstProcess().readAllStandardError()); - } - VERIFY_PASS(results, "flash-firmware"); + RUN_AND_EXPECT(qst::ExitNormal, "-f", dataPath("flash-firmware.qml"), "-p", profile()); + VERIFY_PASS(results(), "flash-firmware"); } -void LaunchpadProbeTest::pinProbereadWrite() +void test_launchpadprobe::pinProbereadWrite() { - QstTestResults results = execQstRun(QStringList{ "-f", dataPath("pinprobe-read-write.qml"), "-p", "cc1310_launchxl" }, 25000); - if (qstProcess().exitCode() != 0) - { - QFAIL(qstProcess().readAllStandardError()); - } - VERIFY_PASS(results, "pinprobe-read-write"); + RUN_AND_EXPECT(qst::ExitNormal, "-f", dataPath("pinprobe-read-write.qml"), "-p", profile()); + VERIFY_PASS(results(), "pinprobe-read-write"); + } -void LaunchpadProbeTest::benchmarkPinProbeResponseTime() +void test_launchpadprobe::benchmarkPinProbeResponseTime() { - QstTestResults results = execQstRun(QStringList{ "-f", dataPath("benchmark-response-time.qml"), "-p", "cc1310_launchxl" }, 25000); - if (qstProcess().exitCode() != 0) - { - QFAIL(qstProcess().readAllStandardError()); - } - VERIFY_PASS(results, "benchmark-response-time"); + RUN_AND_EXPECT(qst::ExitNormal, "-f", dataPath("benchmark-response-time.qml"), "-p", profile()); + VERIFY_PASS(results(), "benchmark-response-time"); + } -void LaunchpadProbeTest::pinProbeWatchdog() +void test_launchpadprobe::pinProbeWatchdog() { - { - QstTestResults results = execQstRun(QStringList{ "-f", dataPath("watchdog.qml"), "-p", "cc1310_launchxl" }, 25000); - if (qstProcess().exitCode() != 0) - { - QFAIL(qstProcess().readAllStandardError()); - } - VERIFY_PASS(results, "watchdog"); - } + RUN_AND_EXPECT(qst::ExitNormal, "-f", dataPath("watchdog.qml"), "-p", profile()); + VERIFY_PASS(results(), "watchdog"); } -QTEST_GUILESS_MAIN(LaunchpadProbeTest) +QTEST_GUILESS_MAIN(test_launchpadprobe) + +#include "test-launchpadprobe.moc" diff --git a/tests/manual/launchpadprobe/test-launchpadprobe.h b/tests/manual/launchpadprobe/test-launchpadprobe.h deleted file mode 100644 index d51803a..0000000 --- a/tests/manual/launchpadprobe/test-launchpadprobe.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) 2017, 2018 The Qst project. - ** - ** Contact: https://github.com/rweickelt/qst - ** - ** $BEGIN_LICENSE$ - ** - ** 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 3 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. If not, see . - ** - ** $END_LICENSE$ -****************************************************************************/ -#ifndef LAUNCHPADPROBETEST_H -#define LAUNCHPADPROBETEST_H - -#include - -#include -#include - -class LaunchpadProbeTest : public QstTest -{ - Q_OBJECT - -public: - QString dataPath(const QString &fileName) const; - -private slots: - void flashFirmware(); - void pinProbereadWrite(); - void benchmarkPinProbeResponseTime(); - void pinProbeWatchdog(); - -}; - -#endif // LAUNCHPADPROBETEST_H diff --git a/tests/manual/launchpadprobe/watchdog.qml b/tests/manual/launchpadprobe/watchdog.qml index 85c3949..55408dc 100644 --- a/tests/manual/launchpadprobe/watchdog.qml +++ b/tests/manual/launchpadprobe/watchdog.qml @@ -8,6 +8,7 @@ LaunchpadProbeTest { property int pingIntervalMs: 517 property int timeUntilDutKillMs: Math.ceil(Math.random() * connectionTimeoutMs) + 100 + // Shows the DUT's connected state PinProbe { name: "connected-led" id: connectedLed @@ -18,6 +19,7 @@ LaunchpadProbeTest { port: Xds.portFromSerial(profile.probe.serial) } + // Shows the DUT's activity PinProbe { name: "activity-led" id: activityLed @@ -28,6 +30,7 @@ LaunchpadProbeTest { port: Xds.portFromSerial(profile.probe.serial) } + // Another qst instance accessing the DUT board ProcessProbe { id: dutQstProcess name: "dut-qst-process" @@ -79,20 +82,29 @@ LaunchpadProbeTest { endOn: dutDisconnected minDuration: (connectionTimeoutMs - pingIntervalMs) - maxDuration: connectionTimeoutMs + maxDuration: (connectionTimeoutMs + pingIntervalMs) } function run() { + // The DUT must not be in connected state Qst.compare(connectedLed.value, PinProbe.Low) + // Start another qst application that connects to the DUT dutQstProcess.start() - Qst.wait(100) + Qst.wait(300) + // The DUT must now be in connected state Qst.compare(connectedLed.value, PinProbe.High) + + // Kill the Qst DUT instance after some time to + // trigger a watchdog reset Qst.wait(timeUntilDutKillMs) dutQstProcess.terminate() - dutKilled() - dutQstProcess.waitForFinished(100) - Qst.compare(dutQstProcess.state, ProcessProbe.NotRunning) - Qst.wait(connectionTimeoutMs * 2) + + // Wait for the termination propagate + dutQstProcess.waitForFinished(300) + // Qst.compare(dutQstProcess.state, ProcessProbe.NotRunning) + + // Wait and ensure that the DUT resets + Qst.wait(connectionTimeoutMs + (2*pingIntervalMs)) Qst.compare(connectedLed.value, PinProbe.Low) } } diff --git a/tests/qsttest.cpp b/tests/qsttest.cpp index dcd0a56..cb93229 100644 --- a/tests/qsttest.cpp +++ b/tests/qsttest.cpp @@ -52,6 +52,11 @@ QString QstTest::dataPath(const QString& directory) const return m_dataDirectory.absoluteFilePath(directory); } +void QstTest::setTimeoutMs(int milliseconds) +{ + m_timeoutMs = milliseconds; +} + QstTestResults QstTest::execQstRun(const QStringList& arguments, int timeoutMs) { QStringList cmdLine = { "run", "--import", m_defaultImportPath }; diff --git a/tests/qsttest.h b/tests/qsttest.h index b3fb516..4f34005 100644 --- a/tests/qsttest.h +++ b/tests/qsttest.h @@ -41,8 +41,11 @@ class QstTest : public QObject static bool verifyExecutionOrder(const QStringList& expected, const QStringList& actual); + void setTimeoutMs(int milliseconds); + protected: - QString dataPath(const QString& directory) const; + virtual QString dataPath(const QString& directory) const; + QString defaultImportPath() const; QstTestResults execQstRun(const QStringList& arguments, int timeoutMs = 500); bool execQstRun(const QStringList& arguments, int expectedExitCode, const QString& file, int line); @@ -54,6 +57,7 @@ class QstTest : public QObject QProcess m_qstProcess; QstTestResults m_results; QString m_stdError; + int m_timeoutMs = 500; static const QDir m_dataDirectory; static const QString m_defaultImportPath; }; @@ -98,4 +102,5 @@ inline QString QstTest::stdError() const { return m_stdError; } } + #endif // QSTTEST_H diff --git a/tests/tests.qbs b/tests/tests.qbs index 26bde2c..f2527e6 100644 --- a/tests/tests.qbs +++ b/tests/tests.qbs @@ -1,7 +1,7 @@ import qbs Project { - condition : qbs.architecture.lastIndexOf("x86") === 0 + condition : qbs.architecture.contains("x86") references: [ "auto/auto.qbs",