162306a36Sopenharmony_ci#!/bin/sh
262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0+
362306a36Sopenharmony_ci#
462306a36Sopenharmony_ci# Reruns the C-language litmus tests previously run that match the
562306a36Sopenharmony_ci# specified criteria, and compares the result to that of the previous
662306a36Sopenharmony_ci# runs from initlitmushist.sh and/or newlitmushist.sh.
762306a36Sopenharmony_ci#
862306a36Sopenharmony_ci# sh checklitmushist.sh
962306a36Sopenharmony_ci#
1062306a36Sopenharmony_ci# Run from the Linux kernel tools/memory-model directory.
1162306a36Sopenharmony_ci# See scripts/parseargs.sh for list of arguments.
1262306a36Sopenharmony_ci#
1362306a36Sopenharmony_ci# Copyright IBM Corporation, 2018
1462306a36Sopenharmony_ci#
1562306a36Sopenharmony_ci# Author: Paul E. McKenney <paulmck@linux.ibm.com>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci. scripts/parseargs.sh
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciT=/tmp/checklitmushist.sh.$$
2062306a36Sopenharmony_citrap 'rm -rf $T' 0
2162306a36Sopenharmony_cimkdir $T
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciif test -d litmus
2462306a36Sopenharmony_cithen
2562306a36Sopenharmony_ci	:
2662306a36Sopenharmony_cielse
2762306a36Sopenharmony_ci	echo Run scripts/initlitmushist.sh first, need litmus repo.
2862306a36Sopenharmony_ci	exit 1
2962306a36Sopenharmony_cifi
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci# Create the results directory and populate it with subdirectories.
3262306a36Sopenharmony_ci# The initial output is created here to avoid clobbering the output
3362306a36Sopenharmony_ci# generated earlier.
3462306a36Sopenharmony_cimkdir $T/results
3562306a36Sopenharmony_cifind litmus -type d -print | ( cd $T/results; sed -e 's/^/mkdir -p /' | sh )
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci# Create the list of litmus tests already run, then remove those that
3862306a36Sopenharmony_ci# are excluded by this run's --procs argument.
3962306a36Sopenharmony_ci( cd $LKMM_DESTDIR; find litmus -name '*.litmus.out' -print ) |
4062306a36Sopenharmony_ci	sed -e 's/\.out$//' |
4162306a36Sopenharmony_ci	xargs -r grep -L "^P${LKMM_PROCS}"> $T/list-C-already
4262306a36Sopenharmony_cixargs < $T/list-C-already -r grep -L "^P${LKMM_PROCS}" > $T/list-C-short
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci# Redirect output, run tests, then restore destination directory.
4562306a36Sopenharmony_cidestdir="$LKMM_DESTDIR"
4662306a36Sopenharmony_ciLKMM_DESTDIR=$T/results; export LKMM_DESTDIR
4762306a36Sopenharmony_ciscripts/runlitmushist.sh < $T/list-C-short > $T/runlitmushist.sh.out 2>&1
4862306a36Sopenharmony_ciLKMM_DESTDIR="$destdir"; export LKMM_DESTDIR
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci# Move the newly generated .litmus.out files to .litmus.out.new files
5162306a36Sopenharmony_ci# in the destination directory.
5262306a36Sopenharmony_cicdir=`pwd`
5362306a36Sopenharmony_ciddir=`awk -v c="$cdir" -v d="$LKMM_DESTDIR" \
5462306a36Sopenharmony_ci	'END { if (d ~ /^\//) print d; else print c "/" d; }' < /dev/null`
5562306a36Sopenharmony_ci( cd $T/results; find litmus -type f -name '*.litmus.out' -print |
5662306a36Sopenharmony_ci  sed -e 's,^.*$,cp & '"$ddir"'/&.new,' | sh )
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_cised < $T/list-C-short -e 's,^,'"$LKMM_DESTDIR/"',' |
5962306a36Sopenharmony_ci	sh scripts/cmplitmushist.sh
6062306a36Sopenharmony_ciexit $?
61