tests/ci: Collect environment information

For reproducing errors or test results it is important to gather
environment information. These environments are divided into two parts.
One part is in which environment the artifacts were built into and the
second part is in which environment the tests were run.

This patch collects thesee information and saves into a .env file in
the metadir. After this patch lands we will also need to change our
jenkins job where we are uploading the artifact to a central location.
This environment file should also be stored along with the artifact.
For easier location the image basename and the environment basename are
kept same.

Approved by:	lwhsu
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D54247
This commit is contained in:
Muhammad Moinur Rahman 2025-12-16 10:24:55 +01:00
parent f94bfc469d
commit 14d5c13a89
No known key found for this signature in database
GPG key ID: BDB9B5A617C0BC91
2 changed files with 77 additions and 23 deletions

View file

@ -82,6 +82,7 @@ KYUA_TEST_FILTERS?=
META_TAR!=mktemp /tmp/meta.XXXXXX
META_DIR!=mktemp -d /tmp/meta.XXXXXX
META_DIROUT!=mktemp -d /tmp/meta.XXXXXX
ENV_FILE= ${META_DIR}/ci-${OSRELEASE}-${GITREV}-${KERNCONF}.env
DISC_CAM!=truncate -s 128m /tmp/disk-cam
EXTRA_DISK_NUM?=5
DISK_NUMBERS!=jot - 1 ${EXTRA_DISK_NUM}
@ -201,7 +202,47 @@ CITYPE=smoke
ci-set-full-var: .PHONY
CITYPE=full
ci-create-meta: .PHONY
ci-get-env: .PHONY
@echo "TARGET=${TARGET}" > ${ENV_FILE}
@echo "TARGET_ARCH=${TARGET_ARCH}" >> ${ENV_FILE}
@echo "KERNCONF=${KERNCONF}" >> ${ENV_FILE}
@echo "OSRELEASE=${OSRELEASE}" >> ${ENV_FILE}
@echo "CIIMAGE=${CIIMAGE}" >> ${ENV_FILE}
@echo "CIDISK=${CIDISK}" >> ${ENV_FILE}
@echo "VMSIZE=${VMSIZE}" >> ${ENV_FILE}
@echo "VM_MEM_SIZE=${VM_MEM_SIZE}" >> ${ENV_FILE}
@echo "TIMEOUT=${TIMEOUT}s" >> ${ENV_FILE}
@echo "CITYPE=${CITYPE}" >> ${ENV_FILE}
@echo "KYUA_TEST_FILTERS='${KYUA_TEST_FILTERS}'" >> ${ENV_FILE}
@echo "META_MODE='${METAMODE}'" >> ${ENV_FILE}
@echo "USE_QEMU='${USE_QEMU}'" >> ${ENV_FILE}
@echo "GITREV='${GITREV}'" >> ${ENV_FILE}
@echo "GITBRANCH='${GITBRANCH}'" >> ${ENV_FILE}
@echo "GITCOUNT='${GITCOUNT}'" >> ${ENV_FILE}
@echo "BUILDDATE='${BUILDDATE}'" >> ${ENV_FILE}
@echo "CC='${CC}'" >> ${ENV_FILE}
@echo "CFLAGS='${CFLAGS}'" >> ${ENV_FILE}
@echo "CPP='${CPP}'" >> ${ENV_FILE}
@echo "CXX='${CXX}'" >> ${ENV_FILE}
@echo "CXXFLAGS='${CXXFLAGS}'" >> ${ENV_FILE}
@echo "COMPILER_FEATURES='${COMPILER_FEATURES}'" >> ${ENV_FILE}
@echo "COMPILER_FREEBSD_VERSION='${COMPILER_FREEBSD_VERSION}'" >> ${ENV_FILE}
@echo "COMPILER_TYPE='${COMPILER_TYPE}'" >> ${ENV_FILE}
@echo "COMPILER_VERSION='${COMPILER_VERSION}'" >> ${ENV_FILE}
@echo "HOST_CC='${HOST_CC}'" >> ${ENV_FILE}
@echo "HOST_MACHINE='${HOST_MACHINE}'" >> ${ENV_FILE}
@echo "HOST_OS='${HOST_OS}'" >> ${ENV_FILE}
@echo "HOST_OSMAJOR='${HOST_OSMAJOR}'" >> ${ENV_FILE}
@echo "HOST_OSTYPE='${HOST_OSTYPE}'" >> ${ENV_FILE}
@echo "LD='${LD}'" >> ${ENV_FILE}
@echo "LDFLAGS='${LDFLAGS}'" >> ${ENV_FILE}
@echo "MACHINE='${MACHINE}'" >> ${ENV_FILE}
@echo "MACHINE_ABI='${MACHINE_ABI}'" >> ${ENV_FILE}
@echo "MACHINE_ARCH='${MACHINE_ARCH}'" >> ${ENV_FILE}
@echo "MACHINE_CPU='${MACHINE_CPU}'" >> ${ENV_FILE}
@echo "MACHINE_CPUARCH='${MACHINE_CPUARCH}'" >> ${ENV_FILE}
ci-create-meta: ci-get-env .PHONY
truncate -s 512M ${META_TAR}
tar rvf ${META_TAR} -C ${META_DIR} .

