merge back enhancements from Thomas
This commit is contained in:
@ -1,21 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2011 George Danchev <danchev@spnet.net>
|
||||
# Licensed under GNU GPL version 2
|
||||
# Copyright 2011 Thomas Schmitt <scdbackup@gmx.net>
|
||||
# Licensed under GNU GPL version 2 or later
|
||||
|
||||
# set -e
|
||||
|
||||
not_in_releng_exit() {
|
||||
printf "\nPlease execute the tests from releng directory.\n\n"
|
||||
exit 1
|
||||
print_specific_help() {
|
||||
# Print own help text
|
||||
echo "Test specific options:"
|
||||
echo " --dev path Suppress dialog and use path as drive address."
|
||||
echo "This test insists in getting a path to xorriso by option -x."
|
||||
echo
|
||||
}
|
||||
|
||||
# Include common bits
|
||||
. inc/releng_getopts.inc || not_in_releng_exit
|
||||
# Include common bits and interpret general options
|
||||
getopts_ts=1
|
||||
if test "$getopts_ts" = 1
|
||||
then
|
||||
getopts_inc=inc/releng_getopts_ts.inc
|
||||
else
|
||||
getopts_inc=inc/releng_getopts.inc
|
||||
fi
|
||||
if test -e "$getopts_inc"
|
||||
then
|
||||
. "$getopts_inc"
|
||||
|
||||
# Each releng_ test should decide whether or not it needs
|
||||
# a xorriso binary to test, since some do compilations only.
|
||||
if [ ! -x $RELENG_XORRISO ]; then
|
||||
if test "$RELENG_PRINTED_HELP" = 1
|
||||
then
|
||||
print_specific_help
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
echo >&2
|
||||
echo "File not found: $getopts_inc" >&2
|
||||
echo "Are we in the ./releng directory of a libisoburn SVN checkout ?" >&2
|
||||
echo "(Please execute the tests from that ./releng directory.)" >&2
|
||||
echo >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Interpret private options, they begin after the first --.
|
||||
dev=
|
||||
next_is=ignore
|
||||
for i in "$@"
|
||||
do
|
||||
if test "$next_is" = "ignore"
|
||||
then
|
||||
if test "$i" = "--"
|
||||
then
|
||||
next_is=""
|
||||
fi
|
||||
elif test "$next_is" = "dev"
|
||||
then
|
||||
dev="$i"
|
||||
next_is=""
|
||||
elif test "$i" = "--dev"
|
||||
then
|
||||
next_is="dev"
|
||||
else
|
||||
echo >&2
|
||||
echo "Unknown test specific option: $i" >&2
|
||||
print_help
|
||||
print_specific_help
|
||||
exit 31
|
||||
fi
|
||||
done
|
||||
|
||||
# Insist in having a xorriso
|
||||
if [ ! -x "$RELENG_XORRISO" ]; then
|
||||
print_help
|
||||
printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n"
|
||||
exit 31
|
||||
@ -23,60 +76,101 @@ fi
|
||||
|
||||
#
|
||||
get_speeds() {
|
||||
echo -e "\n${SELF}: Running: ${RELENG_XORRISO} -outdev ${1} -list_speeds"
|
||||
${RELENG_XORRISO} -outdev ${1} -list_speeds
|
||||
RET_SPEEDS="$?"
|
||||
case ${RET_SPEEDS} in
|
||||
0)
|
||||
;;
|
||||
*)
|
||||
boldify
|
||||
echo -e "\n${SELF}: ${RELENG_XORRISO} -outdev ${1} -list_speeds returned ${RET_SPEEDS}."
|
||||
unboldify
|
||||
;;
|
||||
esac
|
||||
echo -e "\n${SELF}: Running: ${RELENG_XORRISO} -report_about WARNING -outdev ${1} -toc -list_formats -list_profiles out -list_speeds"
|
||||
"$RELENG_XORRISO" -report_about WARNING -outdev "$1" \
|
||||
-print '---toc :' -toc \
|
||||
-print '---list_formats :' -list_formats \
|
||||
-print '---list_profiles :' -list_profiles out \
|
||||
-print '---list_speeds :' -list_speeds
|
||||
}
|
||||
|
||||
cat_var() {
|
||||
# $1 = variable to put out with line feeds
|
||||
cat <<+
|
||||
$1
|
||||
+
|
||||
}
|
||||
|
||||
get_devices() {
|
||||
echo -e "\n${SELF}: Running: $RELENG_XORRISO -devices 2>/dev/null | grep \"\-dev\""
|
||||
DEVICES=`$RELENG_XORRISO -devices 2>/dev/null | grep "\-dev"`
|
||||
NUM_DEV=`(cat <<+
|
||||
${DEVICES}
|
||||
+
|
||||
) | wc -l`
|
||||
# $1 = if not empty: device lines from xorriso -devices
|
||||
# $2 = if not empty: suppress dialog and use $2 as input
|
||||
|
||||
if test -n "$1"
|
||||
then
|
||||
DEVICES="$1"
|
||||
else
|
||||
DEVICES=$("$RELENG_XORRISO" -devices 2>/dev/null | grep "\-dev")
|
||||
fi
|
||||
NUM_DEV=$(cat_var "$DEVICES" | wc -l)
|
||||
case "${NUM_DEV}" in
|
||||
0)
|
||||
echo -e "${SELF}: No drives found."
|
||||
echo -e "\n${SELF}: No drives found."
|
||||
exit 1
|
||||
;;
|
||||
1)
|
||||
echo -e "${SELF}: Single drive found:\n${DEVICES}"
|
||||
OUTDEV=`${RELENG_XORRISO} -devices 2>/dev/null | perl -pe "s#^\d+\s+\-dev\s+\'## and s#\'.*##"`
|
||||
get_speeds ${OUTDEV}
|
||||
echo -e "\n${SELF}: 1 drive found:\n"
|
||||
;;
|
||||
*)
|
||||
echo -e "${SELF}: Multiple drives found. NOT FINISHED YET."
|
||||
exit 2
|
||||
echo -e "\n${SELF}: ${NUM_DEV} drives found:\n"
|
||||
;;
|
||||
esac
|
||||
echo =================================================================
|
||||
echo "$DEVICES"
|
||||
echo =================================================================
|
||||
|
||||
OUTDEV=$( cat_var "$DEVICES" | head -1 | \
|
||||
sed -e "s/[0-9] *-dev '\//\//" -e "s/'.*$//" )
|
||||
if test -n "$2"
|
||||
then
|
||||
x="$2"
|
||||
else
|
||||
echo >&2
|
||||
echo "WARNING: The following tests might pull in the drive tray." >&2
|
||||
echo " Best is if you now put in a suitable media and" >&2
|
||||
echo " load it manually, so nobody gets surprised. :))" >&2
|
||||
echo >&2
|
||||
echo "Which drive to examine ? (Empty input = ${OUTDEV})" >&2
|
||||
read x
|
||||
fi
|
||||
if test -n "$x"
|
||||
then
|
||||
OUTDEV="$x"
|
||||
fi
|
||||
|
||||
get_speeds "$OUTDEV"
|
||||
}
|
||||
|
||||
# main
|
||||
"$RELENG_XORRISO" -version
|
||||
echo -e "\n${SELF}: Running: $RELENG_XORRISO -devices..."
|
||||
$RELENG_XORRISO -devices
|
||||
RET_DEVICES="$?"
|
||||
case ${RET_DEVICES} in
|
||||
devices=$("$RELENG_XORRISO" -report_about WARNING -devices | grep "\-dev")
|
||||
RET="$?"
|
||||
if test "$SIMULATE_FAILURE" = 1
|
||||
then
|
||||
echo "===" >&2
|
||||
echo "=== SIMULATING FAILURE BY OVERRIDING EXIT VALUE OF XORRISO" >&2
|
||||
echo "===" >&2
|
||||
echo "FAIL : ${SELF} : Simulated failure caused by option -f"
|
||||
RET=1
|
||||
fi
|
||||
case ${RET} in
|
||||
0)
|
||||
get_devices
|
||||
;;
|
||||
get_devices "$devices" "$dev"
|
||||
RET="$?"
|
||||
if test "$RET" = 0
|
||||
then
|
||||
dummy=dummy
|
||||
else
|
||||
echo "FAIL : ${SELF} : Device scan or single drive listing failed"
|
||||
exit "$RET"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
boldify
|
||||
echo -ne "\n${SELF}: ${RELENG_XORRISO} -devices returned ${RET_DEVICES}."
|
||||
unboldify
|
||||
echo -e "\n${SELF}: Already mounted?"
|
||||
df -kh
|
||||
;;
|
||||
boldify
|
||||
echo -ne "\n${SELF}: ${RELENG_XORRISO} -devices returned ${RET}."
|
||||
unboldify
|
||||
echo -e "\n${SELF}: Already mounted?"
|
||||
df -kh
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user