18c2ecf20Sopenharmony_ci#!/bin/sh
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0+
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci# Run herd7 tests on all .litmus files in the litmus-tests directory
58c2ecf20Sopenharmony_ci# and check each file's result against a "Result:" comment within that
68c2ecf20Sopenharmony_ci# litmus test.  If the verification result does not match that specified
78c2ecf20Sopenharmony_ci# in the litmus test, this script prints an error message prefixed with
88c2ecf20Sopenharmony_ci# "^^^".  It also outputs verification results to a file whose name is
98c2ecf20Sopenharmony_ci# that of the specified litmus test, but with ".out" appended.
108c2ecf20Sopenharmony_ci#
118c2ecf20Sopenharmony_ci# Usage:
128c2ecf20Sopenharmony_ci#	checkalllitmus.sh
138c2ecf20Sopenharmony_ci#
148c2ecf20Sopenharmony_ci# Run this in the directory containing the memory model.
158c2ecf20Sopenharmony_ci#
168c2ecf20Sopenharmony_ci# This script makes no attempt to run the litmus tests concurrently.
178c2ecf20Sopenharmony_ci#
188c2ecf20Sopenharmony_ci# Copyright IBM Corporation, 2018
198c2ecf20Sopenharmony_ci#
208c2ecf20Sopenharmony_ci# Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci. scripts/parseargs.sh
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cilitmusdir=litmus-tests
258c2ecf20Sopenharmony_ciif test -d "$litmusdir" -a -r "$litmusdir" -a -x "$litmusdir"
268c2ecf20Sopenharmony_cithen
278c2ecf20Sopenharmony_ci	:
288c2ecf20Sopenharmony_cielse
298c2ecf20Sopenharmony_ci	echo ' --- ' error: $litmusdir is not an accessible directory
308c2ecf20Sopenharmony_ci	exit 255
318c2ecf20Sopenharmony_cifi
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci# Create any new directories that have appeared in the github litmus
348c2ecf20Sopenharmony_ci# repo since the last run.
358c2ecf20Sopenharmony_ciif test "$LKMM_DESTDIR" != "."
368c2ecf20Sopenharmony_cithen
378c2ecf20Sopenharmony_ci	find $litmusdir -type d -print |
388c2ecf20Sopenharmony_ci	( cd "$LKMM_DESTDIR"; sed -e 's/^/mkdir -p /' | sh )
398c2ecf20Sopenharmony_cifi
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci# Find the checklitmus script.  If it is not where we expect it, then
428c2ecf20Sopenharmony_ci# assume that the caller has the PATH environment variable set
438c2ecf20Sopenharmony_ci# appropriately.
448c2ecf20Sopenharmony_ciif test -x scripts/checklitmus.sh
458c2ecf20Sopenharmony_cithen
468c2ecf20Sopenharmony_ci	clscript=scripts/checklitmus.sh
478c2ecf20Sopenharmony_cielse
488c2ecf20Sopenharmony_ci	clscript=checklitmus.sh
498c2ecf20Sopenharmony_cifi
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci# Run the script on all the litmus tests in the specified directory
528c2ecf20Sopenharmony_ciret=0
538c2ecf20Sopenharmony_cifor i in $litmusdir/*.litmus
548c2ecf20Sopenharmony_cido
558c2ecf20Sopenharmony_ci	if ! $clscript $i
568c2ecf20Sopenharmony_ci	then
578c2ecf20Sopenharmony_ci		ret=1
588c2ecf20Sopenharmony_ci	fi
598c2ecf20Sopenharmony_cidone
608c2ecf20Sopenharmony_ciif test "$ret" -ne 0
618c2ecf20Sopenharmony_cithen
628c2ecf20Sopenharmony_ci	echo " ^^^ VERIFICATION MISMATCHES" 1>&2
638c2ecf20Sopenharmony_cielse
648c2ecf20Sopenharmony_ci	echo All litmus tests verified as was expected. 1>&2
658c2ecf20Sopenharmony_cifi
668c2ecf20Sopenharmony_ciexit $ret
67