Path: blob/master/tools/memory-model/scripts/runlitmus.sh
29266 views
#!/bin/sh1# SPDX-License-Identifier: GPL-2.0+2#3# Without the -hw argument, runs a herd7 test and outputs verification4# results to a file whose name is that of the specified litmus test,5# but with ".out" appended.6#7# If the --hw argument is specified, this script translates the .litmus8# C-language file to the specified type of assembly and verifies that.9# But in this case, litmus tests using complex synchronization (such as10# locking, RCU, and SRCU) are cheerfully ignored.11#12# Either way, return the status of the herd7 command.13#14# Usage:15# runlitmus.sh file.litmus16#17# Run this in the directory containing the memory model, specifying the18# pathname of the litmus test to check. The caller is expected to have19# properly set up the LKMM environment variables.20#21# Copyright IBM Corporation, 201922#23# Author: Paul E. McKenney <[email protected]>2425litmus=$126if test -f "$litmus" -a -r "$litmus"27then28:29else30echo ' !!! ' error: \"$litmus\" is not a readable file31exit 25532fi3334if test -z "$LKMM_HW_MAP_FILE" -o ! -e $LKMM_DESTDIR/$litmus.out35then36# LKMM run37herdoptions=${LKMM_HERD_OPTIONS--conf linux-kernel.cfg}38echo Herd options: $herdoptions > $LKMM_DESTDIR/$litmus.out39/usr/bin/time $LKMM_TIMEOUT_CMD herd7 $herdoptions $litmus >> $LKMM_DESTDIR/$litmus.out 2>&140ret=$?41if test -z "$LKMM_HW_MAP_FILE"42then43exit $ret44fi45echo " --- " Automatically generated LKMM output for '"'--hw $LKMM_HW_MAP_FILE'"' run46fi4748# Hardware run4950T=/tmp/checklitmushw.sh.$$51trap 'rm -rf $T' 0 252mkdir $T5354# Generate filenames55mapfile="Linux2${LKMM_HW_MAP_FILE}.map"56themefile="$T/${LKMM_HW_MAP_FILE}.theme"57herdoptions="-model $LKMM_HW_CAT_FILE"58hwlitmus=`echo $litmus | sed -e 's/\.litmus$/.litmus.'${LKMM_HW_MAP_FILE}'/'`59hwlitmusfile=`echo $hwlitmus | sed -e 's,^.*/,,'`6061# Don't run on litmus tests with complex synchronization62if ! scripts/simpletest.sh $litmus63then64echo ' --- ' error: \"$litmus\" contains locking, RCU, or SRCU65exit 25466fi6768# Generate the assembly code and run herd7 on it.69gen_theme7 -n 10 -map $mapfile -call Linux.call > $themefile70jingle7 -v -theme $themefile $litmus > $LKMM_DESTDIR/$hwlitmus 2> $T/$hwlitmusfile.jingle7.out71if grep -q "Generated 0 tests" $T/$hwlitmusfile.jingle7.out72then73echo ' !!! ' jingle7 failed, errors in $hwlitmus.err74cp $T/$hwlitmusfile.jingle7.out $LKMM_DESTDIR/$hwlitmus.err75exit 25376fi77/usr/bin/time $LKMM_TIMEOUT_CMD herd7 -unroll 0 $LKMM_DESTDIR/$hwlitmus > $LKMM_DESTDIR/$hwlitmus.out 2>&17879exit $?808182