Skip to content

Commit ea1bf0b

Browse files
keesshuahkh
authored andcommitted
selftests: gen_kselftest_tar.sh: Do not clobber kselftest/
The default installation location for gen_kselftest_tar.sh was still "kselftest/" which collides with the existing directory. Instead, this moves the installation target into "kselftest_install/kselftest/" and adjusts the tar creation accordingly. This also adjusts indentation and logic to be consistent. Fixes: 42d46e5 ("selftests: Extract single-test shell logic from lib.mk") Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 5b06eea commit ea1bf0b

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

tools/testing/selftests/gen_kselftest_tar.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,21 @@ main()
3838
esac
3939
fi
4040

41-
install_dir=./kselftest
41+
# Create working directory.
42+
dest=`pwd`
43+
install_work="$dest"/kselftest_install
44+
install_name=kselftest
45+
install_dir="$install_work"/"$install_name"
46+
mkdir -p "$install_dir"
4247

43-
# Run install using INSTALL_KSFT_PATH override to generate install
44-
# directory
45-
./kselftest_install.sh
46-
tar $copts kselftest${ext} $install_dir
47-
echo "Kselftest archive kselftest${ext} created!"
48+
# Run install using INSTALL_KSFT_PATH override to generate install
49+
# directory
50+
./kselftest_install.sh "$install_dir"
51+
(cd "$install_work"; tar $copts "$dest"/kselftest${ext} $install_name)
52+
echo "Kselftest archive kselftest${ext} created!"
4853

49-
# clean up install directory
50-
rm -rf kselftest
54+
# clean up top-level install work directory
55+
rm -rf "$install_work"
5156
}
5257

5358
main "$@"

tools/testing/selftests/kselftest_install.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@
66
# Author: Shuah Khan <[email protected]>
77
# Copyright (C) 2015 Samsung Electronics Co., Ltd.
88

9-
install_loc=`pwd`
10-
119
main()
1210
{
13-
if [ $(basename $install_loc) != "selftests" ]; then
11+
base_dir=`pwd`
12+
install_dir="$base_dir"/kselftest_install
13+
14+
# Make sure we're in the selftests top-level directory.
15+
if [ $(basename "$base_dir") != "selftests" ]; then
1416
echo "$0: Please run it in selftests directory ..."
1517
exit 1;
1618
fi
19+
20+
# Only allow installation into an existing location.
1721
if [ "$#" -eq 0 ]; then
18-
echo "$0: Installing in default location - $install_loc ..."
22+
echo "$0: Installing in default location - $install_dir ..."
1923
elif [ ! -d "$1" ]; then
2024
echo "$0: $1 doesn't exist!!"
2125
exit 1;
2226
else
23-
install_loc=$1
24-
echo "$0: Installing in specified location - $install_loc ..."
27+
install_dir="$1"
28+
echo "$0: Installing in specified location - $install_dir ..."
2529
fi
2630

27-
install_dir=$install_loc/kselftest_install
28-
29-
# Create install directory
30-
mkdir -p $install_dir
31-
# Build tests
32-
KSFT_INSTALL_PATH=$install_dir make install
31+
# Build tests
32+
KSFT_INSTALL_PATH="$install_dir" make install
3333
}
3434

3535
main "$@"

0 commit comments

Comments
 (0)