Nokia RX-51: Add automated test for running RX-51 build in qemu
[oweals/u-boot.git] / .azure-pipelines.yml
1 variables:
2   windows_vm: vs2017-win2016
3   ubuntu_vm: ubuntu-18.04
4   ci_runner_image: trini/u-boot-gitlab-ci-runner:bionic-20200403-27Apr2020
5   # Add '-u 0' options for Azure pipelines, otherwise we get "permission
6   # denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer",
7   # since our $(ci_runner_image) user is not root.
8   container_option: -u 0
9   work_dir: /u
10
11 jobs:
12   - job: tools_only_windows
13     displayName: 'Ensure host tools build for Windows'
14     pool:
15       vmImage: $(windows_vm)
16     strategy:
17       matrix:
18         i686:
19           MSYS_DIR: msys32
20           BASE_REPO: msys2-ci-base-i686
21         x86_64:
22           MSYS_DIR: msys64
23           BASE_REPO: msys2-ci-base
24     steps:
25       - script: |
26           git clone https://github.com/msys2/$(BASE_REPO).git %CD:~0,2%\$(MSYS_DIR)
27         displayName: 'Install MSYS2'
28       - script: |
29           set PATH=%CD:~0,2%\$(MSYS_DIR)\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
30           %CD:~0,2%\$(MSYS_DIR)\usr\bin\pacman --noconfirm -Syyuu
31         displayName: 'Update MSYS2'
32       - script: |
33           set PATH=%CD:~0,2%\$(MSYS_DIR)\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
34           %CD:~0,2%\$(MSYS_DIR)\usr\bin\pacman --noconfirm --needed -S make gcc bison diffutils openssl-devel
35         displayName: 'Install Toolchain'
36       - script: |
37           set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
38           echo make tools-only_defconfig tools-only NO_SDL=1 > build-tools.sh
39           %CD:~0,2%\$(MSYS_DIR)\usr\bin\bash -lc "bash build-tools.sh"
40         displayName: 'Build Host Tools'
41         env:
42           # Tell MSYS2 we need a POSIX emulation layer
43           MSYSTEM: MSYS
44           # Tell MSYS2 not to ‘cd’ our startup directory to HOME
45           CHERE_INVOKING: yes
46
47   - job: cppcheck
48     displayName: 'Static code analysis with cppcheck'
49     pool:
50       vmImage: $(ubuntu_vm)
51     container:
52       image: $(ci_runner_image)
53       options: $(container_option)
54     steps:
55       - script: cppcheck -j$(nproc) --force --quiet --inline-suppr .
56
57   - job: htmldocs
58     displayName: 'Build HTML documentation'
59     pool:
60       vmImage: $(ubuntu_vm)
61     container:
62       image: $(ci_runner_image)
63       options: $(container_option)
64     steps:
65       - script: make htmldocs
66
67   - job: todo
68     displayName: 'Search for TODO within source tree'
69     pool:
70       vmImage: $(ubuntu_vm)
71     container:
72       image: $(ci_runner_image)
73       options: $(container_option)
74     steps:
75       - script: grep -r TODO .
76       - script: grep -r FIXME .
77       - script: grep -r HACK . | grep -v HACKKIT
78
79   - job: sloccount
80     displayName: 'Some statistics about the code base'
81     pool:
82       vmImage: $(ubuntu_vm)
83     container:
84       image: $(ci_runner_image)
85       options: $(container_option)
86     steps:
87       - script: sloccount .
88
89   - job: maintainers
90     displayName: 'Ensure all configs have MAINTAINERS entries'
91     pool:
92       vmImage: $(ubuntu_vm)
93     container:
94       image: $(ci_runner_image)
95       options: $(container_option)
96     steps:
97       - script: |
98           if [ `./tools/genboardscfg.py -f 2>&1 | wc -l` -ne 0 ]; then exit 1; fi
99
100   - job: tools_only
101     displayName: 'Ensure host tools build'
102     pool:
103       vmImage: $(ubuntu_vm)
104     container:
105       image: $(ci_runner_image)
106       options: $(container_option)
107     steps:
108       - script: |
109           make tools-only_config tools-only -j$(nproc)
110
111   - job: envtools
112     displayName: 'Ensure env tools build'
113     pool:
114       vmImage: $(ubuntu_vm)
115     container:
116       image: $(ci_runner_image)
117       options: $(container_option)
118     steps:
119       - script: |
120           make tools-only_config envtools -j$(nproc)
121
122   - job: utils
123     displayName: 'Run binman, buildman, dtoc, Kconfig and patman testsuites'
124     pool:
125       vmImage: $(ubuntu_vm)
126     steps:
127       - script: |
128           cat << EOF > build.sh
129           set -ex
130           cd ${WORK_DIR}
131           EOF
132           cat << "EOF" >> build.sh
133           git config --global user.name "Azure Pipelines"
134           git config --global user.email bmeng.cn@gmail.com
135           export USER=azure
136           virtualenv -p /usr/bin/python3 /tmp/venv
137           . /tmp/venv/bin/activate
138           pip install pyelftools pytest
139           export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl
140           export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
141           export PATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}
142           ./tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w sandbox_spl
143           ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test
144           ./tools/buildman/buildman -t
145           ./tools/dtoc/dtoc -t
146           ./tools/patman/patman --test
147           make O=${UBOOT_TRAVIS_BUILD_DIR} testconfig
148           EOF
149           cat build.sh
150           # We cannot use "container" like other jobs above, as buildman
151           # seems to hang forever with pre-configured "container" environment
152           docker run -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash $(work_dir)/build.sh
153
154   - job: nokia_rx51_test
155     displayName: 'Run tests for Nokia RX-51 (aka N900)'
156     pool:
157       vmImage: $(ubuntu_vm)
158     container:
159       image: $(ci_runner_image)
160       options: $(container_option)
161     steps:
162       - script: |
163           ./tools/buildman/buildman --fetch-arch arm
164           export PATH=~/.buildman-toolchains/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/:$PATH
165           test/nokia_rx51_test.sh
166
167   - job: test_py
168     displayName: 'test.py'
169     pool:
170       vmImage: $(ubuntu_vm)
171     strategy:
172       matrix:
173         sandbox:
174           TEST_PY_BD: "sandbox"
175         sandbox_clang:
176           TEST_PY_BD: "sandbox"
177           OVERRIDE: "-O clang-10"
178         sandbox_spl:
179           TEST_PY_BD: "sandbox_spl"
180           TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff"
181         sandbox_flattree:
182           TEST_PY_BD: "sandbox_flattree"
183         evb_ast2500:
184           TEST_PY_BD: "evb-ast2500"
185           TEST_PY_ID: "--id qemu"
186         vexpress_ca15_tc2:
187           TEST_PY_BD: "vexpress_ca15_tc2"
188           TEST_PY_ID: "--id qemu"
189         vexpress_ca9x4:
190           TEST_PY_BD: "vexpress_ca9x4"
191           TEST_PY_ID: "--id qemu"
192         integratorcp_cm926ejs:
193           TEST_PY_BD: "integratorcp_cm926ejs"
194           TEST_PY_ID: "--id qemu"
195           TEST_PY_TEST_SPEC: "not sleep"
196         qemu_arm:
197           TEST_PY_BD: "qemu_arm"
198           TEST_PY_TEST_SPEC: "not sleep"
199         qemu_arm64:
200           TEST_PY_BD: "qemu_arm64"
201           TEST_PY_TEST_SPEC: "not sleep"
202         qemu_mips:
203           TEST_PY_BD: "qemu_mips"
204           TEST_PY_TEST_SPEC: "not sleep"
205         qemu_mipsel:
206           TEST_PY_BD: "qemu_mipsel"
207           TEST_PY_TEST_SPEC: "not sleep"
208         qemu_mips64:
209           TEST_PY_BD: "qemu_mips64"
210           TEST_PY_TEST_SPEC: "not sleep"
211         qemu_mips64el:
212           TEST_PY_BD: "qemu_mips64el"
213           TEST_PY_TEST_SPEC: "not sleep"
214         qemu_ppce500:
215           TEST_PY_BD: "qemu-ppce500"
216           TEST_PY_TEST_SPEC: "not sleep"
217         qemu_riscv32:
218           TEST_PY_BD: "qemu-riscv32"
219           TEST_PY_TEST_SPEC: "not sleep"
220         qemu_riscv64:
221           TEST_PY_BD: "qemu-riscv64"
222           TEST_PY_TEST_SPEC: "not sleep"
223         qemu_riscv32_spl:
224           TEST_PY_BD: "qemu-riscv32_spl"
225           TEST_PY_TEST_SPEC: "not sleep"
226         qemu_riscv64_spl:
227           TEST_PY_BD: "qemu-riscv64_spl"
228           TEST_PY_TEST_SPEC: "not sleep"
229         qemu_x86:
230           TEST_PY_BD: "qemu-x86"
231           TEST_PY_TEST_SPEC: "not sleep"
232         qemu_x86_64:
233           TEST_PY_BD: "qemu-x86_64"
234           TEST_PY_TEST_SPEC: "not sleep"
235         xilinx_zynq_virt:
236           TEST_PY_BD: "xilinx_zynq_virt"
237           TEST_PY_ID: "--id qemu"
238           TEST_PY_TEST_SPEC: "not sleep"
239         xilinx_versal_virt:
240           TEST_PY_BD: "xilinx_versal_virt"
241           TEST_PY_ID: "--id qemu"
242           TEST_PY_TEST_SPEC: "not sleep"
243         xtfpga:
244           TEST_PY_BD: "xtfpga"
245           TEST_PY_ID: "--id qemu"
246           TEST_PY_TEST_SPEC: "not sleep"
247     steps:
248       - script: |
249           cat << EOF > test.sh
250           set -ex
251           # make environment variables available as tests are running inside a container
252           export WORK_DIR="${WORK_DIR}"
253           export TEST_PY_BD="${TEST_PY_BD}"
254           export TEST_PY_ID="${TEST_PY_ID}"
255           export TEST_PY_TEST_SPEC="${TEST_PY_TEST_SPEC}"
256           export OVERRIDE="${OVERRIDE}"
257           EOF
258           cat << "EOF" >> test.sh
259           # the below corresponds to .gitlab-ci.yml "before_script"
260           cd ${WORK_DIR}
261           git clone --depth=1 git://github.com/swarren/uboot-test-hooks.git /tmp/uboot-test-hooks
262           ln -s travis-ci /tmp/uboot-test-hooks/bin/`hostname`
263           ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname`
264           grub-mkimage --prefix=\"\" -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
265           grub-mkimage --prefix=\"\" -o ~/grub_x64.efi -O x86_64-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
266           cp /opt/grub/grubriscv64.efi ~/grub_riscv64.efi
267           cp /opt/grub/grubriscv32.efi ~/grub_riscv32.efi
268           cp /opt/grub/grubaa64.efi ~/grub_arm64.efi
269           cp /opt/grub/grubarm.efi ~/grub_arm.efi
270           if [[ "${TEST_PY_BD}" == "qemu-riscv32_spl" ]]; then
271               wget -O - https://github.com/riscv/opensbi/releases/download/v0.6/opensbi-0.6-rv32-bin.tar.xz | tar -C /tmp -xJ;
272               export OPENSBI=/tmp/opensbi-0.6-rv32-bin/platform/qemu/virt/firmware/fw_dynamic.bin;
273           fi
274           if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]]; then
275               wget -O - https://github.com/riscv/opensbi/releases/download/v0.6/opensbi-0.6-rv64-bin.tar.xz | tar -C /tmp -xJ;
276               export OPENSBI=/tmp/opensbi-0.6-rv64-bin/platform/qemu/virt/firmware/fw_dynamic.bin;
277           fi
278           # the below corresponds to .gitlab-ci.yml "script"
279           cd ${WORK_DIR}
280           export UBOOT_TRAVIS_BUILD_DIR=/tmp/${TEST_PY_BD};
281           tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e --board ${TEST_PY_BD} ${OVERRIDE}
282           virtualenv -p /usr/bin/python3 /tmp/venv
283           . /tmp/venv/bin/activate
284           pip install -r test/py/requirements.txt
285           export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
286           export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
287           # "${var:+"-k $var"}" expands to "" if $var is empty, "-k $var" if not
288           ./test/py/test.py --bd ${TEST_PY_BD} ${TEST_PY_ID} ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"} --build-dir "$UBOOT_TRAVIS_BUILD_DIR";
289           # the below corresponds to .gitlab-ci.yml "after_script"
290           rm -rf /tmp/uboot-test-hooks /tmp/venv
291           EOF
292           cat test.sh
293           # make current directory writeable to uboot user inside the container
294           # as sandbox testing need create files like spi flash images, etc.
295           # (TODO: clean up this in the future)
296           chmod 777 .
297           docker run -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash $(work_dir)/test.sh
298
299   - job: build_the_world
300     displayName: 'Build the World'
301     pool:
302       vmImage: $(ubuntu_vm)
303     strategy:
304       # Use almost the same target division in .travis.yml, only merged
305       # 4 small build jobs (arc/microblaze/nds32/xtensa) into one.
306       matrix:
307         arc_microblaze_nds32_xtensa:
308           BUILDMAN: "arc microblaze nds32 xtensa"
309         arm11_arm7_arm920t_arm946es:
310           BUILDMAN: "arm11 arm7 arm920t arm946es"
311         arm926ejs:
312           BUILDMAN: "arm926ejs -x freescale,siemens,at91,kirkwood,spear,omap"
313         at91_non_armv7:
314           BUILDMAN: "at91 -x armv7"
315         at91_non_arm926ejs:
316           BUILDMAN: "at91 -x arm926ejs"
317         boundary_engicam_toradex:
318           BUILDMAN: "boundary engicam toradex"
319         arm_bcm:
320           BUILDMAN: "bcm -x mips"
321         nxp_arm32:
322           BUILDMAN: "freescale -x powerpc,m68k,aarch64,ls101,ls102,ls104,ls108,ls20,lx216"
323         nxp_ls101x:
324           BUILDMAN: "freescale&ls101"
325         nxp_ls102x:
326           BUILDMAN: "freescale&ls102"
327         nxp_ls104x:
328           BUILDMAN: "freescale&ls104"
329         nxp_ls108x:
330           BUILDMAN: "freescale&ls108"
331         nxp_ls20xx:
332           BUILDMAN: "freescale&ls20"
333         nxp_lx216x:
334           BUILDMAN: "freescale&lx216"
335         imx6:
336           BUILDMAN: "mx6 -x boundary,engicam,freescale,technexion,toradex"
337         imx:
338           BUILDMAN: "mx -x mx6,freescale,technexion,toradex"
339         keystone2_keystone3:
340           BUILDMAN: "k2 k3"
341         samsung_socfpga:
342           BUILDMAN: "samsung socfpga"
343         spear:
344           BUILDMAN: "spear"
345         sun4i:
346           BUILDMAN: "sun4i"
347         sun5i:
348           BUILDMAN: "sun5i"
349         sun6i:
350           BUILDMAN: "sun6i"
351         sun7i:
352           BUILDMAN: "sun7i"
353         sun8i_32bit:
354           BUILDMAN: "sun8i&armv7"
355         sun8i_64bit:
356           BUILDMAN: "sun8i&aarch64"
357         sun9i:
358           BUILDMAN: "sun9i"
359         sun50i:
360           BUILDMAN: "sun50i"
361         arm_catch_all:
362           BUILDMAN: "arm -x arm11,arm7,arm9,aarch64,at91,bcm,freescale,kirkwood,mvebu,siemens,tegra,uniphier,mx,samsung,sunxi,am33xx,omap,rk,toradex,socfpga,k2,k3,zynq"
363         sandbox_x86:
364           BUILDMAN: "sandbox x86"
365         technexion:
366           BUILDMAN: "technexion"
367         kirkwood:
368           BUILDMAN: "kirkwood"
369         mvebu:
370           BUILDMAN: "mvebu"
371         m68k:
372           BUILDMAN: "m68k"
373         mips:
374           BUILDMAN: "mips"
375         non_fsl_ppc:
376           BUILDMAN: "powerpc -x freescale"
377         mpc85xx_freescale:
378           BUILDMAN: "mpc85xx&freescale -x t208xrdb -x t4qds -x t102* -x p1_p2_rdb_pc -x p1010rdb -x corenet_ds -x b4860qds -x bsc91*"
379         t208xrdb_corenet_ds:
380           BUILDMAN: "t208xrdb corenet_ds"
381         fsl_ppc:
382           BUILDMAN: "t4qds b4860qds mpc83xx&freescale mpc86xx&freescale"
383         t102x:
384           BUILDMAN: "t102*"
385         p1_p2_rdb_pc:
386           BUILDMAN: "p1_p2_rdb_pc"
387         p1010rdb_bsc91:
388           BUILDMAN: "p1010rdb bsc91"
389         siemens:
390           BUILDMAN: "siemens"
391         tegra:
392           BUILDMAN: "tegra -x toradex"
393         am33xx_no_siemens:
394           BUILDMAN: "am33xx -x siemens"
395         omap:
396           BUILDMAN: "omap"
397         uniphier:
398           BUILDMAN: "uniphier"
399         aarch64_catch_all:
400           BUILDMAN: "aarch64 -x bcm,k3,tegra,ls1,ls2,lx216,mvebu,uniphier,sunxi,samsung,socfpga,rk,versal,zynq"
401         rockchip:
402           BUILDMAN: "rk"
403         sh:
404           BUILDMAN: "sh -x arm"
405         zynq:
406           BUILDMAN: "zynq&armv7"
407         zynqmp_versal:
408           BUILDMAN: "versal|zynqmp&aarch64"
409         riscv:
410           BUILDMAN: "riscv"
411     steps:
412       - script: |
413           cat << EOF > build.sh
414           set -ex
415           cd ${WORK_DIR}
416           # make environment variables available as tests are running inside a container
417           export BUILDMAN="${BUILDMAN}"
418           EOF
419           cat << "EOF" >> build.sh
420           if [[ "${BUILDMAN}" != "" ]]; then
421               ret=0;
422               tools/buildman/buildman -o /tmp -P -W ${BUILDMAN} ${OVERRIDE} || ret=$?;
423               if [[ $ret -ne 0 ]]; then
424                   tools/buildman/buildman -o /tmp -seP ${BUILDMAN};
425                   exit $ret;
426               fi;
427           fi
428           EOF
429           cat build.sh
430           docker run -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash $(work_dir)/build.sh