mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-23 19:28:36 +00:00
cb9d4bb1fb
The goal of this project is to integrate the relevant scripts from the FreeBSD-CI project (https://github.com/freebsd/freebsd-ci) into the src repository. This allows developers to run the test suite similar to how it is executed on ci.freebsd.org, and eventually, have it directly used by our CI system. This effort is also part of the workflow improvement project, aiming to incorporate pre-merge testing. Current Features: * Does smoke tests using either bhyve(amd64 only) or qemu(Non x86_64 or when defined USE_QEMU=1). Currently defined CITYPE=smoke. Once we have added full tests we can also utilize something like CITYPE=full * Most of the resources are dynamically allocated based on available resources in the host * If CPU supports POPCNT or vmm can be loaded then bhyve is used for amd64 otherwise automatically installs and uses qemu@nox11 * When required third party applications or packages for booting non-x86 images are automatically installed Current Limitation: * Does not support full tests like the one in our Jenkins * At this moment this is also not suitable to be used in our Jenkins platform as the jobs are divided in multiple smaller tasks and artifacts are moved here and there which are not exactly the scenario for individual developers. Future Works: * Add full tests like the one in ci.freebsd.org * Add different tests or options to disable some tests * Add test profiles full * Possibly add test through Cloud Providers like AWS/GCP/Azure or Cirrus or Github Actions * Update documentation Test Plan: cd /usr/src/tests/ci make ci make TARGET=amd64 TARGET_ARCH=amd64 ci make TARGET=amd64 TARGET_ARCH=amd64 USE_QEMU=1 ci make TARGET=arm64 TARGET_ARCH=aarch64 ci make TARGET=powerpc TARGET_ARCH=powerpc64 ci make TARGET=powerpc TARGET_ARCH=powerpc64le ci make TARGET=riscv TARGET_ARCH=riscv64 ci Reviewed by: lwhsu Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D43786
91 lines
2.2 KiB
Bash
Executable file
91 lines
2.2 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# 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.
|
|
#
|
|
# PROVIDE: freebsdci
|
|
# REQUIRE: LOGIN FILESYSTEMS
|
|
# KEYWORD: firstboot
|
|
|
|
# This script is used to run the firstboot CI tests on the first boot of a
|
|
# FreeBSD image. 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"
|
|
desc="Run FreeBSD CI"
|
|
rcvar=freebsdci_enable
|
|
start_cmd="firstboot_ci_run"
|
|
stop_cmd=":"
|
|
os_arch=$(uname -p)
|
|
|
|
auto_shutdown()
|
|
{
|
|
# XXX: Currently RISC-V 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 "--------------------------------------------------------------"
|
|
}
|
|
|
|
full_tests()
|
|
{
|
|
# Currently this is a placeholder.
|
|
# This will be used to add the full tests scenario those are run in
|
|
# the CI system
|
|
echo
|
|
echo "--------------------------------------------------------------"
|
|
echo "BUILD sequence COMPLETED"
|
|
echo "IMAGE sequence COMPLETED"
|
|
echo "BOOT sequence COMPLETED"
|
|
echo "TEST sequence STARTED"
|
|
echo "TEST sequence COMPLETED"
|
|
echo "INITIATING system SHUTDOWN"
|
|
echo "--------------------------------------------------------------"
|
|
}
|
|
|
|
firstboot_ci_run()
|
|
{
|
|
if [ "$freebsdci_type" = "smoke" ]; then
|
|
smoke_tests
|
|
elif [ "$freebsdci_type" = "full" ]; then
|
|
full_tests
|
|
fi
|
|
auto_shutdown
|
|
}
|
|
|
|
load_rc_config $name
|
|
run_rc_command "$1"
|