tools/perf/tests/shell/buildid.sh

Source file repositories/reference/linux-study-clean/tools/perf/tests/shell/buildid.sh

File Facts

System
Linux kernel
Corpus path
tools/perf/tests/shell/buildid.sh
Extension
.sh
Size
7355 bytes
Lines
327
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

#!/bin/bash
# build id cache operations
# SPDX-License-Identifier: GPL-2.0

# skip if there's no readelf
if ! [ -x "$(command -v readelf)" ]; then
	echo "failed: no readelf, install binutils"
	exit 2
fi

# skip if there's no compiler
if ! [ -x "$(command -v cc)" ]; then
	echo "failed: no compiler, install gcc"
	exit 2
fi

# check what we need to test windows binaries
add_pe=1
run_pe=1
if ! perf version --build-options | grep -q 'libbfd: .* on '; then
	echo "WARNING: perf not built with libbfd. PE binaries will not be tested."
	add_pe=0
	run_pe=0
fi
if ! which wine > /dev/null; then
	echo "WARNING: wine not found. PE binaries will not be run."
	run_pe=0
fi

# set up wine
if [ ${run_pe} -eq 1 ]; then
	wineprefix=$(mktemp -d /tmp/perf.wineprefix.XXX)
	export WINEPREFIX=${wineprefix}
	# clear display variables to prevent wine from popping up dialogs
	unset DISPLAY
	unset WAYLAND_DISPLAY
fi

build_id_dir=
ex_source=$(mktemp /tmp/perf_buildid_test.ex.XXX.c)
ex_md5=$(mktemp /tmp/perf_buildid_test.ex.MD5.XXX)
ex_sha1=$(mktemp /tmp/perf_buildid_test.ex.SHA1.XXX)
ex_pe=$(dirname $0)/../pe-file.exe
data=$(mktemp /tmp/perf_buildid_test.data.XXX)
log_out=$(mktemp /tmp/perf_buildid_test.log.out.XXX)
log_err=$(mktemp /tmp/perf_buildid_test.log.err.XXX)

cleanup() {
	rm -f ${ex_source} ${ex_md5} ${ex_sha1} ${data} ${log_out} ${log_err}
	if [ ${run_pe} -eq 1 ]; then
		rm -r ${wineprefix}
	fi
        if [ -d ${build_id_dir} ]; then
		rm -rf ${build_id_dir}
        fi
	trap - EXIT TERM INT
}

trap_cleanup() {
	echo "Unexpected signal in ${FUNCNAME[1]}"
	cleanup
	exit 1
}
trap trap_cleanup EXIT TERM INT

# Test program based on the noploop workload.
cat <<EOF > ${ex_source}
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>

Annotation

Implementation Notes