View file

@ -57,6 +57,27 @@ auto_shutdown()
esac
}
set_environment()
{
if [ "${istar}" -eq 1 ]; then
rm -fr ${metadir}
mkdir -p ${metadir}
tar xvf ${tardev} -C ${metadir}
ci_env_file=$(set -- "${metadir}"/ci-*.env; \
[ "$#" -eq 1 ] && printf '%s\n' "$1")
if [ -z "${ci_env_file}" ]; then
echo "ci: No CI environment file found in ${metadir}"
else
env >> "${ci_env_file}"
fi
else
echo "ERROR: no device with POSIX tar archive format found."
# Don't shutdown because this is not run in unattended mode
exit 1
fi
}
smoke_tests()
{
echo
@ -72,29 +93,19 @@ full_tests()
echo "--------------------------------------------------------------"
echo "BOOT sequence COMPLETED"
echo "TEST sequence STARTED"
if [ "${istar}" -eq 1 ]; then
rm -fr ${metadir}
mkdir -p ${metadir}
tar xvf ${tardev} -C ${metadir}
cd /usr/tests
set +e
kyua \
-v parallelism=${parallelism} \
test ${freebsdci_test_filters}
rc=$?
set -e
if [ ${rc} -ne 0 ] && [ ${rc} -ne 1 ]; then
exit ${rc}
fi
kyua report --verbose --results-filter passed,skipped,xfail,broken,failed --output test-report.txt
kyua report-junit --output=test-report.xml
mv test-report.* /${metadir}
tar cvf ${tardev} -C ${metadir} .
else
echo "ERROR: no device with POSIX tar archive format found."
# Don't shutdown because this is not run in unattended mode
exit 1
cd /usr/tests
set +e
kyua \
-v parallelism=${parallelism} \
test ${freebsdci_test_filters}
rc=$?
set -e
if [ ${rc} -ne 0 ] && [ ${rc} -ne 1 ]; then
exit ${rc}
fi
kyua report --verbose --results-filter passed,skipped,xfail,broken,failed --output test-report.txt
kyua report-junit --output=test-report.xml
mv test-report.* /${metadir}
echo "TEST sequence COMPLETED"
echo "INITIATING system SHUTDOWN"
echo "--------------------------------------------------------------"
@ -102,11 +113,13 @@ full_tests()
firstboot_ci_run()
{
set_environment
if [ "$freebsdci_type" = "smoke" ]; then
smoke_tests
elif [ "$freebsdci_type" = "full" ]; then
full_tests
fi
tar cvf ${tardev} -C ${metadir} .
auto_shutdown
}