blob: ea35851d25e8f9e01fe5a54bcff8be7f60bd56e9 [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 ***'
5 @echo ' what-jenkins-does - Run platform build tests with junit output'
6 @echo ' lint / lint-stable - run coreboot lint tools (all / minimal)'
7 @echo ' test-basic - Run stardard build tests. All expected to pass.'
8 @echo ' test-lint - basic: Run stable and extended lint tests.'
9 @echo ' test-tools - basic: Tests a basic list of tools.'
10 @echo ' test-abuild - basic: Builds all platforms'
11 @echo ' test-payloads - basic: Builds internal payloads'
12 @echo ' test-cleanup - basic: Cleans coreboot directories'
Jakub Czapiga94828072021-05-17 12:22:48 +020013 @echo
Martin Roth6c9c1962017-08-03 09:25:43 -060014
15# junit.xml is a helper target to wrap builds that don't create junit.xml output
Martin Rothc32c0542018-05-19 17:51:20 -060016# BLD = The name of the build
Martin Roth6c9c1962017-08-03 09:25:43 -060017# BLD_DIR = Top path from coreboot to the build subdirectory
18# MAKETARGET = target to build
Martin Rothe624e272017-07-31 11:52:58 -060019junit.xml:
20 echo "Building $(BLD)"
21 echo '<?xml version="1.0" encoding="utf-8"?><testsuite>' > $@.tmp
22 echo "<testcase classname='$(BLD)' name='$(BLD)'>" >> $@.tmp
Martin Rothc32c0542018-05-19 17:51:20 -060023 -if [ -z "$(BLD_DIR)" ]; then \
24 projdir=""; \
25 xmlfile=junit_$(BLD).xml; \
26 else \
27 projdir="-C $(BLD_DIR)"; \
28 xmlfile="$(BLD_DIR)/$@"; \
29 fi; \
30 if [ -z "$(SKIP_DISTCLEAN)" ]; then \
31 $(MAKE) -j $(CPUS) $$projdir clean distclean > $@.tmp.2 2>&1 ; \
32 fi; \
33 if $(MAKE) -j $(CPUS) $$projdir $(MAKETARGET) >> $@.tmp.2 2>&1; then \
34 type="system-out"; \
35 echo "<$$type>" >> $@.tmp; \
36 echo "Building $(BLD) Succeeded"; \
37 else \
38 type="failure"; \
39 echo "<failure type='buildFailed'>" >> $@.tmp; \
40 echo "Building $(BLD) Failed"; \
41 fi; \
42 cat $@.tmp.2; \
43 echo '<![CDATA[' >> $@.tmp; \
44 cat $@.tmp.2 >> $@.tmp; \
45 echo "]]></$$type>" >>$@.tmp; \
46 rm -f $@.tmp.2; \
47 echo "</testcase>" >> $@.tmp; \
48 echo "</testsuite>" >> $@.tmp; \
49 mv $@.tmp "$$xmlfile"
Martin Rothe624e272017-07-31 11:52:58 -060050 echo
51
52TOOLLIST= \
Patrick Georgic9a9f832020-11-11 10:50:49 +010053amdfwtool \
Martin Rothe61e7782022-02-25 18:12:02 -070054cbfstool \
Martin Roth6c9c1962017-08-03 09:25:43 -060055cbmem \
56ectool \
57futility \
Patrick Georgi19072dc2021-11-25 10:31:10 +010058ifdtool \
Patrick Georgic9a9f832020-11-11 10:50:49 +010059intelmetool \
Martin Roth6c9c1962017-08-03 09:25:43 -060060inteltool \
61intelvbttool \
62nvramtool \
Patrick Georgic9a9f832020-11-11 10:50:49 +010063post \
Angel Pons446e4dc2020-02-12 22:59:40 +010064superiotool
Martin Roth6c9c1962017-08-03 09:25:43 -060065
66TEST_PAYLOADLIST_INTERNAL= \
67coreinfo \
68nvramcui
69
Martin Rothe624e272017-07-31 11:52:58 -060070JENKINS_PAYLOAD?=none
Martin Roth6c9c1962017-08-03 09:25:43 -060071TEST_PAYLOAD?=$(JENKINS_PAYLOAD)
Martin Rothe624e272017-07-31 11:52:58 -060072CPUS?=4
Martin Roth6c9c1962017-08-03 09:25:43 -060073
Martin Rothea383672016-08-30 09:39:48 -060074lint lint-stable lint-extended:
Martin Roth6c9c1962017-08-03 09:25:43 -060075 util/lint/lint $@
76
Martin Rothb399f102022-11-19 15:59:27 -070077ABUILD_OPTIONS=--blobs --junit --cpus $(CPUS) --clean-somewhat --payloads $(JENKINS_PAYLOAD)
78ABUILD_OPTIONS+=$(if $(V),--verbose,)
79ABUILD_OPTIONS+=$(if $(JENKINS_NOCCACHE),,--ccache)
Patrick Georgi99f0e0c2019-07-25 12:34:43 +020080ABUILD_OPTIONS+=$(JENKINS_ABUILD_OPT)
Patrick Georgic1999732019-07-25 12:24:32 +020081
Patrick Georgi19e1d632019-08-26 17:45:52 +020082COREBOOT_BUILD_DIR?=coreboot-builds
83
Martin Roth1e0f1322022-11-13 09:42:09 -070084validate_sec_tools:
Patrick Georgi673716d2021-09-09 13:42:29 +020085 if [ ! -f 3rdparty/intel-sec-tools/go.mod ]; then \
86 echo "Please download 3rdparty/intel-sec-tools/:"; \
87 echo "git submodule update --init 3rdparty/intel-sec-tools"; \
88 exit 1; \
89 fi
Martin Roth1e0f1322022-11-13 09:42:09 -070090
Martin Roth2852cd22022-11-19 15:49:39 -070091what-jenkins-does: test-cleanup validate_sec_tools
Martin Rothb3f60a52022-11-19 15:53:11 -070092ifneq ($(JENKINS_SKIP_LINT_TESTS),y)
93 JUNIT=--junit $(MAKE) test-lint
Martin Roth1e0f1322022-11-13 09:42:09 -070094endif
Arthur Heymansc44ffc32021-06-17 13:01:58 +020095 cd 3rdparty/intel-sec-tools/ ; go mod vendor
Maximilian Brune1d7a9de2022-04-14 14:54:16 +020096 cd util/goswid ; go mod vendor
Martin Rothdfafe792022-11-19 15:55:45 -070097 $(MAKE) test-abuild
Martin Roth36dcaba2022-11-19 16:34:04 -070098 $(MAKE) test-tools
Jakub Czapigaa0e36d82022-09-06 10:42:16 +020099 +$(MAKE) junit.xml-unit-tests COV=1
100 +(cd payloads/libpayload; unset COREBOOT_BUILD_DIR; $(MAKE) junit.xml-unit-tests COV=1)
101 +(cd payloads/libpayload; unset COREBOOT_BUILD_DIR; $(MAKE) coverage-report COV=1)
102 +$(MAKE) coverage-report JUNIT_OUTPUT=y COV=1
Paul Fagerburg18dd6b82021-12-07 09:52:41 -0700103 find . -name 'tests.info' -exec cat {} + >$(COREBOOT_BUILD_DIR)/coverage.info
Martin Roth6c9c1962017-08-03 09:25:43 -0600104
105test-basic: test-lint test-tools test-abuild test-payloads test-cleanup
106
107test-lint:
Martin Rothb3f60a52022-11-19 15:53:11 -0700108 util/lint/lint lint-stable $(JUNIT)
109 util/lint/lint lint-extended $(JUNIT)
Martin Roth6c9c1962017-08-03 09:25:43 -0600110
111test-abuild:
Martin Rothb5e99462022-11-19 16:41:18 -0700112 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 Roth676e0ac2022-11-19 16:54:26 -0700113 NAME=gcc-chromeos; util/abuild/abuild -o $(COREBOOT_BUILD_DIR)/$${NAME} $(ABUILD_OPTIONS) -x --name $${NAME}
114 NAME=gcc; util/abuild/abuild -o $(COREBOOT_BUILD_DIR)/$${NAME} $(ABUILD_OPTIONS) --name $${NAME}
115 NAME=clang-chromeos; util/abuild/abuild -o $(COREBOOT_BUILD_DIR)/$${NAME} $(ABUILD_OPTIONS) -L -x --name $${NAME}
116 NAME=clang; util/abuild/abuild -o $(COREBOOT_BUILD_DIR)/$${NAME} $(ABUILD_OPTIONS) -L --name $${NAME}
Martin Roth6c9c1962017-08-03 09:25:43 -0600117
118test-payloads:
119 $(MAKE) -C payloads/libpayload test-configs -j $(CPUS) V=$(V) Q=$(Q) MFLAGS= MAKEFLAGS= $(if $(TEST_NOCCACHE),,CONFIG_LP_CCACHE=y)
120 export MFLAGS=;export MAKEFLAGS=; \
121 $(foreach payload, $(TEST_PAYLOADLIST_INTERNAL), \
122 echo "*** Making payload $(payload) ***"; \
123 $(MAKE) -C payloads/$(payload) distclean ;\
124 $(MAKE) $(payload) -j $(CPUS) V=$(V) Q=$(Q)\
125 || exit 1; )
126
127test-tools:
128 @echo "Build testing $(TOOLLIST)"
Martin Roth36dcaba2022-11-19 16:34:04 -0700129 $(foreach tool, $(TOOLLIST), echo "Building $(tool)";$(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR="util/$(tool)" BLD="$(tool)" MFLAGS= MAKEFLAGS= MAKETARGET= junit.xml; )
130 unset COREBOOT_BUILD_DIR;$(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR=payloads/nvramcui BLD=nvramcui MFLAGS= MAKEFLAGS= MAKETARGET=all junit.xml
131 unset COREBOOT_BUILD_DIR;$(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR=payloads/coreinfo BLD=coreinfo MFLAGS= MAKEFLAGS= MAKETARGET=defaultbuild junit.xml
132 (cd payloads/libpayload; unset COREBOOT_BUILD_DIR; $(MAKE) $(if $(JENKINS_NOCCACHE),,CONFIG_LP_CCACHE=y) V=$(V) Q=$(Q) junit.xml)
133 # The tegra targets don't use the standard build system, so we need to provide an xcompile to them.
134 $(MAKE) xcompile=$(COREBOOT_BUILD_DIR)/xcompile $(COREBOOT_BUILD_DIR)/xcompile
135 $(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
136 $(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
Alex Thiessen15aad882018-01-02 17:40:55 +0000137 @echo "Running gitconfig tests"
138 @for test in $$(find util/gitconfig/test -maxdepth 1 \
139 -type f -executable); do \
140 echo "$${test}"; \
141 "$${test}" || exit $${?}; \
142 done
Martin Roth6c9c1962017-08-03 09:25:43 -0600143
144test-cleanup:
Martin Roth2852cd22022-11-19 15:49:39 -0700145 rm -rf $(COREBOOT_BUILD_DIR)/chromeos $(COREBOOT_BUILD_DIR)/default
146 rm -rf $(COREBOOT_BUILD_DIR)/chromeos-clang $(COREBOOT_BUILD_DIR)/default-clang
Martin Rothb5e99462022-11-19 16:41:18 -0700147 rm -rf $(COREBOOT_BUILD_DIR)/scanbuild
Martin Roth6c9c1962017-08-03 09:25:43 -0600148 $(MAKE) clean
Martin Roth6c9c1962017-08-03 09:25:43 -0600149 $(foreach tool, $(TOOLLIST), $(MAKE) -C util/$(tool) clean ; )
Martin Roth2852cd22022-11-19 15:49:39 -0700150 $(MAKE) -C src/soc/nvidia/tegra124/lp0 clean
151 $(MAKE) -C src/soc/nvidia/tegra210/lp0 clean
Martin Roth6c9c1962017-08-03 09:25:43 -0600152
153.PHONY: test-basic test-lint test-abuild test-payloads
154.PHONY: test-tools test-cleanup test-help
155.PHONY: lint lint-stable what-jenkins-does