Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108441748
D43786.id134000.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
24 KB
Referenced Files
None
Subscribers
None
D43786.id134000.diff
View Options
diff --git a/tests/ci/Makefile b/tests/ci/Makefile
new file mode 100644
--- /dev/null
+++ b/tests/ci/Makefile
@@ -0,0 +1,228 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2024 The FreeBSD Foundation
+#
+# This software was developed by Cybermancer Infosec <bofh@FreeBSD.org>
+# under sponsorship from the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE
+#
+# Makefile for CI testing.
+#
+# User-driven targets:
+# ci: Run CI tests. Currently only smoke tests are supported.
+# ci-smokeit: Currently same as ci.
+#
+# Variables affecting the build process:
+# TARGET/TARGET_ARCH: architecture of built release (default: same as build host)
+# KERNELCONF: kernel configuration to use
+# USE_QEMU: Use QEMU for testing rather than bhyve
+#
+
+WORLDDIR?= ${.CURDIR}/../..
+RELEASEDIR= ${WORLDDIR}/release
+MAKECONF?= /dev/null
+SRCCONF?= /dev/null
+_MEMORY!=sysctl -n hw.physmem 2>/dev/null
+PARALLEL_JOBS!=sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null
+TOTAL_MEMORY!=expr ${_MEMORY} / 1073741824
+KERNCONF?= GENERIC
+LOCALBASE?= /usr/local
+
+.if !defined(TARGET) || empty(TARGET)
+TARGET= ${MACHINE}
+.endif
+.if !defined(TARGET_ARCH) || empty(TARGET_ARCH)
+.if ${TARGET} == ${MACHINE}
+TARGET_ARCH= ${MACHINE_ARCH}
+.else
+TARGET_ARCH= ${TARGET}
+.endif
+.endif
+IMAKE= ${MAKE} TARGET=${TARGET} TARGET_ARCH=${TARGET}
+
+.if defined(CROSS_TOOLCHAIN) || !empty(CROSS_TOOLCHAIN)
+CROSS_TOOLCHAIN_PARAM= "CROSS_TOOLCHAIN=${CROSS_TOOLCHAIN}"
+.endif
+
+# Define OSRELEASE by using newvers.sh
+.if !defined(OSRELEASE) || empty(OSRELEASE)
+.for _V in TYPE BRANCH REVISION
+. if !defined(${_V}) || empty(${_V})
+${_V}!= eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../../sys/conf/newvers.sh); echo $$${_V}
+. endif
+.endfor
+.for _V in ${TARGET_ARCH}
+.if !empty(TARGET:M${_V})
+OSRELEASE= ${TYPE}-${REVISION}-${BRANCH}-${TARGET}
+VOLUME_LABEL= ${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET}
+.else
+OSRELEASE= ${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH}
+VOLUME_LABEL= ${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET_ARCH}
+.endif
+.endfor
+.endif
+
+.if exists(${.CURDIR}/tools/ci.conf) && !defined(CICONF)
+CICONF?= ${.CURDIR}/tools/ci.conf
+.endif
+SWAPSIZE?= 1g
+VMFS?= ufs
+FORMAT= raw
+CIIMAGE= ci-${OSRELEASE}-${GITREV}-${KERNCONF}.${FORMAT}
+VMSIZE?= 6g
+CITYPE?=
+TEST_VM_NAME= ci-${OSRELEASE}-${GITREV}-${KERNCONF}
+.if ${TOTAL_MEMORY} >= 16
+VM_MEM!=expr ${TOTAL_MEMORY} / 2
+.elif ${TOTAL_MEMORY} >=4
+VM_MEM=${TOTAL_MEMORY}
+.else
+echo "Please increase the memory to at least 4GB"
+exit 0
+.endif
+VM_MEM_SIZE?=${VM_MEM}g
+TIMEOUT_MS?=5400000
+TIMEOUT=$$((${TIMEOUT_MS} / 1000))
+TIMEOUT_EXPECT=$$((${TIMEOUT} - 60))
+TIMEOUT_VM=$$((${TIMEOUT_EXPECT} - 120))
+.if exists(${.CURDIR}/Makefile.${TARGET_ARCH})
+.include "${.CURDIR}/Makefile.${TARGET_ARCH}"
+.endif
+.if ${TARGET_ARCH} != ${MACHINE_ARCH}
+.if ( ${TARGET_ARCH} != "i386" ) || ( ${MACHINE_ARCH} != "amd64" )
+QEMUSTATIC=/usr/local/bin/qemu-${TARGET_ARCH}-static
+QEMUTGT=portinstall-qemu
+.endif
+.endif
+QEMUTGT?=
+QEMU_DEVICES?=-device virtio-blk,drive=hd0
+QEMU_EXTRA_PARAM?=
+QEMU_MACHINE?=virt
+QEMUBIN=/usr/local/bin/qemu-system-${QEMU_ARCH}
+.if ${PARALLEL_JOBS} >= ${QEMU_MAX_CPU_COUNT}
+QEMU_CPU_COUNT=${QEMU_MAX_CPU_COUNT}
+.else
+QEMU_CPU_COUNT=${PARALLEL_JOBS}
+.endif
+.if ${VM_MEM} >= ${QEMU_MAX_MEM_SIZE}
+VM_MEM_SIZE=${QEMU_MAX_MEM_SIZE}g
+.else
+VM_MEM_SIZE=${VM_MEM}g
+.endif
+KLDISLOADED!=kldstat -q -n adsf 2>/dev/null && echo "1" || echo "0"
+.if ${KLDISLOADED} == "0"
+USE_QEMU?=1
+.endif
+
+CLEANFILES= ${CIIMAGE} ci.img
+CLEANDIRS= ci-buildimage
+
+portinstall: portinstall-pkg portinstall-qemu portinstall-expect portinstall-${TARGET_ARCH:tl} .PHONY
+
+portinstall-pkg: .PHONY
+.if !exists(/usr/local/sbin/pkg-static)
+ env ASSUME_ALWAYS_YES=yes pkg bootstrap -y
+.endif
+
+portinstall-qemu: portinstall-pkg .PHONY
+.if !exists(/usr/local/bin/qemu-${TARGET_ARCH}-static)
+ env ASSUME_ALWAYS_YES=yes pkg install -y emulators/qemu-user-static
+.endif
+.if !exists(/usr/local/bin/qemu-system-${QEMU_ARCH})
+ env ASSUME_ALWAYS_YES=yes pkg install -y emulators/qemu@nox11
+.endif
+
+portinstall-expect: portinstall-pkg .PHONY
+.if !exists(/usr/local/bin/expect)
+ env ASSUME_ALWAYS_YES=yes pkg install -y lang/expect
+.endif
+
+beforeclean: .PHONY
+ chflags -R noschg .
+
+.include <bsd.obj.mk>
+clean: beforeclean .PHONY
+
+ci-buildworld: .PHONY
+ ${IMAKE} -j${PARALLEL_JOBS} -C ${WORLDDIR} -DNO_CLEAN buildworld ${CROSS_TOOLCHAIN_PARAM} __MAKE_CONF=${MAKECONF} SRCCONF=${SRCCONF} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}
+
+ci-buildkernel: ci-buildworld-${TARGET_ARCH:tl} .PHONY
+ ${IMAKE} -j${PARALLEL_JOBS} -C ${WORLDDIR} -DNO_CLEAN buildkernel ${CROSS_TOOLCHAIN_PARAM} __MAKE_CONF=${MAKECONF} SRCCONF=${SRCCONF} TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}
+
+ci-buildimage: ${QEMUTGT} ci-buildkernel-${TARGET_ARCH:tl} .PHONY
+ mkdir -p ${.OBJDIR}/${.TARGET}
+ env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} SWAPSIZE=${SWAPSIZE} \
+ QEMUSTATIC=${QEMUSTATIC} CITYPE=${CITYPE} \
+ ${RELEASEDIR}/scripts/mk-vmimage.sh \
+ -C ${RELEASEDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} -F ${VMFS} \
+ -i ${.OBJDIR}/ci.img -s ${VMSIZE} -f ${FORMAT} \
+ -S ${WORLDDIR} -o ${.OBJDIR}/${CIIMAGE} -c ${CICONF}
+ touch ${.TARGET}
+
+ci-setsmokevar: .PHONY
+CITYPE=smoke
+
+ci-runtest: ci-buildimage-${TARGET_ARCH:tl} portinstall .PHONY
+.if ${MACHINE} == "amd64" && ( ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386" ) && ( !defined(USE_QEMU) || empty(USE_QEMU) )
+ /usr/sbin/bhyvectl --vm=${TEST_VM_NAME} --destroy || true
+ /usr/sbin/bhyveload -c stdio -m ${VM_MEM_SIZE} -d ${CIIMAGE} ${TEST_VM_NAME}
+ expect -c "set timeout ${TIMEOUT_EXPECT}; \
+ spawn /usr/bin/timeout -k 60 ${TIMEOUT_VM} /usr/sbin/bhyve \
+ -c ${PARALLEL_JOBS} -m ${VM_MEM_SIZE} -A -H -P \
+ -s 0:0,hostbridge \
+ -s 1:0,lpc \
+ -s 2:0,virtio-blk,${CIIMAGE} \
+ -l com1,stdio \
+ ${TEST_VM_NAME}; \
+ expect { eof }"
+ /usr/sbin/bhyvectl --vm=${TEST_VM_NAME} --destroy
+.else
+ timeout -k 60 ${TIMEOUT_VM} ${QEMUBIN} \
+ -machine ${QEMU_MACHINE} \
+ -smp ${QEMU_CPU_COUNT} \
+ -m ${VM_MEM_SIZE} \
+ -nographic \
+ -no-reboot \
+ ${QEMU_EXTRA_PARAM} \
+ -drive if=none,file=${CIIMAGE},format=raw,id=hd0 \
+ ${QEMU_DEVICES}
+.endif
+
+ci-checktarget: .PHONY
+.if ${TARGET_ARCH} != "aarch64" && \
+ ${TARGET_ARCH} != "amd64" && \
+ ${TARGET_ARCH} != "armv7" && \
+ ${TARGET_ARCH} != "powerpc64" && \
+ ${TARGET_ARCH} != "powerpc64le" && \
+ ${TARGET_ARCH} != "riscv64"
+ @false
+.ERROR:
+ @echo "Error: ${TARGET_ARCH} is not supported on ${TYPE} ${REVISION} ${BRANCH}"
+.endif
+
+ci-smokeit: ci-setsmokevar ci-checktarget .WAIT ci-runtest-${TARGET_ARCH:tl} .PHONY
+
+ci: ci-smokeit .PHONY
+
+.include "${RELEASEDIR}/Makefile.inc1"
diff --git a/tests/ci/Makefile.aarch64 b/tests/ci/Makefile.aarch64
new file mode 100644
--- /dev/null
+++ b/tests/ci/Makefile.aarch64
@@ -0,0 +1,51 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2024 The FreeBSD Foundation
+#
+# This software was developed by Cybermancer Infosec <bofh@FreeBSD.org>
+# under sponsorship from the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE
+#
+# CI Makefile for aarch64.
+#
+QEMU_ARCH=aarch64
+QEMU_DEVICES=-device virtio-blk,drive=hd0 -device ahci,id=ahci
+QEMU_EXTRA_PARAM=-bios /usr/local/share/u-boot/u-boot-qemu-arm64/u-boot.bin -cpu cortex-a57
+QEMU_MAX_CPU_COUNT=64
+QEMU_MAX_MEM_SIZE=64
+
+portinstall-aarch64: portinstall-pkg .PHONY
+.if !exists(/usr/local/share/u-boot/u-boot-qemu-arm64/u-boot.bin)
+ env ASSUME_ALWAYS_YES=yes pkg install -y sysutils/u-boot-qemu-arm64
+.endif
+
+# XXX: Nothing should be changed below this line unless explicitly required.
+
+ci-buildworld-aarch64: ci-buildworld .PHONY
+
+ci-buildkernel-aarch64: ci-buildkernel .PHONY
+
+ci-buildimage-aarch64: ci-buildimage .PHONY
+
+ci-runtest-aarch64: ci-runtest .PHONY
diff --git a/tests/ci/Makefile.amd64 b/tests/ci/Makefile.amd64
new file mode 100644
--- /dev/null
+++ b/tests/ci/Makefile.amd64
@@ -0,0 +1,48 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2024 The FreeBSD Foundation
+#
+# This software was developed by Cybermancer Infosec <bofh@FreeBSD.org>
+# under sponsorship from the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE
+#
+# CI Makefile for amd64.
+#
+QEMU_ARCH=x86_64
+QEMU_MACHINE=q35
+QEMU_MAX_CPU_COUNT=256
+QEMU_MAX_MEM_SIZE=128
+
+portinstall-amd64: portinstall-pkg .PHONY
+ @true
+
+# XXX: Nothing should be changed below this line unless explicitly required.
+
+ci-buildworld-amd64: ci-buildworld .PHONY
+
+ci-buildkernel-amd64: ci-buildkernel .PHONY
+
+ci-buildimage-amd64: ci-buildimage .PHONY
+
+ci-runtest-amd64: ci-runtest .PHONY
diff --git a/tests/ci/Makefile.powerpc64 b/tests/ci/Makefile.powerpc64
new file mode 100644
--- /dev/null
+++ b/tests/ci/Makefile.powerpc64
@@ -0,0 +1,50 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2024 The FreeBSD Foundation
+#
+# This software was developed by Cybermancer Infosec <bofh@FreeBSD.org>
+# under sponsorship from the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE
+#
+# CI Makefile for powerpc64.
+#
+QEMU_ARCH=ppc64
+QEMU_DEVICES=-device virtio-blk,drive=hd0
+QEMU_EXTRA_PARAM=-vga none -accel tcg,thread=multi
+QEMU_MACHINE=pseries,cap-hpt-max-page-size=16M
+QEMU_MAX_CPU_COUNT=1
+QEMU_MAX_MEM_SIZE=64
+
+portinstall-powerpc64: portinstall-pkg .PHONY
+ @true
+
+# XXX: Nothing should be changed below this line unless explicitly required.
+
+ci-buildworld-powerpc64: ci-buildworld .PHONY
+
+ci-buildkernel-powerpc64: ci-buildkernel .PHONY
+
+ci-buildimage-powerpc64: ci-buildimage .PHONY
+
+ci-runtest-powerpc64: ci-runtest .PHONY
diff --git a/tests/ci/Makefile.powerpc64le b/tests/ci/Makefile.powerpc64le
new file mode 100644
--- /dev/null
+++ b/tests/ci/Makefile.powerpc64le
@@ -0,0 +1,50 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2024 The FreeBSD Foundation
+#
+# This software was developed by Cybermancer Infosec <bofh@FreeBSD.org>
+# under sponsorship from the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE
+#
+# CI Makefile for powerpc64le.
+#
+QEMU_ARCH=ppc64
+QEMU_DEVICES=-device virtio-blk,drive=hd0
+QEMU_EXTRA_PARAM=-vga none -accel tcg,thread=multi
+QEMU_MACHINE=pseries,cap-hpt-max-page-size=16M
+QEMU_MAX_CPU_COUNT=1
+QEMU_MAX_MEM_SIZE=64
+
+portinstall-powerpc64le: portinstall-pkg .PHONY
+ @true
+
+# XXX: Nothing should be changed below this line unless explicitly required.
+
+ci-buildworld-powerpc64le: ci-buildworld .PHONY
+
+ci-buildkernel-powerpc64le: ci-buildkernel .PHONY
+
+ci-buildimage-powerpc64le: ci-buildimage .PHONY
+
+ci-runtest-powerpc64le: ci-runtest .PHONY
diff --git a/tests/ci/Makefile.riscv64 b/tests/ci/Makefile.riscv64
new file mode 100644
--- /dev/null
+++ b/tests/ci/Makefile.riscv64
@@ -0,0 +1,54 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2024 The FreeBSD Foundation
+#
+# This software was developed by Cybermancer Infosec <bofh@FreeBSD.org>
+# under sponsorship from the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE
+#
+# CI Makefile for riscv64.
+#
+QEMU_ARCH=riscv64
+QEMU_DEVICES=-device virtio-blk-device,drive=hd0
+QEMU_EXTRA_PARAM=-bios /usr/local/share/opensbi/lp64/generic/firmware/fw_jump.elf -kernel /usr/local/share/u-boot/u-boot-qemu-riscv64/u-boot.bin
+QEMU_MAX_CPU_COUNT=16
+QEMU_MAX_MEM_SIZE=64
+
+portinstall-riscv64: portinstall-pkg .PHONY
+.if !exists(/usr/local/share/opensbi/lp64/generic/firmware/fw_jump.elf)
+ env ASSUME_ALWAYS_YES=yes pkg install -y sysutils/opensbi
+.endif
+.if !exists(/usr/local/share/u-boot/u-boot-qemu-riscv64/u-boot.bin)
+ env ASSUME_ALWAYS_YES=yes pkg install -y sysutils/u-boot-qemu-riscv64
+.endif
+
+# XXX: Nothing should be changed below this line unless explicitly required.
+
+ci-buildworld-riscv64: ci-buildworld .PHONY
+
+ci-buildkernel-riscv64: ci-buildkernel .PHONY
+
+ci-buildimage-riscv64: ci-buildimage .PHONY
+
+ci-runtest-riscv64: ci-runtest .PHONY
diff --git a/tests/ci/tools/ci.conf b/tests/ci/tools/ci.conf
new file mode 100644
--- /dev/null
+++ b/tests/ci/tools/ci.conf
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+# Set to a list of third-party software to enable in rc.conf(5).
+export VM_RC_LIST="auditd freebsdci"
+
+# Install packages needed by tests:
+# coreutils: bin/date
+# gdb: local/kyua/utils/stacktrace_test
+# jq: sys/net/if_bridge_test
+# kyua: everything
+# ksh93: tests/sys/cddl/zfs/...
+# nist-kat: sys/opencrypto/runtests
+# nmap: sys/netinet/fibs_test:arpresolve_checks_interface_fib
+# perl5: lots of stuff
+# pkgconf: local/lutok/examples_test, local/atf/atf-c, local/atf/atf-c++
+# py-dpkt: sys/opencrypto/runtests
+# python3: sys/opencrypto/runtests
+# devel/py-pytest: sys/net/routing, tests in python in general
+# sudo: tests/sys/cddl/zfs/tests/delegate/...
+# tcptestsuite: network stack test suite
+export VM_EXTRA_PACKAGES="coreutils gdb jq ksh93 nist-kat nmap perl5 net/py-dpkt net/scapy python python3 devel/py-pytest sudo tcptestsuite"
+
+if [ "${TARGET}" = "amd64" ]; then
+ export VM_EXTRA_PACKAGES="$VM_EXTRA_PACKAGES linux-c7-ltp"
+fi
+
+vm_extra_pre_umount() {
+ cat << EOF >> ${DESTDIR}/boot/loader.conf
+autoboot_delay=1
+beastie_disable="YES"
+loader_logo="none"
+console="comconsole,vidconsole"
+net.fibs=3
+net.inet.ip.fw.default_to_accept=1
+mac_bsdextended_load="YES"
+vfs.zfs.arc_max=4294967296
+kern.vty=sc
+EOF
+ cat << EOF >> ${DESTDIR}/etc/kyua/kyua.conf
+test_suites.FreeBSD.ci = 'true'
+test_suites.FreeBSD.fibs = '1 2'
+test_suites.FreeBSD.allow_sysctl_side_effects = '1'
+test_suites.FreeBSD.cam_test_device = '/dev/ada0'
+test_suites.FreeBSD.disks = '/dev/vtbd2 /dev/vtbd3 /dev/vtbd4 /dev/vtbd5 /dev/vtbd6'
+EOF
+ cat << EOF >> ${DESTDIR}/etc/rc.conf
+kld_list="" # Load modules needed by tests
+kld_list="${kld_list} blake2" # sys/opencrypto
+kld_list="${kld_list} cryptodev" # sys/opencrypto
+kld_list="${kld_list} fusefs" # sys/fs/fusefs
+kld_list="${kld_list} ipsec" # sys/netipsec
+kld_list="${kld_list} mac_portacl" # sys/mac/portacl
+kld_list="${kld_list} mqueuefs" # sys/kern/mqueue_test
+kld_list="${kld_list} pfsync" # sys/netpfil/pf (loads pf)
+kld_list="${kld_list} pflog" # sys/netpfil/pf
+kld_list="${kld_list} ipl" # sys/sbin/ipf (loads ipfilter)
+kld_list="${kld_list} ipfw" # sys/netpfil/ipfw (loads ipfw)
+kld_list="${kld_list} ipfw_nat" # sys/netpfil/ipfw (loads ipfw_nat)
+kld_list="${kld_list} ipdivert" # sys/netinet (loads ipdivert)
+kld_list="${kld_list} dummynet" # sys/netpfil/common
+kld_list="${kld_list} carp" # sys/netinet/carp
+kld_list="${kld_list} if_stf" # sys/net/if_stf
+background_fsck="NO"
+sendmail_enable="NONE"
+cron_enable="NO"
+syslogd_enable="NO"
+newsyslog_enable="NO"
+EOF
+if [ "${CITYPE}" = "smoke" ]; then
+ cat << EOF >> ${DESTDIR}/etc/rc.conf
+freebsdci_type="smoke"
+EOF
+fi
+ cat <<EOF >> ${DESTDIR}/etc/sysctl.conf
+kern.cryptodevallowsoft=1
+kern.ipc.tls.enable=1
+net.add_addr_allfibs=0
+security.mac.bsdextended.enabled=0
+vfs.aio.enable_unsafe=1
+vfs.usermount=1
+EOF
+ cat <<EOF >> ${DESTDIR}/etc/fstab
+fdesc /dev/fd fdescfs rw 0 0
+EOF
+ mkdir -p ${DESTDIR}/usr/local/etc/rc.d
+ echo $scriptdir
+ cp -p ${scriptdir}/../../tests/ci/tools/freebsdci ${DESTDIR}/usr/local/etc/rc.d/
+ touch ${DESTDIR}/firstboot
+
+ return 0
+}
+
+vm_extra_pkg_rmcache() {
+ if [ -e ${DESTDIR}/usr/local/sbin/pkg ]; then
+ mount -t devfs devfs ${DESTDIR}/dev
+ chroot ${DESTDIR} ${EMULATOR} env ASSUME_ALWAYS_YES=yes \
+ /usr/local/sbin/pkg clean -y -a
+ umount_loop ${DESTDIR}/dev
+ fi
+
+ return 0
+}
diff --git a/tests/ci/tools/freebsdci b/tests/ci/tools/freebsdci
new file mode 100755
--- /dev/null
+++ b/tests/ci/tools/freebsdci
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+# KEYWORD: firstboot
+# PROVIDE: freebsdci
+# REQUIRE: NETWORKING
+# BEFORE: LOGIN
+
+# This script is used to run the firstboot CI tests on the first boot of a
+# FreeBSD image. It is enabled by default, but can be disabled by setting
+# freebsdci_enable="NO" in /etc/rc.conf.local or /etc/rc.conf. It is
+# automatically disabled after the first boot.
+#
+# The script will run the firstboot CI tests and then shut down the system.
+# The tests are run in the foreground so that the system can shut down
+# immediately after the tests are finished.
+#
+# Default test types are full and smoke. To run only the smoke tests, set
+# freebsdci_type="smoke" in /etc/rc.conf.local or /etc/rc.conf.
+# To run only the full tests, set freebsdci_type="full" in
+# /etc/rc.conf.local or /etc/rc.conf.
+
+. /etc/rc.subr
+
+: ${freebsdci_enable:="NO"}
+
+name="freebsdci"
+rcvar=freebsdci_enable
+start_cmd="firstboot_ci_run"
+stop_cmd=":"
+os_version=$(uname -K)
+os_arch=$(uname -p)
+
+auto_shutdown()
+{
+ # XXX: Currently RISC-V and MIPS64 kernels lack the ability
+ # to make qemu exit on shutdown. Reboot instead;
+ # it makes qemu exit too.
+ case "$os_arch" in
+ riscv64)
+ shutdown -r now
+ ;;
+ *)
+ shutdown -p now
+ ;;
+ esac
+}
+
+smoke_tests()
+{
+ echo
+ echo "--------------------------------------------------------------"
+ echo "BUILD sequence COMPLETED"
+ echo "IMAGE sequence COMPLETED"
+ echo "BOOT sequence COMPLETED"
+ echo "INITIATING system SHUTDOWN"
+ echo "--------------------------------------------------------------"
+}
+
+firstboot_ci_run()
+{
+ if [ $freebsdci_type = "smoke" ]; then
+ smoke_tests
+ fi
+ auto_shutdown
+}
+
+load_rc_config $name
+run_rc_command "$1"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 25, 7:26 PM (15 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16161078
Default Alt Text
D43786.id134000.diff (24 KB)
Attached To
Mode
D43786: M1: CI Scripts for Developers
Attached
Detach File
Event Timeline
Log In to Comment