more unification
This commit is contained in:
parent
1466254129
commit
8cfd6308bb
@ -2,18 +2,43 @@ SELF=$(basename $0)
|
|||||||
RELENG_XORRISO=0
|
RELENG_XORRISO=0
|
||||||
KEEP=0
|
KEEP=0
|
||||||
SIMULATE_FAILURE=0
|
SIMULATE_FAILURE=0
|
||||||
|
CLEANUP=1
|
||||||
|
|
||||||
usage() {
|
START_DIR_DONT_CHANGE=`pwd`
|
||||||
|
GEN_DATA_DIR=releng_generated_data/${SELF}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
print_help() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
|
||||||
Usage: $SELF -x path/to/xorriso [-k0|1] [-f0|1] [-h]
|
Usage: $SELF -x path/to/xorriso [-k0|1] [-f0|1] [-h]
|
||||||
-x absolute or relative path to binary to be run.
|
-x absolute or relative path to binary to be run.
|
||||||
-k keep selfgenerated data, values 0,1 default 0.
|
-k keep selfgenerated data (values 0,1, default 0).
|
||||||
-f simulate failure, values 0,1 default 0.
|
-c cleanup selfgenerated data kept from previous
|
||||||
|
run and exit (values 0,1, default 0).
|
||||||
|
-f simulate failure (values 0,1, default 0).
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts “x:k:f:h” OPTION
|
#############################################
|
||||||
|
cleanup() {
|
||||||
|
if [ ${KEEP} -eq 0 -a ${CLEANUP} -eq 1 ]; then
|
||||||
|
# safety net, just in case -> we want to be in the starting
|
||||||
|
# directory before removing whatever self-generated stuff
|
||||||
|
if [ -d "${GEN_DATA_DIR}" ]; then
|
||||||
|
cd "${START_DIR_DONT_CHANGE}" || exit 2
|
||||||
|
rm -rf ${GEN_DATA_DIR}
|
||||||
|
printf "${SELF}: Removed (self-generated) %s\n" ${GEN_DATA_DIR}
|
||||||
|
else
|
||||||
|
printf "${SELF}: ${GEN_DATA_DIR} does not exist. Nothing to clean.\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "${SELF}: Leaving (self-generated) %s\n" ${GEN_DATA_DIR}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#############################################
|
||||||
|
while getopts “x:k:c:f:h” OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
x)
|
x)
|
||||||
@ -22,34 +47,46 @@ do
|
|||||||
k)
|
k)
|
||||||
KEEP=$OPTARG
|
KEEP=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
c)
|
||||||
|
CLEANUP=$OPTARG
|
||||||
|
cleanup
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
f)
|
f)
|
||||||
SIMULATE_FAILURE=$OPTARG
|
SIMULATE_FAILURE=$OPTARG
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
usage
|
print_help
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
usage
|
print_help
|
||||||
exit 31
|
exit 31
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! -x $RELENG_XORRISO ]; then
|
# Each releng_ test should decide whether or not to check that
|
||||||
usage
|
#if [ ! -x $RELENG_XORRISO ]; then
|
||||||
printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n"
|
# print_help
|
||||||
|
# printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n"
|
||||||
|
# exit 31
|
||||||
|
#fi
|
||||||
|
|
||||||
|
if [ x"$KEEP" != x"0" -a x"$KEEP" != x"1" ]; then
|
||||||
|
print_help
|
||||||
|
printf "\n${SELF}: -k keep selfgenerated data.\n\n"
|
||||||
exit 31
|
exit 31
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ x"$KEEP" != x"0" -a x"$KEEP" != x"1" ]; then
|
if [ x"$CLEANUP" != x"0" -a x"$CLEANUP" != x"1" ]; then
|
||||||
usage
|
print_help
|
||||||
printf "\n${SELF}: -k keep selfgenerated data, values 0,1 default 0.\n\n"
|
printf "\n${SELF}: -c cleanup selfgenerated data kept from previous run.\n\n"
|
||||||
exit 31
|
exit 31
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ x"$SIMULATE_FAILURE" != x"0" -a x"$SIMULATE_FAILURE" != x"1" ]; then
|
if [ x"$SIMULATE_FAILURE" != x"0" -a x"$SIMULATE_FAILURE" != x"1" ]; then
|
||||||
usage
|
print_help
|
||||||
printf "\n${SELF}: -f simulate failure, values 0,1 default 0.\n\n"
|
printf "\n${SELF}: -f simulate failure.\n\n"
|
||||||
exit 31
|
exit 31
|
||||||
fi
|
fi
|
||||||
|
@ -6,6 +6,7 @@ set -e
|
|||||||
|
|
||||||
printf "\nRELENG_XORRISO =${RELENG_XORRISO}"
|
printf "\nRELENG_XORRISO =${RELENG_XORRISO}"
|
||||||
printf "\nKEEP =${KEEP}"
|
printf "\nKEEP =${KEEP}"
|
||||||
|
printf "\nCLEANUP =${CLEANUP}"
|
||||||
printf "\nSIMULATE_FAILURE =${SIMULATE_FAILURE}"
|
printf "\nSIMULATE_FAILURE =${SIMULATE_FAILURE}"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
|
||||||
|
@ -2,68 +2,17 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
START_DIR_DONT_CHANGE=`pwd`
|
. inc/releng_getopts.inc
|
||||||
SELF=$(basename "$0")
|
|
||||||
GEN_DATA_DIR=releng_generated_data/${SELF}
|
# xorriso binary is not needed for that particular test
|
||||||
KEEP=0
|
|
||||||
SAMPLE_CODE_DIR=codesamples
|
SAMPLE_CODE_DIR=codesamples
|
||||||
CC=g++
|
CC=g++
|
||||||
|
|
||||||
#####################################################################
|
|
||||||
print_help() {
|
|
||||||
cat << HLP
|
|
||||||
Usage:
|
|
||||||
$0 -help
|
|
||||||
|
|
||||||
#
|
|
||||||
$0 -rc [-keep]
|
|
||||||
|
|
||||||
# cleanup test generated data directory and exit
|
|
||||||
$0 -cleanup
|
|
||||||
HLP
|
|
||||||
}
|
|
||||||
|
|
||||||
#####################################################################
|
|
||||||
cleanup() {
|
|
||||||
if [ ${KEEP} -eq 0 ]; then
|
|
||||||
# safety net, just in case -> we want to be in the starting
|
|
||||||
# directory before removing whatever self-generated stuff
|
|
||||||
if [ -d "${GEN_DATA_DIR}" ]; then
|
|
||||||
cd "${START_DIR_DONT_CHANGE}" || exit 2
|
|
||||||
rm -rf ${GEN_DATA_DIR}
|
|
||||||
printf "${SELF}: Removed (self-generated) %s\n" ${GEN_DATA_DIR}
|
|
||||||
else
|
|
||||||
printf "${SELF}: ${GEN_DATA_DIR} does not exist. Nothing to clean.\n"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
printf "${SELF}: Leaving (self-generated) %s\n" ${GEN_DATA_DIR}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#####################################################################
|
|
||||||
# help
|
|
||||||
if [ ! "${1}" ]; then
|
|
||||||
print_help && exit 3
|
|
||||||
#
|
|
||||||
elif [ "${1}" == "-cleanup" ]; then
|
|
||||||
cleanup
|
|
||||||
exit 0
|
|
||||||
#
|
|
||||||
elif [ "${1}" == "-rc" -a "${2}" == "-keep" ]; then
|
|
||||||
KEEP=1
|
|
||||||
elif [ "${1}" == "-rc" -a ! "${2}" ]; then
|
|
||||||
KEEP=0
|
|
||||||
# the rest
|
|
||||||
else
|
|
||||||
print_help && exit 4
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#####################################################################
|
|
||||||
# check data dir
|
# check data dir
|
||||||
if [ -d "${GEN_DATA_DIR}" ]; then
|
if [ -d "${GEN_DATA_DIR}" ]; then
|
||||||
printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
|
printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
|
||||||
printf "\n${SELF}: use '${SELF} -cleanup' to remove.\n"
|
printf "\n${SELF}: use '${SELF} -c1' to remove.\n"
|
||||||
exit 5
|
exit 5
|
||||||
else
|
else
|
||||||
mkdir "${GEN_DATA_DIR}"
|
mkdir "${GEN_DATA_DIR}"
|
||||||
|
@ -2,46 +2,19 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
START_DIR_DONT_CHANGE=`pwd`
|
. inc/releng_getopts.inc
|
||||||
SELF=$(basename "$0")
|
# Each releng_ test should decide whether or not it need
|
||||||
# required config items
|
# a xorriso binary to test, since some do compilations only.
|
||||||
# RELENG_XORRISO=""
|
if [ ! -x $RELENG_XORRISO ]; then
|
||||||
|
print_help
|
||||||
# optional config items
|
printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n"
|
||||||
|
exit 31
|
||||||
# config file
|
fi
|
||||||
CONFFILE=${HOME}/.libburnia-releng/${SELF}.conf
|
|
||||||
GEN_DATA_DIR=releng_generated_data/${SELF}
|
|
||||||
KEEP=0
|
|
||||||
|
|
||||||
printf "\n$0: FAIL: === TEPLATE === RENAME ME TO releng_<title>\n"
|
printf "\n$0: FAIL: === TEPLATE === RENAME ME TO releng_<title>\n"
|
||||||
exit 31
|
exit 31
|
||||||
|
|
||||||
#####################################################################
|
|
||||||
print_help() {
|
|
||||||
cat << HLP
|
|
||||||
Usage:
|
|
||||||
$0 -help
|
|
||||||
|
|
||||||
# using a config file ${CONFFILE}
|
|
||||||
$0 -rc [-keep]
|
|
||||||
|
|
||||||
# without using a config file
|
|
||||||
$0 your_own_options_here
|
|
||||||
|
|
||||||
# cleanup test generated data directory and exit
|
|
||||||
$0 -cleanup
|
|
||||||
HLP
|
|
||||||
}
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
print_help
|
print_help
|
||||||
#if [ ! -x "${XOR}" ]; then
|
|
||||||
# printf "$0: Not found or not an executable: $XOR\n"
|
|
||||||
# exit 50
|
|
||||||
#fi
|
|
||||||
|
|
||||||
# xorriso version details, incl. underlying libraries
|
|
||||||
# "${XOR}" -version
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user