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# Generates the output for each .litmus file into a corresponding
662306a36Sopenharmony_ci# .litmus.out file, and does not judge the result.
762306a36Sopenharmony_ci#
862306a36Sopenharmony_ci# sh initlitmushist.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# This script can consume significant wallclock time and CPU, especially as
1462306a36Sopenharmony_ci# the value of --procs rises.  On a four-core (eight hardware threads)
1562306a36Sopenharmony_ci# 2.5GHz x86 with a one-minute per-run timeout:
1662306a36Sopenharmony_ci#
1762306a36Sopenharmony_ci# --procs wallclock CPU		timeouts	tests
1862306a36Sopenharmony_ci#	1 0m11.241s 0m1.086s           0	   19
1962306a36Sopenharmony_ci#	2 1m12.598s 2m8.459s           2	  393
2062306a36Sopenharmony_ci#	3 1m30.007s 6m2.479s           4	 2291
2162306a36Sopenharmony_ci#	4 3m26.042s 18m5.139s	       9	 3217
2262306a36Sopenharmony_ci#	5 4m26.661s 23m54.128s	      13	 3784
2362306a36Sopenharmony_ci#	6 4m41.900s 26m4.721s         13	 4352
2462306a36Sopenharmony_ci#	7 5m51.463s 35m50.868s        13	 4626
2562306a36Sopenharmony_ci#	8 10m5.235s 68m43.672s        34	 5117
2662306a36Sopenharmony_ci#	9 15m57.80s 105m58.101s       69	 5156
2762306a36Sopenharmony_ci#      10 16m14.13s 103m35.009s       69         5165
2862306a36Sopenharmony_ci#      20 27m48.55s 198m3.286s       156         5269
2962306a36Sopenharmony_ci#
3062306a36Sopenharmony_ci# Increasing the timeout on the 20-process run to five minutes increases
3162306a36Sopenharmony_ci# the runtime to about 90 minutes with the CPU time rising to about
3262306a36Sopenharmony_ci# 10 hours.  On the other hand, it decreases the number of timeouts to 101.
3362306a36Sopenharmony_ci#
3462306a36Sopenharmony_ci# Note that there are historical tests for which herd7 will fail
3562306a36Sopenharmony_ci# completely, for example, litmus/manual/atomic/C-unlock-wait-00.litmus
3662306a36Sopenharmony_ci# contains a call to spin_unlock_wait(), which no longer exists in either
3762306a36Sopenharmony_ci# the kernel or LKMM.
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci. scripts/parseargs.sh
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ciT=/tmp/initlitmushist.sh.$$
4262306a36Sopenharmony_citrap 'rm -rf $T' 0
4362306a36Sopenharmony_cimkdir $T
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciif test -d litmus
4662306a36Sopenharmony_cithen
4762306a36Sopenharmony_ci	:
4862306a36Sopenharmony_cielse
4962306a36Sopenharmony_ci	git clone https://github.com/paulmckrcu/litmus
5062306a36Sopenharmony_ci	( cd litmus; git checkout origin/master )
5162306a36Sopenharmony_cifi
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci# Create any new directories that have appeared in the github litmus
5462306a36Sopenharmony_ci# repo since the last run.
5562306a36Sopenharmony_ciif test "$LKMM_DESTDIR" != "."
5662306a36Sopenharmony_cithen
5762306a36Sopenharmony_ci	find litmus -type d -print |
5862306a36Sopenharmony_ci	( cd "$LKMM_DESTDIR"; sed -e 's/^/mkdir -p /' | sh )
5962306a36Sopenharmony_cifi
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci# Create a list of the C-language litmus tests with no more than the
6262306a36Sopenharmony_ci# specified number of processes (per the --procs argument).
6362306a36Sopenharmony_cifind litmus -name '*.litmus' -print | mselect7 -arch C > $T/list-C
6462306a36Sopenharmony_cixargs < $T/list-C -r grep -L "^P${LKMM_PROCS}" > $T/list-C-short
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ciscripts/runlitmushist.sh < $T/list-C-short
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ciexit 0
69