util/testing: Update junit.xml to support coreboot builds
[coreboot.git] / util / testing / Makefile.inc
blobd9bb0f78e50c0066451966ee2a6814cc2e67bd1e
1 ##
2 ## This file is part of the coreboot project.
3 ##
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; version 2 of the License.
7 ##
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 ## GNU General Public License for more details.
14 test-help help::
15         @echo  '*** coreboot test targets ***'
16         @echo  '  what-jenkins-does      - Run platform build tests with junit output'
17         @echo  '  lint / lint-stable     - run coreboot lint tools (all / minimal)'
18         @echo  '  test-basic             - Run stardard build tests. All expected to pass.'
19         @echo  '  test-lint              - basic: Run stable and extended lint tests.'
20         @echo  '  test-tools             - basic: Tests a basic list of tools.'
21         @echo  '  test-abuild            - basic: Builds all platforms'
22         @echo  '  test-payloads          - basic: Builds internal payloads'
23         @echo  '  test-cleanup           - basic: Cleans coreboot directories'
25 # junit.xml is a helper target to wrap builds that don't create junit.xml output
26 # BLD = The name of the build
27 # BLD_DIR = Top path from coreboot to the build subdirectory
28 # MAKETARGET = target to build
29 junit.xml:
30         echo "Building $(BLD)"
31         echo '<?xml version="1.0" encoding="utf-8"?><testsuite>' > $@.tmp
32         echo "<testcase classname='$(BLD)' name='$(BLD)'>" >> $@.tmp
33         -if [ -z "$(BLD_DIR)" ]; then                                          \
34                 projdir="";                                                    \
35                 xmlfile=junit_$(BLD).xml;                                      \
36         else                                                                   \
37                 projdir="-C $(BLD_DIR)";                                       \
38                 xmlfile="$(BLD_DIR)/$@";                                       \
39         fi;                                                                    \
40         if [ -z "$(SKIP_DISTCLEAN)" ]; then                                    \
41                 $(MAKE) -j $(CPUS) $$projdir clean distclean > $@.tmp.2 2>&1 ; \
42         fi;                                                                    \
43         if $(MAKE) -j $(CPUS) $$projdir $(MAKETARGET) >> $@.tmp.2 2>&1; then   \
44                 type="system-out";                                             \
45                 echo "<$$type>" >> $@.tmp;                                     \
46                 echo "Building $(BLD) Succeeded";                              \
47         else                                                                   \
48                 type="failure";                                                \
49                 echo "<failure type='buildFailed'>" >> $@.tmp;                 \
50                 echo "Building $(BLD) Failed";                                 \
51         fi;                                                                    \
52         cat $@.tmp.2;                                                          \
53         echo '<![CDATA[' >> $@.tmp;                                            \
54         cat $@.tmp.2 >> $@.tmp;                                                \
55         echo "]]></$$type>" >>$@.tmp;                                          \
56         rm -f $@.tmp.2;                                                        \
57         echo "</testcase>" >> $@.tmp;                                          \
58         echo "</testsuite>" >> $@.tmp;                                         \
59         mv $@.tmp "$$xmlfile"
60         echo
62 TOOLLIST= \
63 broadcom/secimage \
64 cbmem \
65 ectool \
66 futility \
67 inteltool \
68 intelvbttool \
69 nvramtool \
70 superiotool \
71 viatool
73 TEST_PAYLOADLIST_INTERNAL= \
74 coreinfo \
75 nvramcui
77 JENKINS_PAYLOAD?=none
78 TEST_PAYLOAD?=$(JENKINS_PAYLOAD)
79 CPUS?=4
81 lint lint-stable lint-extended:
82         util/lint/lint $@
84 what-jenkins-does:
85         util/lint/lint lint-stable --junit
86         util/lint/lint lint-extended --junit
87         util/abuild/abuild -B -J $(if $(JENKINS_NOCCACHE),,-y) -c $(CPUS) -z -p $(JENKINS_PAYLOAD) -x -X $(top)/abuild-chromeos.xml
88         util/abuild/abuild -B -J $(if $(JENKINS_NOCCACHE),,-y) -c $(CPUS) -z -p $(JENKINS_PAYLOAD)
89         (cd payloads/libpayload; unset COREBOOT_BUILD_DIR; $(MAKE) $(if $(JENKINS_NOCCACHE),,CONFIG_LP_CCACHE=y) V=$(V) Q=$(Q) junit.xml)
90         $(foreach tool, $(TOOLLIST), $(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR="util/$(tool)" BLD="$(tool)" MFLAGS= MAKEFLAGS= MAKETARGET= junit.xml; )
91         unset COREBOOT_BUILD_DIR;$(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR=payloads/nvramcui BLD=nvramcui MFLAGS= MAKEFLAGS= MAKETARGET=all junit.xml
92         unset COREBOOT_BUILD_DIR;$(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR=payloads/coreinfo BLD=coreinfo MFLAGS= MAKEFLAGS= MAKETARGET=defaultbuild junit.xml
93         $(MAKE) CPUS=$(CPUS) V=$(V) Q=$(Q) BLD_DIR=util/romcc BLD=romcc MFLAGS= MAKEFLAGS= MAKETARGET=test junit.xml
94         $(MAKE) -C src/soc/nvidia/tegra124/lp0 all clean
95         $(MAKE) -C src/soc/nvidia/tegra210/lp0 all clean
97 test-basic: test-lint test-tools test-abuild test-payloads test-cleanup
99 test-lint:
100         util/lint/lint lint-stable
101         util/lint/lint lint-extended
103 test-abuild:
104         rm -rf coreboot-builds-chromeos coreboot-builds
105         export COREBOOT_BUILD_DIR=coreboot-builds-chromeos; util/abuild/abuild -B -e $(if $(TEST_NOCCACHE),,-y) -c $(CPUS) -p $(TEST_PAYLOAD) -x
106         util/abuild/abuild -B -e $(if $(TEST_NOCCACHE),,-y) -c $(CPUS) -p $(TEST_PAYLOAD)
108 test-payloads:
109         $(MAKE) -C payloads/libpayload test-configs -j $(CPUS) V=$(V) Q=$(Q) MFLAGS= MAKEFLAGS= $(if $(TEST_NOCCACHE),,CONFIG_LP_CCACHE=y)
110         export MFLAGS=;export MAKEFLAGS=; \
111         $(foreach payload, $(TEST_PAYLOADLIST_INTERNAL), \
112                 echo "*** Making payload $(payload) ***"; \
113                 $(MAKE) -C payloads/$(payload) distclean ;\
114                 $(MAKE) $(payload) -j $(CPUS) V=$(V) Q=$(Q)\
115                 || exit 1; )
117 test-tools:
118         @echo "Build testing $(TOOLLIST)"
119         $(foreach tool, $(TOOLLIST), $(MAKE) -C util/$(tool) clean ; )
120         $(MAKE) -C util/romcc clean
121         $(foreach tool, $(TOOLLIST), echo "Building $(tool)";export MFLAGS= ;export MAKEFLAGS= ;$(MAKE) -C util/$(tool) all V=$(V) Q=$(Q) || exit 1; )
122         echo "Building romcc"
123         $(MAKE) -C util/romcc all test -j $(CPUS) V=$(V) Q=$(Q)
124         echo "Testing broadcom/secimage"
125         $(MAKE) -C util/broadcom/secimage test
127 test-cleanup:
128         rm -rf coreboot-builds coreboot-builds-chromeos
129         $(MAKE) clean
130         $(MAKE) distclean
131         $(foreach tool, $(TOOLLIST), $(MAKE) -C util/$(tool) clean ; )
132         $(MAKE) -C util/romcc clean
134 .PHONY: test-basic test-lint test-abuild test-payloads
135 .PHONY: test-tools test-cleanup test-help
136 .PHONY: lint lint-stable what-jenkins-does