119 lines
2.7 KiB
Bash
119 lines
2.7 KiB
Bash
#!/bin/bash
|
|
|
|
# Created by argbash-init v2.10.0
|
|
# ARG_OPTIONAL_SINGLE([old],[],[old librtas DSO],[/lib64/librtas.so.2])
|
|
# ARG_OPTIONAL_SINGLE([new],[],[new librtas DSO],[$PWD/.libs/librtas.so.2])
|
|
# ARG_HELP([Test the activate_firmware command against a development build of librtas])
|
|
# ARGBASH_GO()
|
|
# needed because of Argbash --> m4_ignore([
|
|
### START OF CODE GENERATED BY Argbash v2.10.0 one line above ###
|
|
# Argbash is a bash code generator used to get arguments parsing right.
|
|
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
|
|
|
|
|
|
die()
|
|
{
|
|
local _ret="${2:-1}"
|
|
test "${_PRINT_HELP:-no}" = yes && print_help >&2
|
|
echo "$1" >&2
|
|
exit "${_ret}"
|
|
}
|
|
|
|
|
|
begins_with_short_option()
|
|
{
|
|
local first_option all_short_options='h'
|
|
first_option="${1:0:1}"
|
|
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
|
|
}
|
|
|
|
# THE DEFAULTS INITIALIZATION - OPTIONALS
|
|
_arg_old="/lib64/librtas.so.2"
|
|
_arg_new="$PWD/.libs/librtas.so.2"
|
|
|
|
|
|
print_help()
|
|
{
|
|
printf '%s\n' "Test the activate_firmware command against a development build of librtas"
|
|
printf 'Usage: %s [--old <arg>] [--new <arg>] [-h|--help]\n' "$0"
|
|
printf '\t%s\n' "--old: old librtas DSO (default: '/lib64/librtas.so.2')"
|
|
printf '\t%s\n' "--new: new librtas DSO (default: '$PWD/.libs/librtas.so.2')"
|
|
printf '\t%s\n' "-h, --help: Prints help"
|
|
}
|
|
|
|
|
|
parse_commandline()
|
|
{
|
|
while test $# -gt 0
|
|
do
|
|
_key="$1"
|
|
case "$_key" in
|
|
--old)
|
|
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
|
|
_arg_old="$2"
|
|
shift
|
|
;;
|
|
--old=*)
|
|
_arg_old="${_key##--old=}"
|
|
;;
|
|
--new)
|
|
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
|
|
_arg_new="$2"
|
|
shift
|
|
;;
|
|
--new=*)
|
|
_arg_new="${_key##--new=}"
|
|
;;
|
|
-h|--help)
|
|
print_help
|
|
exit 0
|
|
;;
|
|
-h*)
|
|
print_help
|
|
exit 0
|
|
;;
|
|
*)
|
|
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
}
|
|
|
|
parse_commandline "$@"
|
|
|
|
# OTHER STUFF GENERATED BY Argbash
|
|
|
|
### END OF CODE GENERATED BY Argbash (sortof) ### ])
|
|
# [ <-- needed because of Argbash
|
|
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
workdir="$(mktemp -d)"
|
|
|
|
uak_old="${workdir}/uak.old"
|
|
uak_new="${workdir}/uak.new"
|
|
|
|
preload_sanitizers=/lib64/libasan.so.8:/lib64/libubsan.so.1
|
|
|
|
export LD_PRELOAD="${preload_sanitizers}":"$_arg_old"
|
|
activate_firmware -e > "$uak_old"
|
|
|
|
export LD_PRELOAD="${preload_sanitizers}":"$_arg_new"
|
|
activate_firmware -e > "$uak_new"
|
|
|
|
export -n LSAN_OPTIONS ASAN_OPTIONS LD_PRELOAD
|
|
|
|
cmp "$uak_old" "$uak_new" || {
|
|
echo "error: Update Access Key information differs"
|
|
diff -u "$uak_old" "$uak_new"
|
|
exit 1
|
|
}
|
|
|
|
echo "Tested $(type -P activate_firmware) with ${_arg_old} and ${_arg_new}, no differences detected."
|
|
|
|
test -d "$workdir" && rm -fr "$workdir"
|
|
|
|
# ] <-- needed because of Argbash
|