From efef49c3616a0ca07b840df940a6cb5a1b7cb6fb Mon Sep 17 00:00:00 2001 From: Andrii Filippov Date: Fri, 29 Aug 2025 12:56:10 +0200 Subject: [PATCH 1/2] ci: add first JTAG Flash test bump IDF version to 5.4 to solve board detection issue Temporary isolate test for Linux runner only --- .github/workflows/ci.yml | 2 +- .../project/IDFProjectJTAGFlashTest.java | 166 ++++++++++++++++++ ...ewEspressifIDFProjectFlashProcessTest.java | 26 ++- .../operations/ProjectTestOperations.java | 11 +- 4 files changed, 195 insertions(+), 10 deletions(-) create mode 100644 tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectJTAGFlashTest.java diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12641fe44..9eb43b58d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: repository: espressif/esp-idf path: dependencies/idf-tools submodules: 'true' - ref: release/v5.1 + ref: release/v5.4 - name: Set up Python uses: actions/setup-python@v2 diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectJTAGFlashTest.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectJTAGFlashTest.java new file mode 100644 index 000000000..cd017ed0e --- /dev/null +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectJTAGFlashTest.java @@ -0,0 +1,166 @@ +/******************************************************************************* + * Copyright 2025 Espressif Systems (Shanghai) PTE LTD. + * All rights reserved. Use is subject to license terms. + *******************************************************************************/ + +package com.espressif.idf.ui.test.executable.cases.project; + +import java.io.IOException; + +import org.apache.commons.lang3.SystemUtils; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import com.espressif.idf.ui.test.common.WorkBenchSWTBot; +import static org.eclipse.swtbot.swt.finder.waits.Conditions.*; +import static org.junit.Assert.assertTrue; + +import com.espressif.idf.ui.test.common.utility.TestWidgetWaitUtility; +import com.espressif.idf.ui.test.operations.EnvSetupOperations; +import com.espressif.idf.ui.test.operations.ProjectTestOperations; +import com.espressif.idf.ui.test.operations.selectors.LaunchBarConfigSelector; +import com.espressif.idf.ui.test.operations.selectors.LaunchBarTargetSelector; + +/** + * Test class to test JTAG Flash Process + * + * @author Andrii Filippov + * + */ + +@SuppressWarnings("restriction") +@RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class IDFProjectJTAGFlashTest +{ + @BeforeClass + public static void beforeTestClass() throws Exception + { + Fixture.loadEnv(); + } + + @After + public void afterEachTest() + { + try + { + Fixture.cleanTestEnv(); + } + catch (Exception e) + { + System.err.println("Error during cleanup: " + e.getMessage()); + } + } + + @Test + public void givenNewProjectCreatedWhenSelectJTAGflashWhenBuiltThenCheckFlashedSuccessfully() throws Exception + { + if (SystemUtils.IS_OS_LINUX) //temporary solution until new ESP boards arrive for Windows + { + Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); + Fixture.givenProjectNameIs("NewProject"); + Fixture.whenNewProjectIsSelected(); + Fixture.whenSelectJTAGflashInLaunchConfig(); + Fixture.whenSelectLaunchTargetBoard(); + Fixture.whenProjectIsBuiltUsingContextMenu(); + Fixture.whenFlashProject(); + Fixture.thenVerifyJTAGflashDone(); + } + else + { + assertTrue(true); + } + } + + private static class Fixture + { + private static SWTWorkbenchBot bot; + private static String category; + private static String subCategory; + private static String projectName; + + private static void loadEnv() throws Exception + { + bot = WorkBenchSWTBot.getBot(); + EnvSetupOperations.setupEspressifEnv(bot); + bot.sleep(1000); + ProjectTestOperations.deleteAllProjects(bot); + } + + private static void givenNewEspressifIDFProjectIsSelected(String category, String subCategory) + { + Fixture.category = category; + Fixture.subCategory = subCategory; + } + + private static void givenProjectNameIs(String projectName) + { + Fixture.projectName = projectName; + } + + private static void whenNewProjectIsSelected() throws Exception + { + ProjectTestOperations.setupProject(projectName, category, subCategory, bot); + } + + private static void whenProjectIsBuiltUsingContextMenu() throws IOException + { + ProjectTestOperations.buildProjectUsingContextMenu(projectName, bot); + ProjectTestOperations.waitForProjectBuild(bot); + TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot); + } + + private static void whenFlashProject() throws IOException + { + ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Run Configurations..."); + TestWidgetWaitUtility.waitForDialogToAppear(bot, "Run Configurations", 10000); + bot.tree().getTreeItem("ESP-IDF Application").select(); + bot.tree().getTreeItem("ESP-IDF Application").expand(); + bot.tree().getTreeItem("ESP-IDF Application").getNode(projectName).select(); + bot.waitUntil(widgetIsEnabled(bot.button("Run")), 5000); + bot.button("Run").click(); + } + + private static void whenSelectJTAGflashInLaunchConfig() throws Exception + { + LaunchBarConfigSelector configSelector = new LaunchBarConfigSelector(bot); + configSelector.clickEdit(); + TestWidgetWaitUtility.waitForDialogToAppear(bot, "Edit Configuration", 20000); + bot.cTabItem("Main").show(); + bot.cTabItem("Main").setFocus(); + bot.comboBoxWithLabel("Flash over:").setSelection("JTAG"); + bot.button("OK").click(); + } + + private static void whenSelectLaunchTargetBoard() throws Exception + { + LaunchBarTargetSelector targetSelector = new LaunchBarTargetSelector(bot); + targetSelector.clickEdit(); + TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target", 20000); + SWTBotShell shell = bot.shell("New ESP Target"); + bot.comboBoxWithLabel("Board:").setSelection("ESP32-ETHERNET-KIT [usb://1-10]"); + TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot); + shell.setFocus(); + bot.button("Finish").click(); + } + + private static void thenVerifyJTAGflashDone() throws Exception + { + ProjectTestOperations.verifyTheConsoleOutput(bot, "** Flashing done for partition_table/partition-table.bin"); + } + + private static void cleanTestEnv() + { + TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot); + ProjectTestOperations.closeAllProjects(bot); + ProjectTestOperations.deleteAllProjects(bot); + } + } +} diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectFlashProcessTest.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectFlashProcessTest.java index 13111a58b..a916828dd 100644 --- a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectFlashProcessTest.java +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/NewEspressifIDFProjectFlashProcessTest.java @@ -6,8 +6,11 @@ import java.io.IOException; +import org.apache.commons.lang3.SystemUtils; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import static org.eclipse.swtbot.swt.finder.waits.Conditions.*; +import static org.junit.Assert.assertTrue; + import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; @@ -60,14 +63,21 @@ public void afterEachTest() public void givenNewProjectCreatedBuiltWhenSelectSerialPortWhenFlashThenCheckFlashedSuccessfully() throws Exception { - Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); - Fixture.givenProjectNameIs("NewProjectFlashTest"); - Fixture.whenNewProjectIsSelected(); - Fixture.whenTurnOffOpenSerialMonitorAfterFlashingInLaunchConfig(); - Fixture.whenProjectIsBuiltUsingContextMenu(); - Fixture.whenSelectLaunchTargetSerialPort(); - Fixture.whenFlashProject(); - Fixture.thenVerifyFlashDoneSuccessfully(); + if (SystemUtils.IS_OS_LINUX) //temporary solution until new ESP boards arrive for Windows + { + Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); + Fixture.givenProjectNameIs("NewProjectFlashTest"); + Fixture.whenNewProjectIsSelected(); + Fixture.whenTurnOffOpenSerialMonitorAfterFlashingInLaunchConfig(); + Fixture.whenProjectIsBuiltUsingContextMenu(); + Fixture.whenSelectLaunchTargetSerialPort(); + Fixture.whenFlashProject(); + Fixture.thenVerifyFlashDoneSuccessfully(); + } + else + { + assertTrue(true); + } } private static class Fixture diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java index 4c3f90b72..6ae4172d6 100644 --- a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/operations/ProjectTestOperations.java @@ -52,7 +52,7 @@ public class ProjectTestOperations { private static final String DEFAULT_PROJECT_BUILD_WAIT_PROPERTY = "default.project.build.wait"; - + private static final String DEFAULT_FLASH_WAIT_PROPERTY = "default.project.flash.wait"; private static final Logger logger = LoggerFactory.getLogger(ProjectTestOperations.class); @@ -755,6 +755,15 @@ public static void deletePartitionTableRow(SWTWorkbenchBot bot) throws IOExcepti bot.button("OK").click(); } + + public static void verifyTheConsoleOutput(SWTWorkbenchBot bot, String text) throws IOException + { + SWTBotView view = bot.viewByPartName("Console"); + view.setFocus(); + TestWidgetWaitUtility.waitUntilViewContains(bot, text, view, + DefaultPropertyFetcher.getLongPropertyValue(DEFAULT_FLASH_WAIT_PROPERTY, 120000)); + } + public static void joinJobByName(String jobName) { Job[] jobs = Job.getJobManager().find(null); From 90adbf332ca4e92a8ec67ec4e80816ef0b103b9b Mon Sep 17 00:00:00 2001 From: Andrii Filippov Date: Thu, 4 Sep 2025 19:26:58 +0200 Subject: [PATCH 2/2] ci: change projectName --- .../test/executable/cases/project/IDFProjectJTAGFlashTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectJTAGFlashTest.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectJTAGFlashTest.java index cd017ed0e..d06ef0d63 100644 --- a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectJTAGFlashTest.java +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectJTAGFlashTest.java @@ -65,7 +65,7 @@ public void givenNewProjectCreatedWhenSelectJTAGflashWhenBuiltThenCheckFlashedSu if (SystemUtils.IS_OS_LINUX) //temporary solution until new ESP boards arrive for Windows { Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project"); - Fixture.givenProjectNameIs("NewProject"); + Fixture.givenProjectNameIs("NewProjectJTAGFlashTest"); Fixture.whenNewProjectIsSelected(); Fixture.whenSelectJTAGflashInLaunchConfig(); Fixture.whenSelectLaunchTargetBoard();