brintos

brintos / linux-shallow public Read only

0
0
Text · 2.6 KiB · c3808c4 Raw
91 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.0+3#4# Carry out a kvm-based run for the specified batch of scenarios, which5# might have been built by --build-only kvm.sh run.6#7# Usage: kvm-test-1-run-batch.sh SCENARIO [ SCENARIO ... ]8#9# Each SCENARIO is the name of a directory in the current directory10#	containing a ready-to-run qemu-cmd file.11#12# Copyright (C) 2021 Facebook, Inc.13#14# Authors: Paul E. McKenney <paulmck@kernel.org>15 16T="`mktemp -d ${TMPDIR-/tmp}/kvm-test-1-run-batch.sh.XXXXXX`"17trap 'rm -rf $T' 018 19echo ---- Running batch $*20# Check arguments21runfiles=22for i in "$@"23do24	if ! echo $i | grep -q '^[^/.a-z]\+\(\.[0-9]\+\)\?$'25	then26		echo Bad scenario name: \"$i\" 1>&227		exit 128	fi29	if ! test -d "$i"30	then31		echo Scenario name not a directory: \"$i\" 1>&232		exit 233	fi34	if ! test -f "$i/qemu-cmd"35	then36		echo Scenario lacks a command file: \"$i/qemu-cmd\" 1>&237		exit 338	fi39	rm -f $i/build.*40	touch $i/build.run41	runfiles="$runfiles $i/build.run"42done43 44# Extract settings from the qemu-cmd file.45grep '^#' $1/qemu-cmd | sed -e 's/^# //' > $T/qemu-cmd-settings46. $T/qemu-cmd-settings47 48# Start up jitter, start each scenario, wait, end jitter.49echo ---- System running test: `uname -a`50echo ---- Starting kernels. `date` | tee -a log51$TORTURE_JITTER_START52kvm-assign-cpus.sh /sys/devices/system/node > $T/cpuarray.awk53for i in "$@"54do55	echo ---- System running test: `uname -a` > $i/kvm-test-1-run-qemu.sh.out56	echo > $i/kvm-test-1-run-qemu.sh.out57	export TORTURE_AFFINITY=58	kvm-get-cpus-script.sh $T/cpuarray.awk $T/cpubatches.awk $T/cpustate59	cat << '	___EOF___' >> $T/cpubatches.awk60	END {61		affinitylist = "";62		if (!gotcpus()) {63			print "echo No CPU-affinity information, so no taskset command.";64		} else if (cpu_count !~ /^[0-9][0-9]*$/) {65			print "echo " scenario ": Bogus number of CPUs (old qemu-cmd?), so no taskset command.";66		} else {67			affinitylist = nextcpus(cpu_count);68			if (!(affinitylist ~ /^[0-9,-][0-9,-]*$/))69				print "echo " scenario ": Bogus CPU-affinity information, so no taskset command.";70			else if (!dumpcpustate())71				print "echo " scenario ": Could not dump state, so no taskset command.";72			else73				print "export TORTURE_AFFINITY=" affinitylist;74		}75	}76	___EOF___77	cpu_count="`grep '# TORTURE_CPU_COUNT=' $i/qemu-cmd | sed -e 's/^.*=//'`"78	affinity_export="`awk -f $T/cpubatches.awk -v cpu_count="$cpu_count" -v scenario=$i < /dev/null`"79	$affinity_export80	kvm-test-1-run-qemu.sh $i >> $i/kvm-test-1-run-qemu.sh.out 2>&1 &81done82for i in $runfiles83do84	while ls $i > /dev/null 2>&185	do86		:87	done88done89echo ---- All kernel runs complete. `date` | tee -a log90$TORTURE_JITTER_STOP91