121979405SShuah Khan#!/bin/bash
24b461dc2SShuah Khan# SPDX-License-Identifier: GPL-2.0
321979405SShuah Khan#
421979405SShuah Khan# Kselftest Install
521979405SShuah Khan# Install kselftest tests
621979405SShuah Khan# Author: Shuah Khan <shuahkh@osg.samsung.com>
721979405SShuah Khan# Copyright (C) 2015 Samsung Electronics Co., Ltd.
821979405SShuah Khan
921979405SShuah Khanmain()
1021979405SShuah Khan{
11ea1bf0bbSKees Cook	base_dir=`pwd`
12ea1bf0bbSKees Cook	install_dir="$base_dir"/kselftest_install
13ea1bf0bbSKees Cook
14ea1bf0bbSKees Cook	# Make sure we're in the selftests top-level directory.
15ea1bf0bbSKees Cook	if [ $(basename "$base_dir") !=  "selftests" ]; then
1621979405SShuah Khan		echo "$0: Please run it in selftests directory ..."
1721979405SShuah Khan		exit 1;
1821979405SShuah Khan	fi
19ea1bf0bbSKees Cook
20ea1bf0bbSKees Cook	# Only allow installation into an existing location.
2121979405SShuah Khan	if [ "$#" -eq 0 ]; then
22ea1bf0bbSKees Cook		echo "$0: Installing in default location - $install_dir ..."
2321979405SShuah Khan	elif [ ! -d "$1" ]; then
2421979405SShuah Khan		echo "$0: $1 doesn't exist!!"
2521979405SShuah Khan		exit 1;
2621979405SShuah Khan	else
27ea1bf0bbSKees Cook		install_dir="$1"
28ea1bf0bbSKees Cook		echo "$0: Installing in specified location - $install_dir ..."
2921979405SShuah Khan	fi
3021979405SShuah Khan
3121979405SShuah Khan	# Build tests
32ea1bf0bbSKees Cook	KSFT_INSTALL_PATH="$install_dir" make install
3321979405SShuah Khan}
3421979405SShuah Khan
3521979405SShuah Khanmain "$@"
36