From 9d0751e2b1c357b4896a6948335010a3bd5a2308 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 16 Apr 2018 11:48:36 +0800 Subject: [PATCH 1/4] =?UTF-8?q?ci:=20support=20jobs=20which=20don=E2=80=99?= =?UTF-8?q?t=20run=20unless=20triggered=20by=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, any job will run unless a filter is given, in that case the filter will determine if the job should run or not. Some jobs do not need to be run by default, and should only be triggered using the bot. For such jobs, BOT_NEEDS_TRIGGER_BY_NAME can added to environment variables. --- tools/ci/apply_bot_filter.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/ci/apply_bot_filter.py b/tools/ci/apply_bot_filter.py index 26f458836e..29c8bb565e 100755 --- a/tools/ci/apply_bot_filter.py +++ b/tools/ci/apply_bot_filter.py @@ -28,8 +28,8 @@ def parse_filter(filter_name): return filters -def process_filter(filter_name, ci_name): - execute = True +def process_filter(execute_by_default, filter_name, ci_name): + execute = execute_by_default # bot message is case insensitive (processed with lower case). so we also convert ci_name to lower case. ci_name = ci_name.lower() @@ -51,8 +51,12 @@ def process_filter(filter_name, ci_name): if __name__ == "__main__": - need_to_execute = process_filter("BOT_STAGE_FILTER", os.getenv("CI_JOB_STAGE")) \ - and process_filter("BOT_JOB_FILTER", os.getenv("CI_JOB_NAME")) + execute_by_default = True + if os.getenv("BOT_NEEDS_TRIGGER_BY_NAME", "0") == "1": + execute_by_default = False + + need_to_execute = process_filter(True, "BOT_STAGE_FILTER", os.getenv("CI_JOB_STAGE")) \ + and process_filter(execute_by_default, "BOT_JOB_FILTER", os.getenv("CI_JOB_NAME")) if need_to_execute: sys.exit(0) else: From 6545f8eaf379d0149dc9c9d904299552d087ef1b Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 16 Apr 2018 11:50:12 +0800 Subject: [PATCH 2/4] nvs: add long ci test for power off recovery and coverage This test can be triggered manually: `bot test name: test_nvs_coverage` --- .gitlab-ci.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f1b560d76..b2e0bb5573 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -243,6 +243,24 @@ test_nvs_on_host: - cd components/nvs_flash/test_nvs_host - make test +test_nvs_coverage: + stage: test + image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG + tags: + - nvs_host_test + dependencies: [] + artifacts: + paths: + - components/nvs_flash/test_nvs_host/coverage_report + only: + - triggers + # This job takes a few hours to finish, so only run it on demand + variables: + BOT_NEEDS_TRIGGER_BY_NAME: 1 + script: + - cd components/nvs_flash/test_nvs_host + - make coverage_report + test_partition_table_on_host: stage: test image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG From f8cb95d0b853111065b9330813c1612ffacfeb5d Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 16 Apr 2018 15:02:11 +0800 Subject: [PATCH 3/4] nvs: print progress in nvs API tests, reduce number of iterations --- components/nvs_flash/test_nvs_host/test_nvs.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/nvs_flash/test_nvs_host/test_nvs.cpp b/components/nvs_flash/test_nvs_host/test_nvs.cpp index f35edf5b2d..c20ea9a27d 100644 --- a/components/nvs_flash/test_nvs_host/test_nvs.cpp +++ b/components/nvs_flash/test_nvs_host/test_nvs.cpp @@ -722,7 +722,14 @@ TEST_CASE("can init storage from flash with random contents", "[nvs]") TEST_CASE("nvs api tests, starting with random data in flash", "[nvs][.][long]") { - for (size_t count = 0; count < 10000; ++count) { + const size_t testIters = 3000; + int lastPercent = -1; + for (size_t count = 0; count < testIters; ++count) { + int percentDone = (int) (count * 100 / testIters); + if (percentDone != lastPercent) { + lastPercent = percentDone; + printf("%d%%\n", percentDone); + } SpiFlashEmulator emu(10); emu.randomize(static_cast(count)); From 6f504deed07cff96ae5eac11fea90341113e013a Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 16 Apr 2018 11:51:43 +0800 Subject: [PATCH 4/4] nvs: run all test by default, exclude long tests by tag Reduces the chance of new tests being skipped in CI --- components/nvs_flash/test_nvs_host/Makefile | 6 +++--- components/nvs_flash/test_nvs_host/test_nvs.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/nvs_flash/test_nvs_host/Makefile b/components/nvs_flash/test_nvs_host/Makefile index f1f5b52f26..3696304949 100644 --- a/components/nvs_flash/test_nvs_host/Makefile +++ b/components/nvs_flash/test_nvs_host/Makefile @@ -37,10 +37,10 @@ $(OUTPUT_DIR): mkdir -p $(OUTPUT_DIR) test: $(TEST_PROGRAM) - ./$(TEST_PROGRAM) + ./$(TEST_PROGRAM) -d yes exclude:[long] long-test: $(TEST_PROGRAM) - ./$(TEST_PROGRAM) [list],[enumtable],[spi_flash_emu],[nvs],[long] + ./$(TEST_PROGRAM) -d yes $(COVERAGE_FILES): $(TEST_PROGRAM) long-test @@ -58,4 +58,4 @@ clean: rm -rf coverage_report/ rm -f coverage.info -.PHONY: clean all test +.PHONY: clean all test long-test diff --git a/components/nvs_flash/test_nvs_host/test_nvs.cpp b/components/nvs_flash/test_nvs_host/test_nvs.cpp index c20ea9a27d..dd013e24ac 100644 --- a/components/nvs_flash/test_nvs_host/test_nvs.cpp +++ b/components/nvs_flash/test_nvs_host/test_nvs.cpp @@ -720,7 +720,7 @@ TEST_CASE("can init storage from flash with random contents", "[nvs]") } -TEST_CASE("nvs api tests, starting with random data in flash", "[nvs][.][long]") +TEST_CASE("nvs api tests, starting with random data in flash", "[nvs][long]") { const size_t testIters = 3000; int lastPercent = -1; @@ -984,7 +984,7 @@ TEST_CASE("monkey test", "[nvs][monkey]") s_perf << "Monkey test: nErase=" << emu.getEraseOps() << " nWrite=" << emu.getWriteOps() << std::endl; } -TEST_CASE("test recovery from sudden poweroff", "[.][long][nvs][recovery][monkey]") +TEST_CASE("test recovery from sudden poweroff", "[long][nvs][recovery][monkey]") { std::random_device rd; std::mt19937 gen(rd());