blob: ff55df059b2169221ea77e5dcfceb166628de0d9 [file] [log] [blame]
Patrick Georgi7333a112020-05-08 20:48:04 +02001## SPDX-License-Identifier: GPL-2.0-only
Martin Rothe624e272017-07-31 11:52:58 -06002
Martin Roth6c9c1962017-08-03 09:25:43 -06003test-help help::
4 @echo '*** coreboot test targets ***'
Martin Roth6202fbb2022-11-12 21:40:04 -07005 @echo ' what-jenkins-does - Run platform build tests with junit output'
6 @echo ' Skip tests by setting env vars JENKINS_SKIP_x_TESTS'
7 @echo ' to 'y' where x is: CLANG, GCC, LINT, TOOL, or UNIT'
8 @echo ' lint / lint-stable - Run coreboot lint tools (all / minimal)'
9 @echo ' test-basic - Run standard build tests. All expected to pass.'
10 @echo ' test-lint - Basic: Run stable and extended lint tests.'
11 @echo ' test-tools - Basic: Tests a basic list of tools.'
12 @echo ' test-abuild - Basic: Builds all platforms'
13 @echo ' test-payloads - Basic: Builds internal payloads'
14 @echo ' test-cleanup - Basic: Cleans coreboot directories'
Jakub Czapiga94828072021-05-17 12:22:48 +020015 @echo
Martin Roth6c9c1962017-08-03 09:25:43 -060016
17# junit.xml is a helper target to wrap builds that don't create junit.xml output
Martin Rothc32c0542018-05-19 17:51:20 -060018# BLD = The name of the build
Martin Roth6c9c1962017-08-03 09:25:43 -060019# BLD_DIR = Top path from coreboot to the build subdirectory
20# MAKETARGET = target to build
Martin Rothe624e272017-07-31 11:52:58 -060021junit.xml:
22 echo "Building $(BLD)"
23 echo '<?xml version="1.0" encoding="utf-8"?><testsuite>' > $@.tmp
24 echo "<testcase classname='$(BLD)' name='$(BLD)'>" >> $@.tmp
Martin Rothc32c0542018-05-19 17:51:20 -060025 -if [ -z "$(BLD_DIR)" ]; then \
26 projdir=""; \
27 xmlfile=junit_$(BLD).xml; \
28 else \
29 projdir="-C $(BLD_DIR)"; \
30 xmlfile="$(BLD_DIR)/$@"; \
31 fi; \
32 if [ -z "$(SKIP_DISTCLEAN)" ]; then \
33 $(MAKE) -j $(CPUS) $$projdir clean distclean > $@.tmp.2 2>&1 ; \
34 fi; \
35 if $(MAKE) -j $(CPUS) $$projdir $(MAKETARGET) >> $@.tmp.2 2>&1; then \
36 type="system-out"; \
37 echo "<$$type>" >> $@.tmp; \
38 echo "Building $(BLD) Succeeded"; \
39 else \
40 type="failure"; \
41 echo "<failure type='buildFailed'>" >> $@.tmp; \
42 echo "Building $(BLD) Failed"; \
43 fi; \
44 cat $@.tmp.2; \
45 echo '<![CDATA[' >> $@.tmp; \
46 cat $@.tmp.2 >> $@.tmp; \
47 echo "]]></$$type>" >>$@.tmp; \
48 rm -f $@.tmp.2; \
49 echo "</testcase>" >> $@.tmp; \
50 echo "</testsuite>" >> $@.tmp; \
51 mv $@.tmp "$$xmlfile"
Martin Rothe624e272017-07-31 11:52:58 -060052 echo
53
54TOOLLIST= \
Patrick Georgic9a9f832020-11-11 10:50:49 +010055amdfwtool \
Martin Rothe61e7782022-02-25 18:12:02 -070056cbfstool \
Martin Roth6c9c1962017-08-03 09:25:43 -060057cbmem \
58ectool \
59futility \
Patrick Georgi19072dc2021-11-25 10:31:10 +010060ifdtool \
Patrick Georgic9a9f832020-11-11 10:50:49 +010061intelmetool \
Martin Roth6c9c1962017-08-03 09:25:43 -060062inteltool \
63intelvbttool \
64nvramtool \
Patrick Georgic9a9f832020-11-11 10:50:49 +010065post \
Angel Pons446e4dc2020-02-12 22:59:40 +010066superiotool
Martin Roth6c9c1962017-08-03 09:25:43 -060067
68TEST_PAYLOADLIST_INTERNAL= \
69coreinfo \
70nvramcui
71
Martin Rothe624e272017-07-31 11:52:58 -060072JENKINS_PAYLOAD?=none
Martin Roth6c9c1962017-08-03 09:25:43 -060073TEST_PAYLOAD?=$(JENKINS_PAYLOAD)
Martin Rothe624e272017-07-31 11:52:58 -060074CPUS?=4
Martin Roth6c9c1962017-08-03 09:25:43 -060075
Martin Rothea383672016-08-30 09:39:48 -060076lint lint-stable lint-extended:
Martin Roth6c9c1962017-08-03 09:25:43 -060077 util/lint/lint $@
78
Martin Rothc45c2fb2022-11-23 12:19:29 -070079ABUILD_OPTIONS=--blobs --junit --cpus $(CPUS) --payloads $(JENKINS_PAYLOAD)
Martin Rothb399f102022-11-19 15:59:27 -070080ABUILD_OPTIONS+=$(if $(V),--verbose,)
81ABUILD_OPTIONS+=$(if $(JENKINS_NOCCACHE),,--ccache)
Patrick Georgi99f0e0c2019-07-25 12:34:43 +020082ABUILD_OPTIONS+=$(JENKINS_ABUILD_OPT)
Patrick Georgic1999732019-07-25 12:24:32 +020083
Patrick Georgi19e1d632019-08-26 17:45:52 +020084COREBOOT_BUILD_DIR?=coreboot-builds
85
Martin Roth1e0f1322022-11-13 09:42:09 -070086validate_sec_tools:
Patrick Georgi673716d2021-09-09 13:42:29 +020087 if [ ! -f 3rdparty/intel-sec-tools/go.mod ]; then \
88 echo "Please download 3rdparty/intel-sec-tools/:"; \
89 echo "git submodule update --init 3rdparty/intel-sec-tools"; \
90 exit 1; \
91 fi
Martin Roth1e0f1322022-11-13 09:42:09 -070092
Martin Roth2852cd22022-11-19 15:49:39 -070093what-jenkins-does: test-cleanup validate_sec_tools
Martin Rothb3f60a52022-11-19 15:53:11 -070094ifneq ($(JENKINS_SKIP_LINT_TESTS),y)
95 JUNIT=--junit $(MAKE) test-lint
Martin Roth1e0f1322022-11-13 09:42:09 -070096endif
Arthur Heymansc44ffc32021-06-17 13:01:58 +020097 cd 3rdparty/intel-sec-tools/ ; go mod vendor
Maximilian Brune1d7a9de2022-04-14 14:54:16 +020098 cd util/goswid ; go mod vendor
Martin Rothdfafe792022-11-19 15:55:45 -070099 $(MAKE) test-abuild
Martin Roth6202fbb2022-11-12 21:40:04 -0700100ifneq ($(JENKINS_SKIP_TOOL_TESTS),y)
Martin Roth36dcaba2022-11-19 16:34:04 -0700101 $(MAKE) test-tools
Martin Roth6202fbb2022-11-12 21:40:04 -0700102endif
103ifneq ($(JENKINS_SKIP_UNIT_TESTS),y)
Jakub Czapigaa0e36d82022-09-06 10:42:16 +0200104 +$(MAKE) junit.xml-unit-tests COV=1
105 +(cd payloads/libpayload; unset COREBOOT_BUILD_DIR; $(MAKE) junit.xml-unit-tests COV=1)
106 +(cd payloads/libpayload; unset COREBOOT_BUILD_DIR; $(MAKE) coverage-report COV=1)
107 +$(MAKE) coverage-report JUNIT_OUTPUT=y COV=1
Paul Fagerburg18dd6b82021-12-07 09:52:41 -0700108 find . -name 'tests.info' -exec cat {} + >$(COREBOOT_BUILD_DIR)/coverage.info
Martin Roth6202fbb2022-11-12 21:40:04 -0700109endif
Martin Roth6c9c1962017-08-03 09:25:43 -0600110
111test-basic: test-lint test-tools test-abuild test-payloads test-cleanup
112
113test-lint:
Martin Rothb3f60a52022-11-19 15:53:11 -0700114 util/lint/lint lint-stable $(JUNIT)
115 util/lint/lint lint-extended $(JUNIT)
Martin Roth6c9c1962017-08-03 09:25:43 -0600116
117test-abuild:
Martin Roth03635612023-02-06 10:12:29 -0700118ifneq ($(JENKINS_SKIP_SCANBUILD_TEST),y)
Martin Rothb5e99462022-11-19 16:41:18 -0700119 NAME=scanbuild; SCANBUILD_ARGS='-k -plist-html -maxloop 10' util/abuild/abuild -o $(COREBOOT_BUILD_DIR)/$${NAME} $(ABUILD_OPTIONS) -scan-build --target EMULATION_QEMU_X86_Q35 --exitcode --name $${NAME}
Martin Roth03635612023-02-06 10:12:29 -0700120endif
Martin Roth6202fbb2022-11-12 21:40:04 -0700121ifneq ($(JENKINS_SKIP_GCC_TESTS),y)
Martin Rothc45c2fb2022-11-23 12:19:29 -0700122 NAME=gcc-chromeos; util/abuild/abuild -o $(COREBOOT_BUILD_DIR)/$${NAME} $(ABUILD_OPTIONS) -x --name $${NAME} --clean
123 NAME=gcc; util/abuild/abuild -o $(COREBOOT_BUILD_DIR)/$${NAME} $(ABUILD_OPTIONS) --name $${NAME} --clean-somewhat
Martin Roth6202fbb2022-11-12 21:40:04 -0700124endif
125ifneq ($(JENKINS_SKIP_CLANG_TESTS),y)
Martin Rothc45c2fb2022-11-23 12:19:29 -0700126 NAME=clang-chromeos; util/abuild/abuild -o $(COREBOOT_BUILD_DIR)/$${NAME} $(ABUILD_OPTIONS) -L -x --name $${NAME} --clean
127 NAME=clang; util/abuild/abuild -o $(COREBOOT_BUILD_DIR)/$${NAME} $(ABUILD_OPTIONS) -L --name $${NAME} --clean
Martin Roth6202fbb2022-11-12 21:40:04 -0700128endif
Martin Roth6c9c1962017-08-03 09:25:43 -0600129
130test-payloads:
131 $(MAKE) -C payloads/libpayload test-configs -j $(CPUS) V=$(V) Q=$(Q) MFLAGS= MAKEFLAGS= $(if $(TEST_NOCCACHE),,CONFIG_LP_CCACHE=y)
132 export MFLAGS=;export MAKEFLAGS=; \
133 $(foreach payload, $(TEST_PAYLOADLIST_INTERNAL), \
134 echo "*** Making payload $(payload) ***"; \
135 $(MAKE) -C payloads/$(payload) distclean ;\
136 $(MAKE) $(payload) -j $(CPUS) V=$(V) Q=$(Q)\
137 || exit 1; )
138
139test-tools:
140 @echo "Build testing $(TOOLLIST)"
Martin Roth36dcaba2022-11-19 16:34:04 -0700141 $(foreach tool, $(TOOLLIST), echo "Building $(tool)";$(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR="util/$(tool)" BLD="$(tool)" MFLAGS= MAKEFLAGS= MAKETARGET= junit.xml; )
142 unset COREBOOT_BUILD_DIR;$(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR=payloads/nvramcui BLD=nvramcui MFLAGS= MAKEFLAGS= MAKETARGET=all junit.xml
143 unset COREBOOT_BUILD_DIR;$(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR=payloads/coreinfo BLD=coreinfo MFLAGS= MAKEFLAGS= MAKETARGET=defaultbuild junit.xml
144 (cd payloads/libpayload; unset COREBOOT_BUILD_DIR; $(MAKE) $(if $(JENKINS_NOCCACHE),,CONFIG_LP_CCACHE=y) V=$(V) Q=$(Q) junit.xml)
Martin Roth37cb9222022-12-19 17:15:59 -0700145 echo "The tegra builds need to be fixed. Disabled until someone fixes them."
Martin Roth36dcaba2022-11-19 16:34:04 -0700146 # The tegra targets don't use the standard build system, so we need to provide an xcompile to them.
Martin Roth37cb9222022-12-19 17:15:59 -0700147 # $(MAKE) xcompile=$(COREBOOT_BUILD_DIR)/xcompile $(COREBOOT_BUILD_DIR)/xcompile
148 # $(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR=src/soc/nvidia/tegra124/lp0 BLD=tegra124_lp0 MFLAGS= MAKEFLAGS=xcompile=$(COREBOOT_BUILD_DIR)/xcompile MAKETARGET=all junit.xml
149 # $(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR=src/soc/nvidia/tegra210/lp0 BLD=tegra120_lp0 MFLAGS= MAKEFLAGS=xcompile=$(COREBOOT_BUILD_DIR)/xcompile MAKETARGET=all junit.xml
150 #
151 echo "The gitconfig tests are flaky and are disabled until someone fixes them."
152 # @echo "Running gitconfig tests"
153 # @for test in $$(find util/gitconfig/test -maxdepth 1 \
154 # -type f -executable); do \
155 # echo "$${test}"; \
156 # "$${test}" || exit $${?}; \
157 # done
Martin Roth6c9c1962017-08-03 09:25:43 -0600158
159test-cleanup:
Martin Roth2852cd22022-11-19 15:49:39 -0700160 rm -rf $(COREBOOT_BUILD_DIR)/chromeos $(COREBOOT_BUILD_DIR)/default
161 rm -rf $(COREBOOT_BUILD_DIR)/chromeos-clang $(COREBOOT_BUILD_DIR)/default-clang
Martin Rothb5e99462022-11-19 16:41:18 -0700162 rm -rf $(COREBOOT_BUILD_DIR)/scanbuild
Martin Roth6c9c1962017-08-03 09:25:43 -0600163 $(MAKE) clean
Martin Roth6c9c1962017-08-03 09:25:43 -0600164 $(foreach tool, $(TOOLLIST), $(MAKE) -C util/$(tool) clean ; )
Martin Roth2852cd22022-11-19 15:49:39 -0700165 $(MAKE) -C src/soc/nvidia/tegra124/lp0 clean
166 $(MAKE) -C src/soc/nvidia/tegra210/lp0 clean
Martin Roth6c9c1962017-08-03 09:25:43 -0600167
168.PHONY: test-basic test-lint test-abuild test-payloads
169.PHONY: test-tools test-cleanup test-help
170.PHONY: lint lint-stable what-jenkins-does