Skip to content

Commit 0783f21

Browse files
paulmckrcuNeeraj Upadhyay (AMD)
authored andcommitted
torture: Extract testid.txt generation to separate script
The kvm.sh script places a testid.txt file in the top-level results directory in order to identify the tree and commit that was tested. This works well, but there are scripts other than kvm.sh that also create results directories, and it would be good for them to also identify exactly what was tested. This commit therefore extracts the testid.txt generation to a new mktestid.sh script so that it can be easily used elsewhere. Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Neeraj Upadhyay (AMD) <[email protected]>
1 parent ce243b7 commit 0783f21

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

tools/testing/selftests/rcutorture/bin/kvm.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -442,18 +442,7 @@ echo $scriptname $args
442442
touch $resdir/$ds/log
443443
echo $scriptname $args >> $resdir/$ds/log
444444
echo ${TORTURE_SUITE} > $resdir/$ds/torture_suite
445-
echo Build directory: `pwd` > $resdir/$ds/testid.txt
446-
if test -d .git
447-
then
448-
echo Current commit: `git rev-parse HEAD` >> $resdir/$ds/testid.txt
449-
echo >> $resdir/$ds/testid.txt
450-
echo ' ---' Output of "'"git status"'": >> $resdir/$ds/testid.txt
451-
git status >> $resdir/$ds/testid.txt
452-
echo >> $resdir/$ds/testid.txt
453-
echo >> $resdir/$ds/testid.txt
454-
echo ' ---' Output of "'"git diff HEAD"'": >> $resdir/$ds/testid.txt
455-
git diff HEAD >> $resdir/$ds/testid.txt
456-
fi
445+
mktestid.sh $resdir/$ds
457446
___EOF___
458447
kvm-assign-cpus.sh /sys/devices/system/node > $T/cpuarray.awk
459448
kvm-get-cpus-script.sh $T/cpuarray.awk $T/dumpbatches.awk
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0+
3+
#
4+
# Create a testid.txt file in the specified directory.
5+
#
6+
# Usage: mktestid.sh dirpath
7+
#
8+
# Copyright (C) Meta Platforms, Inc. 2025
9+
#
10+
# Author: Paul E. McKenney <[email protected]>
11+
12+
resdir="$1"
13+
if test -z "${resdir}" || ! test -d "${resdir}" || ! test -w "${resdir}"
14+
then
15+
echo Path '"'${resdir}'"' not writeable directory, no ${resdir}/testid.txt.
16+
exit 1
17+
fi
18+
echo Build directory: `pwd` > ${resdir}/testid.txt
19+
if test -d .git
20+
then
21+
echo Current commit: `git rev-parse HEAD` >> ${resdir}/testid.txt
22+
echo >> ${resdir}/testid.txt
23+
echo ' ---' Output of "'"git status"'": >> ${resdir}/testid.txt
24+
git status >> ${resdir}/testid.txt
25+
echo >> ${resdir}/testid.txt
26+
echo >> ${resdir}/testid.txt
27+
echo ' ---' Output of "'"git diff HEAD"'": >> ${resdir}/testid.txt
28+
git diff HEAD >> ${resdir}/testid.txt
29+
fi

0 commit comments

Comments
 (0)