summaryrefslogtreecommitdiff
path: root/zephyr/Makefile.cq
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2022-11-30 15:33:14 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-12-02 04:24:21 +0000
commit72ae3419d58a781bb2f01f3e24f095989f193719 (patch)
tree8794cc3448adaa10e240de08c579546b8a2f9fe3 /zephyr/Makefile.cq
parent66448fe689d155b3e906fd1f047aaefadf7ab6bd (diff)
downloadchrome-ec-72ae3419d58a781bb2f01f3e24f095989f193719.tar.gz
cq: Run steps in parallel by moving logic to make
In order to get everything to run in parallel, just migrate most of the test logic to a makefile, and call make from the python script. When building locally, this saved 30% of the time, and got the same coverage metrics, so I assume the same tests and builds were run. BRANCH=None BUG=None TEST=Ran builder locally, compared metrics with prior commit. Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I7429c35e4a30ad05e092d5aa73d523f3c676e8e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4068492 Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'zephyr/Makefile.cq')
-rw-r--r--zephyr/Makefile.cq131
1 files changed, 131 insertions, 0 deletions
diff --git a/zephyr/Makefile.cq b/zephyr/Makefile.cq
new file mode 100644
index 0000000000..ae12f5604e
--- /dev/null
+++ b/zephyr/Makefile.cq
@@ -0,0 +1,131 @@
+# -*- makefile -*-
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This makefile is used only by firmware_builder.py to achieve parallelism.
+# The paths in this file need to match the ones in firmware_builder.py,
+# so be careful.
+
+# This also assumes that you ran zmake build -a before this in the build stage
+
+TWISTER_COMMAND=cd $(PLATFORM_EC) && ./twister --outdir \
+ twister-out-$(TOOLCHAIN) -v -i --no-upload-cros-rdb --toolchain \
+ $(TOOLCHAIN)
+ifdef COVERAGE
+TWISTER_COMMAND+=--coverage
+endif
+
+PLATFORM_EC=$(abspath ..)
+THIRD_PARTY=$(abspath ../../../third_party)
+BUILD=$(PLATFORM_EC)/build
+
+GENERATED_AND_SYSTEM_PATTERNS='$(PLATFORM_EC)/build/**' \
+ '$(PLATFORM_EC)/twister-out*/**' \
+ '/usr/include/**' \
+ '/usr/lib/**'
+TEST_PATTERNS='$(PLATFORM_EC)/test/**' \
+ '$(PLATFORM_EC)/include/tests/**' \
+ '$(PLATFORM_EC)/private/test/**' \
+ '$(PLATFORM_EC)/private/fingerprint/*/mcutest/**' \
+ '$(PLATFORM_EC)/zephyr/test/**' \
+ '$(THIRD_PARTY)/zephyr/main/subsys/testsuite/**' \
+ '$(PLATFORM_EC)/include/mock/**' \
+ '$(PLATFORM_EC)/common/mock/**' \
+ '$(PLATFORM_EC)/board/host/**' \
+ '$(PLATFORM_EC)/chip/host/**' \
+ '$(PLATFORM_EC)/core/host/**' \
+ '$(PLATFORM_EC)/zephyr/emul/**' \
+ '$(PLATFORM_EC)/zephyr/mock/**' \
+ '$(THIRD_PARTY)/zephyr/main/subsys/emul/**' \
+ '$(THIRD_PARTY)/zephyr/main/arch/posix/**' \
+ '**/*_test.c' \
+ '**/*_test.h' \
+ '**/*_emul.c' \
+ '**/*_emul.h' \
+ '$(PLATFORM_EC)/include/test_util.h' \
+ '$(PLATFORM_EC)/common/test_util.c' \
+ '$(PLATFORM_EC)/zephyr/shim/src/test_util.c' \
+ '$(PLATFORM_EC)/zephyr/shim/src/ztest_system.c'
+
+.PHONY: test twister_host twister_llvm
+
+test: zmake_unit_tests
+ifdef COVERAGE
+# List all of the files expected by firmware_builder.py
+test: $(PLATFORM_EC)/twister-out-llvm/coverage.info # EC_ZEPHYR_TESTS
+test: $(PLATFORM_EC)/twister-out-host/coverage.info # EC_ZEPHYR_TESTS_GCC
+test: $(BUILD)/coverage/lcov.info # EC_LEGACY_TESTS
+test: $(BUILD)/zephyr/all_tests.info # ALL_TESTS
+test: $(BUILD)/zephyr/zephyr_merged.info # EC_ZEPHYR_MERGED
+test: $(BUILD)/zephyr/lcov.info # ALL_MERGED
+test: $(BUILD)/zephyr/lcov_no_tests.info # ALL_FILTERED
+test: $(BUILD)/zephyr/lcov_rpt # html artifact
+test: special_boards # BOARD_ metric and html artifact
+else
+test: twister_host twister_llvm
+endif
+
+zmake_unit_tests:
+ zmake/run_tests.sh
+
+twister_host $(PLATFORM_EC)/twister-out-host/coverage.info: TOOLCHAIN=host
+twister_host $(PLATFORM_EC)/twister-out-host/coverage.info:
+ +$(TWISTER_COMMAND)
+
+twister_llvm $(PLATFORM_EC)/twister-out-llvm/coverage.info: TOOLCHAIN=llvm
+twister_llvm $(PLATFORM_EC)/twister-out-llvm/coverage.info:
+ +$(TWISTER_COMMAND)
+
+$(BUILD)/coverage/lcov.info:
+ $(MAKE) -C .. test-coverage
+
+$(BUILD)/zephyr/all_tests.info: $(PLATFORM_EC)/twister-out-host/coverage.info $(PLATFORM_EC)/twister-out-llvm/coverage.info $(BUILD)/coverage/lcov.info
+ /usr/bin/lcov -o $@ --rc lcov_branch_coverage=1 \
+ -a $(BUILD)/coverage/lcov.info -a $(PLATFORM_EC)/twister-out-llvm/coverage.info \
+ -a $(PLATFORM_EC)/twister-out-host/coverage.info
+
+$(BUILD)/zephyr/zephyr_merged.info: $(BUILD)/zephyr/all_tests.info $(BUILD)/zephyr/all_builds.info
+ /usr/bin/lcov -o $@ --rc lcov_branch_coverage=1 \
+ -a $(BUILD)/zephyr/all_tests.info -a $(BUILD)/zephyr/all_builds.info
+
+$(BUILD)/zephyr/lcov.info: $(BUILD)/zephyr/zephyr_merged.info
+ /usr/bin/lcov -o $@ --rc lcov_branch_coverage=1 \
+ -r $(BUILD)/zephyr/zephyr_merged.info \
+ $(GENERATED_AND_SYSTEM_PATTERNS)
+
+$(BUILD)/zephyr/lcov_no_tests.info: $(BUILD)/zephyr/lcov.info
+ /usr/bin/lcov -o $@ --rc lcov_branch_coverage=1 \
+ -r $(BUILD)/zephyr/lcov.info \
+ $(TEST_PATTERNS)
+
+$(BUILD)/zephyr/lcov_rpt: $(BUILD)/zephyr/lcov.info
+ /usr/bin/genhtml --branch-coverage -q -o $@ \
+ -t 'All boards and tests merged' -s $^
+
+special_boards: $(foreach b, $(SPECIAL_BOARDS), $(BUILD)/zephyr/$(b)_rpt)
+
+$(BUILD)/zephyr/%_merged.info: $(BUILD)/zephyr/%/output/zephyr.info $(BUILD)/zephyr/all_tests.info
+ /usr/bin/lcov -o $@ --rc lcov_branch_coverage=1 \
+ -a $(BUILD)/zephyr/all_tests.info -a $<
+
+$(BUILD)/zephyr/%_stenciled.info: $(BUILD)/zephyr/%/output/zephyr.info $(BUILD)/zephyr/%_merged.info
+ $(PLATFORM_EC)/util/lcov_stencil.py -o $@ $^
+
+.PRECIOUS: $(BUILD)/zephyr/%_final.info
+$(BUILD)/zephyr/%_final.info: $(BUILD)/zephyr/%_stenciled.info
+ /usr/bin/lcov -o $@ --rc lcov_branch_coverage=1 \
+ -r $< \
+ '$(THIRD_PARTY)/**' \
+ '$(PLATFORM_EC)/zephyr/drivers/**' \
+ '$(PLATFORM_EC)/zephyr/include/drivers/**' \
+ '$(PLATFORM_EC)/zephyr/program/**' \
+ '$(PLATFORM_EC)/zephyr/shim/chip/**' \
+ '$(PLATFORM_EC)/zephyr/shim/chip/npcx/npcx_monitor/**' \
+ '$(PLATFORM_EC)/zephyr/shim/core/**' \
+ $(GENERATED_AND_SYSTEM_PATTERNS) $(TEST_PATTERNS)
+
+.PRECIOUS: $(BUILD)/zephyr/%_rpt
+$(BUILD)/zephyr/%_rpt: $(BUILD)/zephyr/%_final.info
+ /usr/bin/genhtml --branch-coverage -q -o $@ \
+ -t '$* ec code only' -s $^