diff --git a/src/plugins/mcusupport/mcuabstractpackage.h b/src/plugins/mcusupport/mcuabstractpackage.h index e0499ef06fa..09d4744b269 100644 --- a/src/plugins/mcusupport/mcuabstractpackage.h +++ b/src/plugins/mcusupport/mcuabstractpackage.h @@ -54,6 +54,7 @@ public: virtual Utils::FilePath path() const = 0; virtual Utils::FilePath defaultPath() const = 0; virtual Utils::FilePath detectionPath() const = 0; + virtual QString settingsKey() const = 0; virtual void updateStatus() = 0; virtual Status status() const = 0; diff --git a/src/plugins/mcusupport/mcupackage.cpp b/src/plugins/mcusupport/mcupackage.cpp index f4ca09355e4..a41138e1cd0 100644 --- a/src/plugins/mcusupport/mcupackage.cpp +++ b/src/plugins/mcusupport/mcupackage.cpp @@ -76,6 +76,11 @@ QString McuPackage::label() const return m_label; } +QString McuPackage::settingsKey() const +{ + return m_settingsKey; +} + const QString &McuPackage::environmentVariableName() const { return m_environmentVariableName; @@ -148,7 +153,6 @@ bool McuPackage::isValidStatus() const return m_status == Status::ValidPackage || m_status == Status::ValidPackageMismatchedVersion; } - void McuPackage::updateStatusUi() { switch (m_status) { @@ -269,7 +273,6 @@ QWidget *McuPackage::widget() return m_widget; } - McuToolChainPackage::McuToolChainPackage(const QString &label, const FilePath &defaultPath, const FilePath &detectionPath, @@ -466,5 +469,4 @@ QVariant McuToolChainPackage::debuggerId() const return DebuggerItemManager::registerDebugger(newDebugger); } - } // namespace McuSupport::Internal diff --git a/src/plugins/mcusupport/mcupackage.h b/src/plugins/mcusupport/mcupackage.h index 5a57fad9658..58008d10b1a 100644 --- a/src/plugins/mcusupport/mcupackage.h +++ b/src/plugins/mcusupport/mcupackage.h @@ -74,6 +74,7 @@ public: Utils::FilePath path() const override; Utils::FilePath defaultPath() const override; Utils::FilePath detectionPath() const override; + QString settingsKey() const final; void updateStatus() override; Status status() const override; diff --git a/src/plugins/mcusupport/mcusupportconstants.h b/src/plugins/mcusupport/mcusupportconstants.h index ec46414fb7f..7b5e66f8271 100644 --- a/src/plugins/mcusupport/mcusupportconstants.h +++ b/src/plugins/mcusupport/mcusupportconstants.h @@ -43,6 +43,7 @@ const char KIT_MCUTARGET_TOOCHAIN_KEY[] = "McuSupport.McuTargetToolchain"; const char SETTINGS_GROUP[] = "McuSupport"; const char SETTINGS_KEY_PACKAGE_PREFIX[] = "Package_"; +const char SETTINGS_KEY_FREERTOS_PREFIX[] = "FreeRTOSSourcePackage_"; const char SETTINGS_KEY_PACKAGE_QT_FOR_MCUS_SDK[] = "QtForMCUsSdk"; // Key known by SDK installer const char SETTINGS_KEY_AUTOMATIC_KIT_CREATION[] = "AutomaticKitCreation"; diff --git a/src/plugins/mcusupport/test/armgcc_nxp_1050_json.h b/src/plugins/mcusupport/test/armgcc_nxp_1050_json.h new file mode 100644 index 00000000000..81c15d6bdc6 --- /dev/null +++ b/src/plugins/mcusupport/test/armgcc_nxp_1050_json.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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-3.0.html. +** +****************************************************************************/ + +#pragma once + +constexpr auto armgcc_nxp_1050_json = R"({ + "qulVersion": "2.0.0", + "compatVersion": "1", + "platform": { + "id": "MIMXRT1050-EVK-FREERTOS", + "vendor": "NXP", + "colorDepths": [ + 16 + ], + "pathEntries": [], + "environmentEntries": [], + "cmakeCacheEntries": [ + { + "id": "Qul_DIR", + "description": "Qt for MCUs SDK", + "type": "path", + "cmakeOptionName": "Qul_ROOT", + "optional": false + }, + { + "id": "MCU_XPRESSO_PATH", + "description": "MCUXpresso IDE", + "type": "path", + "cmakeOptionName": "MCUXPRESSO_IDE_PATH", + "defaultValue": { + "windows": "$ROOT/nxp/MCUXpressoIDE*", + "unix": "/usr/local/mcuxpressoide/" + }, + "optional": false + } + ] + }, + "toolchain": { + "id": "armgcc", + "versions": [ + "9.3.1" + ], + "cmakeCacheEntries": [ + { + "id": "ARMGCC_DIR", + "description": "GNU Arm Embedded Toolchain", + "cmakeOptionName": "QUL_TARGET_TOOLCHAIN_DIR", + "type": "path", + "optional": false + }, + { + "id": "ARMGCC_CMAKE_TOOLCHAIN_FILE", + "description": "CMake Toolchain File", + "cmakeOptionName": "CMAKE_TOOLCHAIN_FILE", + "type": "file", + "defaultValue": "$Qul_ROOT/lib/cmake/Qul/toolchain/armgcc.cmake", + "visible": false, + "optional": false + } + ] + }, + "boardSdk": { + "envVar": "EVKB_IMXRT1050_SDK_PATH", + "versions": [ + "2.10.0" + ], + "cmakeCacheEntries": [ + { + "id": "NXP_SDK_DIR", + "description": "Board SDK for MIMXRT1050-EVK", + "cmakeOptionName": "QUL_BOARD_SDK_DIR", + "type": "path", + "optional": false + } + ] + }, + "freeRTOS": { + "envVar": "IMXRT1050_FREERTOS_DIR", + "cmakeCacheEntries": [ + { + "id": "NXP_FREERTOS_DIR", + "description": "FreeRTOS SDK for MIMXRT1050-EVK", + "cmakeOptionName": "FREERTOS_DIR", + "defaultValue": "$QUL_BOARD_SDK_DIR/rtos/freertos/freertos_kernel", + "type": "path", + "optional": false + } + ] + } +})"; diff --git a/src/plugins/mcusupport/test/nxp_1064_json.h b/src/plugins/mcusupport/test/armgcc_nxp_1064_json.h similarity index 93% rename from src/plugins/mcusupport/test/nxp_1064_json.h rename to src/plugins/mcusupport/test/armgcc_nxp_1064_json.h index 4e8f53afa96..f03911f405c 100644 --- a/src/plugins/mcusupport/test/nxp_1064_json.h +++ b/src/plugins/mcusupport/test/armgcc_nxp_1064_json.h @@ -25,7 +25,9 @@ #pragma once -constexpr auto nxp_1064_json = R"({ +constexpr auto armgcc_nxp_1064_json = R"({ + "compatVersion": "1", + "qulVersion": "2.0.0", "boardSdk": { "cmakeCacheEntries": [ { @@ -35,9 +37,9 @@ constexpr auto nxp_1064_json = R"({ "optional": false, "type": "path" } - ], - "envVar": "EVK_MIMXRT1064_SDK_PATH", - "versions": ["2.10.0"] + ], + "envVar": "EVK_MIMXRT1064_SDK_PATH", + "versions": ["2.10.0"] }, "compatVersion": "1", "freeRTOS": { @@ -49,7 +51,7 @@ constexpr auto nxp_1064_json = R"({ "id": "NXP_FREERTOS_DIR", "optional": false, "type": "path" - } + } ], "envVar": "IMXRT1064_FREERTOS_DIR" }, diff --git a/src/plugins/mcusupport/test/armgcc_stm32f769i_freertos_json.h b/src/plugins/mcusupport/test/armgcc_stm32f769i_freertos_json.h new file mode 100644 index 00000000000..1695d83244e --- /dev/null +++ b/src/plugins/mcusupport/test/armgcc_stm32f769i_freertos_json.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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-3.0.html. +** +****************************************************************************/ + +#pragma once + +constexpr auto armgcc_stm32f769i_freertos_json = R"({ + "qulVersion": "@CMAKE_PROJECT_VERSION@", + "compatVersion": "@COMPATIBILITY_VERSION@", + "platform": { + "id": "STM32F769I-DISCOVERY-FREERTOS", + "vendor": "ST", + "colorDepths": [ + 32 + ], + "pathEntries": [ + { + "id": "STM32CubeProgrammer_PATH", + "id": "STM32CubeProgrammer_PATH", + "description": "STM32CubeProgrammer", + "type": "path", + "defaultValue": { + "windows": "$PROGRAMSANDFILES/STMicroelectronics/STM32Cube/STM32CubeProgrammer/", + "unix": "$HOME/STMicroelectronics/STM32Cube/STM32CubeProgrammer/" + }, + "optional": false + } + ], + "environmentEntries": [], + "cmakeCacheEntries": [ + { + "id": "Qul_DIR", + "description": "Qt for MCUs SDK", + "type": "path", + "cmakeOptionName": "Qul_ROOT", + "optional": false + } + ] + }, + "toolchain": { + "id": "armgcc", + "versions": [ + "9.3.1" + ], + "cmakeCacheEntries": [ + { + "id": "ARMGCC_DIR", + "description": "GNU Arm Embedded Toolchain", + "cmakeOptionName": "QUL_TARGET_TOOLCHAIN_DIR", + "type": "path", + "optional": false + }, + { + "id": "ARMGCC_CMAKE_TOOLCHAIN_FILE", + "description": "CMake Toolchain File", + "cmakeOptionName": "CMAKE_TOOLCHAIN_FILE", + "type": "file", + "defaultValue": "$Qul_ROOT/lib/cmake/Qul/toolchain/armgcc.cmake", + "visible": false, + "optional": false + } + ] + }, + "boardSdk": { + "envVar": "STM32Cube_FW_F7_SDK_PATH", + "versions": [ + "1.16.0" + ], + "cmakeCacheEntries": [ + { + "id": "ST_SDK_DIR", + "description": "Board SDK for STM32F769I-Discovery", + "cmakeOptionName": "QUL_BOARD_SDK_DIR", + "type": "path", + "optional": false + } + ] + }, + "freeRTOS": { + "envVar": "STM32F7_FREERTOS_DIR", + "cmakeCacheEntries": [ + { + "id": "ST_FREERTOS_DIR", + "description": "FreeRTOS SDK for STM32F769I-Discovery", + "cmakeOptionName": "FREERTOS_DIR", + "defaultValue": "$QUL_BOARD_SDK_DIR/Middlewares/Third_Party/FreeRTOS/Source", + "type": "path", + "optional": false + } + ] + } +})"; diff --git a/src/plugins/mcusupport/test/armgcc_stm32h750b_metal_json.h b/src/plugins/mcusupport/test/armgcc_stm32h750b_metal_json.h new file mode 100644 index 00000000000..51484538e6b --- /dev/null +++ b/src/plugins/mcusupport/test/armgcc_stm32h750b_metal_json.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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-3.0.html. +** +****************************************************************************/ + +#pragma once + +constexpr auto armgcc_stm32h750b_metal_json = R"({ + "qulVersion": "2.0.0", + "compatVersion": "1", + "platform": { + "id": "STM32H750B-DISCOVERY-BAREMETAL", + "vendor": "ST", + "colorDepths": [ + 32 + ], + "pathEntries": [ + { + "id": "STM32CubeProgrammer_PATH", + "description": "STM32CubeProgrammer", + "type": "path", + "defaultValue": { + "windows": "$PROGRAMSANDFILES/STMicroelectronics/STM32Cube/STM32CubeProgrammer/", + "unix": "$HOME/STMicroelectronics/STM32Cube/STM32CubeProgrammer/" + }, + "optional": false + } + ], + "environmentEntries": [], + "cmakeCacheEntries": [ + { + "id": "Qul_DIR", + "description": "Qt for MCUs SDK", + "type": "path", + "cmakeOptionName": "Qul_ROOT", + "optional": false + } + ] + }, + "toolchain": { + "id": "armgcc", + "versions": [ + "9.3.1" + ], + "cmakeCacheEntries": [ + { + "id": "ARMGCC_DIR", + "description": "GNU Arm Embedded Toolchain", + "cmakeOptionName": "QUL_TARGET_TOOLCHAIN_DIR", + "type": "path", + "optional": false + }, + { + "id": "ARMGCC_CMAKE_TOOLCHAIN_FILE", + "description": "CMake Toolchain File", + "cmakeOptionName": "CMAKE_TOOLCHAIN_FILE", + "type": "file", + "defaultValue": "$Qul_ROOT/lib/cmake/Qul/toolchain/armgcc.cmake", + "visible": false, + "optional": false + } + ] + }, + "boardSdk": { + "envVar": "STM32Cube_FW_H7_SDK_PATH", + "versions": [ + "1.5.0" + ], + "cmakeCacheEntries": [ + { + "id": "ST_SDK_DIR", + "description": "Board SDK for STM32H750B-Discovery", + "cmakeOptionName": "QUL_BOARD_SDK_DIR", + "type": "path", + "optional": false + } + ] + } +})"; diff --git a/src/plugins/mcusupport/test/iar_stm32f469i_metal_json.h b/src/plugins/mcusupport/test/iar_stm32f469i_metal_json.h new file mode 100644 index 00000000000..6a738729cae --- /dev/null +++ b/src/plugins/mcusupport/test/iar_stm32f469i_metal_json.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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-3.0.html. +** +****************************************************************************/ + +#pragma once + +constexpr auto iar_stm32f469i_metal_json = R"({ + "qulVersion": "@CMAKE_PROJECT_VERSION@", + "compatVersion": "@COMPATIBILITY_VERSION@", + "platform": { + "id": "STM32F469I-DISCOVERY-BAREMETAL", + "vendor": "ST", + "colorDepths": [ + 24 + ], + "pathEntries": [ + { + "id": "STM32CubeProgrammer_PATH", + "description": "STM32CubeProgrammer", + "type": "path", + "defaultValue": { + "windows": "$PROGRAMSANDFILES/STMicroelectronics/STM32Cube/STM32CubeProgrammer/", + "unix": "$HOME/STMicroelectronics/STM32Cube/STM32CubeProgrammer/" + }, + "optional": false + } + ], + "environmentEntries": [], + "cmakeCacheEntries": [ + { + "id": "Qul_DIR", + "description": "Qt for MCUs SDK", + "type": "path", + "cmakeOptionName": "Qul_ROOT", + "optional": false + } + ] + }, + "toolchain": { + "id": "iar", + "versions": [ + "8.50.9" + ], + "cmakeCacheEntries": [ + { + "id": "IARToolchain", + "envVar": "IAR_ARM_COMPILER_DIR", + "description": "IAR ARM Compiler", + "cmakeOptionName": "QUL_TARGET_TOOLCHAIN_DIR", + "type": "path", + "optional": false + }, + { + "id": "IAR_CMAKE_TOOLCHAIN_FILE", + "description": "CMake Toolchain File", + "cmakeOptionName": "CMAKE_TOOLCHAIN_FILE", + "type": "file", + "defaultValue": "$Qul_ROOT/lib/cmake/Qul/toolchain/iar.cmake", + "visible": false, + "optional": false + } + ] + }, + "boardSdk": { + "envVar": "STM32Cube_FW_F4_SDK_PATH", + "versions": [ + "1.25.0" + ], + "cmakeCacheEntries": [ + { + "id": "ST_SDK_DIR", + "description": "Board SDK for STM32F469I-Discovery", + "cmakeOptionName": "QUL_BOARD_SDK_DIR", + "type": "path", + "optional": false + } + ] + } +})"; diff --git a/src/plugins/mcusupport/test/packagemock.h b/src/plugins/mcusupport/test/packagemock.h index 2e41ef6550b..6857702d127 100644 --- a/src/plugins/mcusupport/test/packagemock.h +++ b/src/plugins/mcusupport/test/packagemock.h @@ -42,6 +42,7 @@ public: MOCK_METHOD(Utils::FilePath, detectionPath, (), (const)); MOCK_METHOD(QString, statusText, (), (const)); MOCK_METHOD(void, updateStatus, ()); + MOCK_METHOD(QString, settingsKey, (), (const)); MOCK_METHOD(Status, status, (), (const)); MOCK_METHOD(bool, isValidStatus, (), (const)); diff --git a/src/plugins/mcusupport/test/unittest.cpp b/src/plugins/mcusupport/test/unittest.cpp index f2a7dfddc4b..0ad964ae6ee 100644 --- a/src/plugins/mcusupport/test/unittest.cpp +++ b/src/plugins/mcusupport/test/unittest.cpp @@ -24,18 +24,39 @@ ****************************************************************************/ #include "unittest.h" -#include "mcutargetdescription.h" +#include "armgcc_nxp_1050_json.h" +#include "armgcc_nxp_1064_json.h" +#include "armgcc_stm32f769i_freertos_json.h" +#include "armgcc_stm32h750b_metal_json.h" +#include "iar_stm32f469i_metal_json.h" #include "mcukitmanager.h" -#include "nxp_1064_json.h" +#include "mcusupportconstants.h" +#include "mcusupportsdk.h" +#include "mcutargetdescription.h" #include "utils/filepath.h" + #include #include #include #include #include +#include +#include +#include namespace McuSupport::Internal::Test { +static const QString nxp1050FreeRtosEnvVar{"IMXRT1050_FREERTOS_DIR"}; +static const QString nxp1064FreeRtosEnvVar{"IMXRT1064_FREERTOS_DIR"}; +static const QString nxp1170FreeRtosEnvVar{"EVK_MIMXRT1170_FREERTOS_PATH"}; +static const QString stm32f7FreeRtosEnvVar{"STM32F7_FREERTOS_DIR"}; +static const QString stm32f7{"STM32F7"}; +static const QString nxp1170{"EVK_MIMXRT1170"}; +static const QString nxp1050{"IMXRT1050"}; +static const QString nxp1064{"IMXRT1064"}; + +static const QStringList jsonFiles{armgcc_nxp_1050_json, armgcc_nxp_1064_json}; + using CMakeProjectManager::CMakeConfigItem; using CMakeProjectManager::CMakeConfigurationKitAspect; using ProjectExplorer::EnvironmentKitAspect; @@ -54,7 +75,7 @@ void McuSupportTest::initTestCase() void McuSupportTest::test_parseBasicInfoFromJson() { - const auto description = Sdk::parseDescriptionJson(nxp_1064_json); + const auto description = Sdk::parseDescriptionJson(armgcc_nxp_1064_json); QVERIFY(!description.freeRTOS.envVar.isEmpty()); QVERIFY(description.freeRTOS.boardSdkSubDir.isEmpty()); @@ -91,9 +112,96 @@ void McuSupportTest::test_addFreeRtosCmakeVarToKit() const auto &cmakeConfig{CMakeConfigurationKitAspect::configuration(&kit)}; QCOMPARE(cmakeConfig.size(), 1); - CMakeConfigItem expectedCmakeVar{freeRtosCmakeVar.toLocal8Bit(), - FilePath::fromString(defaultfreeRtosPath).toUserOutput().toLocal8Bit()}; + CMakeConfigItem + expectedCmakeVar{freeRtosCmakeVar.toLocal8Bit(), + FilePath::fromString(defaultfreeRtosPath).toUserOutput().toLocal8Bit()}; QVERIFY(cmakeConfig.contains(expectedCmakeVar)); } +void McuSupportTest::test_createPackagesWithCorrespondingSettings_data() +{ + QTest::addColumn("json"); + QTest::addColumn>("expectedSettings"); + + QSet commonSettings{{"CypressAutoFlashUtil"}, + {"GHSArmToolchain"}, + {"GHSToolchain"}, + {"GNUArmEmbeddedToolchain"}, + {"IARToolchain"}, + {"MCUXpressoIDE"}, + {"RenesasFlashProgrammer"}, + {"Stm32CubeProgrammer"}}; + + QTest::newRow("nxp1064") << armgcc_nxp_1064_json + << QSet{{"EVK_MIMXRT1064_SDK_PATH"}, + {QString{Constants::SETTINGS_KEY_FREERTOS_PREFIX} + .append("IMXRT1064")}} + .unite(commonSettings); + QTest::newRow("nxp1050") << armgcc_nxp_1050_json + << QSet{{"EVKB_IMXRT1050_SDK_PATH"}, + {QString{Constants::SETTINGS_KEY_FREERTOS_PREFIX} + .append("IMXRT1050")}} + .unite(commonSettings); + + QTest::newRow("stm32h750b") << armgcc_stm32h750b_metal_json + << QSet{{"STM32Cube_FW_H7_SDK_PATH"}}.unite(commonSettings); + + QTest::newRow("stm32f769i") << armgcc_stm32f769i_freertos_json + << QSet{{"STM32Cube_FW_F7_SDK_PATH"}}.unite(commonSettings); + + QTest::newRow("stm32f469i") << iar_stm32f469i_metal_json + << QSet{{"STM32Cube_FW_F4_SDK_PATH"}}.unite(commonSettings); +} + +void McuSupportTest::test_createPackagesWithCorrespondingSettings() +{ + QFETCH(QString, json); + const auto description = Sdk::parseDescriptionJson(json.toLocal8Bit()); + QVector packages; + const auto targets = Sdk::targetsFromDescriptions({description}, &packages); + + QSet settings; + std::transform(packages.begin(), + packages.end(), + std::inserter(settings, settings.end()), + [](const auto &package) { return package->settingsKey(); }); + + QFETCH(QSet, expectedSettings); + QVERIFY(settings.contains(expectedSettings)); +} + +//TODO(piotr.mucko): Enable when mcutargetfactory is delivered. +void McuSupportTest::test_createFreeRtosPackageWithCorrectSetting() +{ + // Sdk::targetsAndPackages(jsonFile, &mcuSdkRepo); + // + // QVector mcuPackages; + // auto mcuTargets = Sdk::targetsFromDescriptions({description}, &mcuPackages); + // QVERIFY(mcuPackages contains freertos package) + // QVERIFY(freertos package is not empty & has proper value) + + // McuSupportOptions mcuSuportOptions{}; + // mcuSuportOptions.createAutomaticKits(); + + QFETCH(QString, freeRtosEnvVar); + QFETCH(QString, expectedSettingsKey); + + auto *package{Sdk::createFreeRTOSSourcesPackage(freeRtosEnvVar, FilePath{}, QString{})}; + QVERIFY(package != nullptr); + + QCOMPARE(package->settingsKey(), expectedSettingsKey); + + // QVERIFY(freertos package is not empty & has proper value) + // static McuPackage *createFreeRTOSSourcesPackage(const QString &envVar, + // const FilePath &boardSdkDir, + // const QString &freeRTOSBoardSdkSubDir) + // createFreeRtosPackage + // verify that package's setting is Package_FreeRTOSSourcePackage_IMXRT1064. + //TODO(me): write settings + // auto *freeRtosPackage + // = new McuPackage; + // freeRtosPackage->writeToSettings(); + //TODO(me): verify that setting is the same as in 2.0.0 +} + } // namespace McuSupport::Internal::Test diff --git a/src/plugins/mcusupport/test/unittest.h b/src/plugins/mcusupport/test/unittest.h index 0b1476a75f3..1c5fb0355c6 100644 --- a/src/plugins/mcusupport/test/unittest.h +++ b/src/plugins/mcusupport/test/unittest.h @@ -55,6 +55,9 @@ private slots: void test_addFreeRtosCmakeVarToKit(); void test_addNewKit(); void test_parseBasicInfoFromJson(); + void test_createPackagesWithCorrespondingSettings(); + void test_createPackagesWithCorrespondingSettings_data(); + void test_createFreeRtosPackageWithCorrectSetting(); private: QVersionNumber currentQulVersion{2, 0};