Commit ea1bf0bb authored by Kees Cook's avatar Kees Cook Committed by Shuah Khan
Browse files

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: 42d46e57 ("selftests: Extract single-test shell logic from lib.mk")
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 5b06eeae
Loading
Loading
Loading
Loading
+13 −8
Original line number Original line Diff line number Diff line
@@ -38,16 +38,21 @@ main()
	esac
	esac
	fi
	fi


	install_dir=./kselftest
	# Create working directory.
	dest=`pwd`
	install_work="$dest"/kselftest_install
	install_name=kselftest
	install_dir="$install_work"/"$install_name"
	mkdir -p "$install_dir"


	# Run install using INSTALL_KSFT_PATH override to generate install
	# Run install using INSTALL_KSFT_PATH override to generate install
	# directory
	# directory
./kselftest_install.sh
	./kselftest_install.sh "$install_dir"
tar $copts kselftest${ext} $install_dir
	(cd "$install_work"; tar $copts "$dest"/kselftest${ext} $install_name)
	echo "Kselftest archive kselftest${ext} created!"
	echo "Kselftest archive kselftest${ext} created!"


# clean up install directory
	# clean up top-level install work directory
rm -rf kselftest
	rm -rf "$install_work"
}
}


main "$@"
main "$@"
+12 −12
Original line number Original line Diff line number Diff line
@@ -6,30 +6,30 @@
# Author: Shuah Khan <shuahkh@osg.samsung.com>
# Author: Shuah Khan <shuahkh@osg.samsung.com>
# Copyright (C) 2015 Samsung Electronics Co., Ltd.
# Copyright (C) 2015 Samsung Electronics Co., Ltd.


install_loc=`pwd`

main()
main()
{
{
	if [ $(basename $install_loc) !=  "selftests" ]; then
	base_dir=`pwd`
	install_dir="$base_dir"/kselftest_install

	# Make sure we're in the selftests top-level directory.
	if [ $(basename "$base_dir") !=  "selftests" ]; then
		echo "$0: Please run it in selftests directory ..."
		echo "$0: Please run it in selftests directory ..."
		exit 1;
		exit 1;
	fi
	fi

	# Only allow installation into an existing location.
	if [ "$#" -eq 0 ]; then
	if [ "$#" -eq 0 ]; then
		echo "$0: Installing in default location - $install_loc ..."
		echo "$0: Installing in default location - $install_dir ..."
	elif [ ! -d "$1" ]; then
	elif [ ! -d "$1" ]; then
		echo "$0: $1 doesn't exist!!"
		echo "$0: $1 doesn't exist!!"
		exit 1;
		exit 1;
	else
	else
		install_loc=$1
		install_dir="$1"
		echo "$0: Installing in specified location - $install_loc ..."
		echo "$0: Installing in specified location - $install_dir ..."
	fi
	fi


	install_dir=$install_loc/kselftest_install

# Create install directory
	mkdir -p $install_dir
	# Build tests
	# Build tests
	KSFT_INSTALL_PATH=$install_dir make install
	KSFT_INSTALL_PATH="$install_dir" make install
}
}


main "$@"
main "$@"