From 83adbde947752113eb62ed80ba19fb43ff875f4e Mon Sep 17 00:00:00 2001 From: George Danchev Date: Fri, 8 Jul 2011 14:18:54 +0000 Subject: [PATCH] completed transitioning, docs reflect that too --- libisoburn/trunk/releng/README.core | 20 +-- libisoburn/trunk/releng/releng_printsize | 167 +++++++++++--------- libisoburn/trunk/releng/run_all_releng | 50 ++++-- libisoburn/trunk/releng/template_new_releng | 2 + 4 files changed, 137 insertions(+), 102 deletions(-) diff --git a/libisoburn/trunk/releng/README.core b/libisoburn/trunk/releng/README.core index 5260a9c8..1c313900 100644 --- a/libisoburn/trunk/releng/README.core +++ b/libisoburn/trunk/releng/README.core @@ -6,24 +6,20 @@ Release Engineering Alternatively, use latest all-in-one development tarball from: http://www.gnu.org/software/xorriso/ -* SETUP THE TEST ENVIRONMENT - + Not all TESTs are scripts (e.g. cppcheck, valgrind) - + Copy all SCRIPT.conf.template to $HOME/.libburnia-releng/SCRIPT.conf - + Read the configuration files and set up accordingly to your needs +* SETUP THE TEST ENVIRONMENT AND RUN THE TEST SUITE + + All tests have to be run from the releng/ directory, within + libisoburn source tree. There is a 'master' script called + run_all_releng, which runs all scripts prefixed with releng_*. + + Any releng_* script can be run on its own, regardless. + + All scripts support -h, -help, --help and + print usage help when run without options. * DELIVERING A NEW TEST SCRIPT + Start a new test script over the top of template_new_releng + All filenames start with releng_ prefix + Self generated data are to be stored in ./releng_generated_data/scriptname/ directory - + Test data generation options -rc [-keep] - + Test data removal options -cleanup - + Well documented configuration file SCRIPT.conf.template + + Keep the newly added script options in sync with other scripts + Throw FAIL string to stdout if any failure is detected + Return exit code 0 on success, non-zero on failure + Use different exit codes for any failure (range 0-31) - -* RUNNING TESTS - + All tests have to be run from the releng/ directory, within - libisoburn source tree. Ther is a 'master' script called - run_all_releng, which runs all scripts prefixed with releng_*. diff --git a/libisoburn/trunk/releng/releng_printsize b/libisoburn/trunk/releng/releng_printsize index a6f35cc9..5f3e429f 100755 --- a/libisoburn/trunk/releng/releng_printsize +++ b/libisoburn/trunk/releng/releng_printsize @@ -2,90 +2,111 @@ set -e -START_DIR_DONT_CHANGE=`pwd` -SELF=$(basename "$0") -# required config items -RELENG_XORRISO="" -RELENG_GENISOIMAGE=/usr/bin/genisoimage -RELENG_MKISOFS=/usr/bin/mkisofs +# Include common bits +. inc/releng_getopts.inc -# config file -CONFFILE=${HOME}/.libburnia-releng/${SELF}.conf -GEN_DATA_DIR=releng_generated_data/${SELF} - -UPPER=40 -KEEP=0 - -##################################################################### -print_help() { - cat << HLP -Usage: - $0 -help - -# using a config file ${CONFFILE} - $0 -rc [-keep] - -# without using a config file - $0 xorriso_cmd - -# cleanup test generated data directory and exit - $0 -cleanup -HLP -} - -##################################################################### -# cleanup -if [ "${1}" == "-cleanup" ]; then - cd "${START_DIR_DONT_CHANGE}" || exit 2 - if [ -d "${GEN_DATA_DIR}" ]; then - rm -rf ${GEN_DATA_DIR} - printf "${SELF}: removed %s\n" ${GEN_DATA_DIR} - else - printf "${SELF}: ${GEN_DATA_DIR} does not exist.\n" - fi - exit 0 +# Each releng_ test should decide whether or not it need +# a xorriso binary to test, since some do compilations only. +if [ ! -x $RELENG_XORRISO ]; then + print_help + printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n" + exit 31 fi -# help -if [ ! "${1}" ]; then print_help && exit 3; fi -# config file -if [ "${1}" == "-rc" ]; then - if [ -e ${CONFFILE} ]; then - . ${CONFFILE} - printf "${SELF}: Using config file %s\n" ${CONFFILE} - else - echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 4 - fi - if [ "${2}" == "-keep" ]; then KEEP=1; fi -# command line args -elif [ "${1}" ]; then - RELENG_XORRISO="${1}" - if [ "${2}" == "-keep" ]; then KEEP=1; fi -# the rest -else - print_help && exit 5 -fi - -# data dir +# check data dir, if any and after checking -x xorriso if [ -d "${GEN_DATA_DIR}" ]; then printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR} - printf "\n${SELF}: use '${SELF} -cleanup' to remove.\n" - exit 6 + printf "\n${SELF}: use '${SELF} -c1' to remove.\n" + exit 8 else mkdir "${GEN_DATA_DIR}" fi -if [ "${RELENG_XORRISO}" == "" ]; then - echo -e "\n${SELF}: xorriso_cmd is required\n" - exit 7 -fi +#START_DIR_DONT_CHANGE=`pwd` +#SELF=$(basename "$0") +# required config items +#RELENG_XORRISO="" -if [ ! -x "${RELENG_XORRISO}" ]; then - printf "${SELF}: Not found or not an executable: $RELENG_XORRISO\n" - exit 8 -fi +RELENG_GENISOIMAGE=/usr/bin/genisoimage +RELENG_MKISOFS=/usr/bin/mkisofs -# all must be set at this point +# config file +# CONFFILE=${HOME}/.libburnia-releng/${SELF}.conf +# GEN_DATA_DIR=releng_generated_data/${SELF} + +UPPER=40 +# KEEP=0 + +##################################################################### +#print_help() { +# cat << HLP +#Usage: +# $0 -help + +# using a config file ${CONFFILE} +# $0 -rc [-keep] + +# without using a config file +# $0 xorriso_cmd + +# cleanup test generated data directory and exit +# $0 -cleanup +#HLP +#} + +##################################################################### +# cleanup +#if [ "${1}" == "-cleanup" ]; then +# cd "${START_DIR_DONT_CHANGE}" || exit 2 +# if [ -d "${GEN_DATA_DIR}" ]; then +# rm -rf ${GEN_DATA_DIR} +# printf "${SELF}: removed %s\n" ${GEN_DATA_DIR} +# else +# printf "${SELF}: ${GEN_DATA_DIR} does not exist.\n" +# fi +# exit 0 +#fi + +# help +#if [ ! "${1}" ]; then print_help && exit 3; fi +# config file +#if [ "${1}" == "-rc" ]; then +# if [ -e ${CONFFILE} ]; then +# . ${CONFFILE} +# printf "${SELF}: Using config file %s\n" ${CONFFILE} +# else +# echo -e "\n${SELF}: Config file ${CONFFILE} not found.\n" && exit 4 +# fi +# if [ "${2}" == "-keep" ]; then KEEP=1; fi +# command line args +#elif [ "${1}" ]; then +# RELENG_XORRISO="${1}" +# if [ "${2}" == "-keep" ]; then KEEP=1; fi +# the rest +#else +# print_help && exit 5 +#fi + +# data dir +#if [ -d "${GEN_DATA_DIR}" ]; then +# printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR} +# printf "\n${SELF}: use '${SELF} -cleanup' to remove.\n" +# exit 6 +#else +# mkdir "${GEN_DATA_DIR}" +#fi + +#if [ "${RELENG_XORRISO}" == "" ]; then +# echo -e "\n${SELF}: xorriso_cmd is required\n" +# exit 7 +# fi + +#if [ ! -x "${RELENG_XORRISO}" ]; then +# printf "${SELF}: Not found or not an executable: $RELENG_XORRISO\n" +# exit 8 +#fi + +# All must be set at this point printf "${SELF}: Config items:" printf "\n\txorriso_cmd=${RELENG_XORRISO}\n" diff --git a/libisoburn/trunk/releng/run_all_releng b/libisoburn/trunk/releng/run_all_releng index f6a12d4f..63de6a73 100755 --- a/libisoburn/trunk/releng/run_all_releng +++ b/libisoburn/trunk/releng/run_all_releng @@ -2,29 +2,39 @@ set -e +# It is not a good idea to include inc/releng_getopts.inc with the +# master script as it calls the subordinate scripts and they include +# this file too, and we want to avoid sharing variable with subshells + SELF=$(basename "$0") GEN_DATA_DIR=releng_generated_data CLOG=${GEN_DATA_DIR}/log.${SELF} +PASSED_OPTIONS="$@" +CLEANUP_LOG=0 -PASSED_OPTIONS="" +############################################# +while getopts “x:k:c:f:h” OPT +do + case $OPT in + c) + CLEANUP_LOG=1 + ;; + *) + ;; + esac +done -if [ "${1}" == "-cleanup" ]; then - PASSED_OPTIONS="-cleanup" -elif [ "${1}" == "-rc" -a "${2}" == "-keep" ]; then - PASSED_OPTIONS="-rc -keep" -elif [ "${1}" == "-rc" ]; then - PASSED_OPTIONS="-rc" -else +if [ ! "${1}" ]; then cat << HLP -${SELF} runs executables from CWD starting with releng_*. +${SELF} runs executables from CWD starting with releng_*, passing them its own options. stdout/stderr output stored in ${CLOG} - ${SELF} -rc [-keep] - ${SELF} -cleanup + ${SELF} -x path/to/xorriso [-k1] + ${SELF} -c1 HLP - exit 101 + exit 31 fi ######################################################## @@ -63,9 +73,16 @@ fi DEND=`date --utc` printf "\n${SELF}: Stopped at ${DEND}." - if [ "${1}" == "-cleanup" ]; then - if [ -f "${CLOG}" ]; then rm -f "${CLOG}"; fi - if [ -f "${CLOG}".prev ]; then rm -f "${CLOG}".prev; fi + if [ "${CLEANUP_LOG}" -eq 1 ]; then + if [ -f "${CLOG}" ]; then + printf "\n${SELF}: Removed my own log ${CLOG}." + rm -f "${CLOG}" + fi + if [ -f "${CLOG}".prev ]; then + printf "\n${SELF}: Removed my own log ${CLOG}.prev." + rm -f "${CLOG}".prev + fi + printf "\n" else E2=`date '+%s'` let ES="${E2} - ${E1}" @@ -110,6 +127,5 @@ fi fi fi - printf "\n" - + # Fin exit 0 diff --git a/libisoburn/trunk/releng/template_new_releng b/libisoburn/trunk/releng/template_new_releng index ea373f18..d901b72b 100755 --- a/libisoburn/trunk/releng/template_new_releng +++ b/libisoburn/trunk/releng/template_new_releng @@ -2,7 +2,9 @@ set -e +# Include common bits . inc/releng_getopts.inc + # Each releng_ test should decide whether or not it need # a xorriso binary to test, since some do compilations only. if [ ! -x $RELENG_XORRISO ]; then