Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Dec 2025 09:21:26 +0000
Message-ID:  <69427616.3c460.6f282e9c@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by bofh:

URL: https://cgit.FreeBSD.org/src/commit/?id=14d5c13a89269862b51ef2a7f190b0d28cfbf8a2

commit 14d5c13a89269862b51ef2a7f190b0d28cfbf8a2
Author:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
AuthorDate: 2025-12-16 09:24:55 +0000
Commit:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2025-12-17 09:20:33 +0000

    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
---
 tests/ci/Makefile        | 43 +++++++++++++++++++++++++++++++++++-
 tests/ci/tools/freebsdci | 57 +++++++++++++++++++++++++++++-------------------
 2 files changed, 77 insertions(+), 23 deletions(-)

diff --git a/tests/ci/Makefile b/tests/ci/Makefile
index 30ca34a810be..a750b1265169 100644
--- a/tests/ci/Makefile
+++ b/tests/ci/Makefile
@@ -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} .
 
diff --git a/tests/ci/tools/freebsdci b/tests/ci/tools/freebsdci
index 42c565a45055..f71ccc1cad4f 100755
--- a/tests/ci/tools/freebsdci
+++ b/tests/ci/tools/freebsdci
@@ -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
 }
 


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69427616.3c460.6f282e9c>