162306a36Sopenharmony_ci#!/bin/sh
262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0+
362306a36Sopenharmony_ci#
462306a36Sopenharmony_ci# Runs the C-language litmus tests matching the specified criteria
562306a36Sopenharmony_ci# that do not already have a corresponding .litmus.out file, and does
662306a36Sopenharmony_ci# not judge the result.
762306a36Sopenharmony_ci#
862306a36Sopenharmony_ci# sh newlitmushist.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/newlitmushist.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 any new directories that have appeared in the github litmus
3262306a36Sopenharmony_ci# repo since the last run.
3362306a36Sopenharmony_ciif test "$LKMM_DESTDIR" != "."
3462306a36Sopenharmony_cithen
3562306a36Sopenharmony_ci	find litmus -type d -print |
3662306a36Sopenharmony_ci	( cd "$LKMM_DESTDIR"; sed -e 's/^/mkdir -p /' | sh )
3762306a36Sopenharmony_cifi
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci# Create a list of the C-language litmus tests previously run.
4062306a36Sopenharmony_ci( cd $LKMM_DESTDIR; find litmus -name '*.litmus.out' -print ) |
4162306a36Sopenharmony_ci	sed -e 's/\.out$//' |
4262306a36Sopenharmony_ci	xargs -r grep -L "^P${LKMM_PROCS}"> $T/list-C-already
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci# Form full list of litmus tests with no more than the specified
4562306a36Sopenharmony_ci# number of processes (per the --procs argument).
4662306a36Sopenharmony_cifind litmus -name '*.litmus' -print | mselect7 -arch C > $T/list-C-all
4762306a36Sopenharmony_cixargs < $T/list-C-all -r grep -L "^P${LKMM_PROCS}" > $T/list-C-short
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci# Form list of new tests.  Note: This does not handle litmus-test deletion!
5062306a36Sopenharmony_cisort $T/list-C-already $T/list-C-short | uniq -u > $T/list-C-new
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci# Form list of litmus tests that have changed since the last run.
5362306a36Sopenharmony_cised < $T/list-C-short -e 's,^.*$,if test & -nt '"$LKMM_DESTDIR"'/&.out; then echo &; fi,' > $T/list-C-script
5462306a36Sopenharmony_cish $T/list-C-script > $T/list-C-newer
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci# Merge the list of new and of updated litmus tests: These must be (re)run.
5762306a36Sopenharmony_cisort -u $T/list-C-new $T/list-C-newer > $T/list-C-needed
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciscripts/runlitmushist.sh < $T/list-C-needed
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ciexit 0
62