tools/testing/selftests/nolibc/run-tests.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/nolibc/run-tests.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/nolibc/run-tests.sh
Extension
.sh
Size
4999 bytes
Lines
221
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

function swallow_output() {
	if ! OUTPUT="$("$@" 2>&1)"; then
		echo "$OUTPUT"
		return 1
	fi
	return 0
}

test_arch() {
	arch=$1
	ct_arch=$(crosstool_arch "$arch")
	ct_abi=$(crosstool_abi "$1")

	if [ ! -d "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/." ]; then
		echo "No toolchain found in ${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}."
		echo "Did you install the toolchains or set the correct arch ? Rerun with -h for help."
		return 1
	fi

	cross_compile=$(realpath "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/${ct_arch}-${ct_abi}-")
	build_dir="${build_location}/${arch}"
	if [ "$werror" -ne 0 ]; then
		CFLAGS_EXTRA="$CFLAGS_EXTRA -Werror -Wl,--fatal-warnings"
	fi
	MAKE=(make -f Makefile.nolibc -j"${nproc}" XARCH="${arch}" CROSS_COMPILE="${cross_compile}" LLVM="${llvm}" O="${build_dir}")

	if [ "$arch" = "parisc32" ]; then
		MAKE+=("CROSS32CC=${cross_compile}gcc")
	fi

	case "$test_mode" in
		'system')
			test_target=run
			;;
		'user')
			test_target=run-user
			;;
		*)
			echo "Unknown mode $test_mode"
			exit 1
	esac
	printf '%-15s' "$arch:"
	if [ "$arch" = "m68k" -o "$arch" = "sh4" -o "$arch" = "openrisc" -o "$arch" = "parisc32" ] && [ "$llvm" = "1" ]; then
		echo "Unsupported configuration"
		return
	fi
	if [ "$arch" = "x32" ] && [ "$test_mode" = "user" ]; then
		echo "Unsupported configuration"
		return
	fi

	mkdir -p "$build_dir"
	swallow_output "${MAKE[@]}" defconfig
	swallow_output "${MAKE[@]}" CFLAGS_EXTRA="$CFLAGS_EXTRA" "$test_target" V=1
	cp run.out run.out."${arch}"
	"${MAKE[@]}" report | grep passed
}

if [ "$perform_download" -ne 0 ]; then
	for arch in $archs; do
		download_crosstool "$arch"
	done
fi

for arch in $archs; do
	test_arch "$arch"
done

Annotation

Implementation Notes