18c2ecf20Sopenharmony_ci#!/bin/sh
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0+
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci# Runs the C-language litmus tests matching the specified criteria
58c2ecf20Sopenharmony_ci# that do not already have a corresponding .litmus.out file, and does
68c2ecf20Sopenharmony_ci# not judge the result.
78c2ecf20Sopenharmony_ci#
88c2ecf20Sopenharmony_ci# sh newlitmushist.sh
98c2ecf20Sopenharmony_ci#
108c2ecf20Sopenharmony_ci# Run from the Linux kernel tools/memory-model directory.
118c2ecf20Sopenharmony_ci# See scripts/parseargs.sh for list of arguments.
128c2ecf20Sopenharmony_ci#
138c2ecf20Sopenharmony_ci# Copyright IBM Corporation, 2018
148c2ecf20Sopenharmony_ci#
158c2ecf20Sopenharmony_ci# Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci. scripts/parseargs.sh
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciT=/tmp/newlitmushist.sh.$$
208c2ecf20Sopenharmony_citrap 'rm -rf $T' 0
218c2ecf20Sopenharmony_cimkdir $T
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ciif test -d litmus
248c2ecf20Sopenharmony_cithen
258c2ecf20Sopenharmony_ci	:
268c2ecf20Sopenharmony_cielse
278c2ecf20Sopenharmony_ci	echo Run scripts/initlitmushist.sh first, need litmus repo.
288c2ecf20Sopenharmony_ci	exit 1
298c2ecf20Sopenharmony_cifi
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci# Create any new directories that have appeared in the github litmus
328c2ecf20Sopenharmony_ci# repo since the last run.
338c2ecf20Sopenharmony_ciif test "$LKMM_DESTDIR" != "."
348c2ecf20Sopenharmony_cithen
358c2ecf20Sopenharmony_ci	find litmus -type d -print |
368c2ecf20Sopenharmony_ci	( cd "$LKMM_DESTDIR"; sed -e 's/^/mkdir -p /' | sh )
378c2ecf20Sopenharmony_cifi
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci# Create a list of the C-language litmus tests previously run.
408c2ecf20Sopenharmony_ci( cd $LKMM_DESTDIR; find litmus -name '*.litmus.out' -print ) |
418c2ecf20Sopenharmony_ci	sed -e 's/\.out$//' |
428c2ecf20Sopenharmony_ci	xargs -r grep -L "^P${LKMM_PROCS}"> $T/list-C-already
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci# Form full list of litmus tests with no more than the specified
458c2ecf20Sopenharmony_ci# number of processes (per the --procs argument).
468c2ecf20Sopenharmony_cifind litmus -name '*.litmus' -exec grep -l -m 1 "^C " {} \; > $T/list-C-all
478c2ecf20Sopenharmony_cixargs < $T/list-C-all -r grep -L "^P${LKMM_PROCS}" > $T/list-C-short
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci# Form list of new tests.  Note: This does not handle litmus-test deletion!
508c2ecf20Sopenharmony_cisort $T/list-C-already $T/list-C-short | uniq -u > $T/list-C-new
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci# Form list of litmus tests that have changed since the last run.
538c2ecf20Sopenharmony_cised < $T/list-C-short -e 's,^.*$,if test & -nt '"$LKMM_DESTDIR"'/&.out; then echo &; fi,' > $T/list-C-script
548c2ecf20Sopenharmony_cish $T/list-C-script > $T/list-C-newer
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci# Merge the list of new and of updated litmus tests: These must be (re)run.
578c2ecf20Sopenharmony_cisort -u $T/list-C-new $T/list-C-newer > $T/list-C-needed
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ciscripts/runlitmushist.sh < $T/list-C-needed
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ciexit 0
62