This is pending review.

On Fri, Dec 6, 2013 at 4:00 PM, Jose A. Lopes <[email protected]> wrote:

> Add script that creates distribution tarballs with different configure
> options and tests the integrity of these tarballs.  The script checks
> whether a given set of expected files are in the tarball, including
> source files and documentation.  The script also tests whether
> different configure options create tarballs with the same set of
> files.  Given that it takes too much time to test all configuration
> options, a number of configure options are selected randomly and
> tested.  These options are extracted directly from 'configure --help'.
>
> The script starts with a clean checkout and lists the files in the
> 'doc', 'lib', and 'src' directories.  These are the expected files and
> all distribution tarballs must contain these.
>
> The script also generates a distribution tarball using only the
> standard configure options.  The files contained within this tarball
> are used as a basis to check the distribution tarballs created with
> the different configure options.
>
> TODO
>
>   Integrate with buildbot: the script probably needs to be changed in
>   order to integrate with buildbot, for example, proper exit code
>   status or logging has to be done differently
>
> Feedback is highly appreciated.
>
> Signed-off-by: Jose A. Lopes <[email protected]>
> ---
>  devel/test-dists | 298
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 298 insertions(+)
>  create mode 100755 devel/test-dists
>
> diff --git a/devel/test-dists b/devel/test-dists
> new file mode 100755
> index 0000000..80c0793
> --- /dev/null
> +++ b/devel/test-dists
> @@ -0,0 +1,298 @@
> +#!/bin/bash
> +
> +# Argument to the script with be given directly to 'make'
> +#
> +# Example:
> +#  ./test-dists -j8
> +ARGS="$@"
> +
> +set -e
> +
> +if [[ ! -f ./INSTALL ]]
> +then
> +    echo This script must be run from the top-level directory >&2
> +    exit 1
> +fi
> +
> +function formatLogFile {
> +    local name=$1
> +    eval $2="ganeti-${name}.log"
> +}
> +
> +function formatDistDir {
> +    local name=$1
> +    eval $2="ganeti-${name}"
> +}
> +
> +function formatDistFile {
> +    local name=$1
> +    eval $2="ganeti-${name}.tar.gz"
> +}
> +
> +function formatExpectedFile {
> +    local name=$1
> +    eval $2="ganeti-${name}.lst"
> +}
> +
> +docDir="doc"
> +libDir="lib"
> +srcDir="src"
> +
> +# writeExpectedFile file
> +#
> +# Writes into 'file' the list of files that are expected to be
> +# contained in a distribution tarball.  These include documentation
> +# and source files both from Haskell and Python.
> +function writeExpectedFile {
> +    local file=$1
> +
> +    find $docDir -type f -iname "*.rst"                     | sort  >
> $file
> +    find $libDir -type f -iname "*.py" -or -iname "*.py.in" | sort >>
> $file
> +    find $srcDir -type f -iname "*.hs" -or -iname "*.hs.in" | sort >>
> $file
> +}
> +
> +# Performs a distclean whether there is a 'Makefile' present or not.
> +function makeClean {
> +    local name=$1
> +
> +    local logFile
> +    formatLogFile $name logFile
> +
> +    if [[ -f Makefile ]]
> +    then
> +       echo [$name] make distclean
> +       echo make distclean >> $logFile
> +       make distclean 2>&1 | sed -e "s/^/  /g" >> $logFile
> +    else
> +       echo [$name] ./autogen.sh
> +       echo ./autogen.sh                >> $logFile
> +       ./autogen.sh | sed -e "s/^/  /g" >> $logFile
> +
> +       echo [$name] ./configure
> +       echo ./configure                >> $logFile
> +       ./configure | sed -e "s/^/  /g" >> $logFile
> +
> +       echo [$name] make distclean
> +       echo make distclean                     >> $logFile
> +       make distclean 2>&1 | sed -e "s/^/  /g" >> $logFile
> +    fi
> +}
> +
> +function runAutogen {
> +    local name=$1
> +
> +    local logFile
> +    formatLogFile $name logFile
> +
> +    echo [$name] ./autogen.sh
> +    echo ./autogen.sh                     >> $logFile
> +    ./autogen.sh 2>&1 | sed -e "s/^/  /g" >> $logFile
> +}
> +
> +function runConfigure {
> +    local name=$1
> +    local args=$2
> +
> +    local logFile
> +    formatLogFile $name logFile
> +
> +    echo [$name] ./configure ... "$args"
> +    echo ./configure PYTHON=python2.6 --prefix=/usr --sysconfdir=/etc \
> +       --localstatedir=/var --with-user-prefix=gnt-
> --with-group-prefix=gnt- \
> +       --enable-symlinks "$args" >> $logFile
> +
> +    ./configure PYTHON=python2.6 --prefix=/usr --sysconfdir=/etc \
> +       --localstatedir=/var --with-user-prefix=gnt-
> --with-group-prefix=gnt- \
> +       --enable-symlinks "$args" 2>&1 | sed -e "s/^/  /g" >> $logFile
> +}
> +
> +function makeDist {
> +    local name=$1
> +
> +    local logFile
> +    formatLogFile $name logFile
> +
> +    local distDir
> +    formatDistDir $name distDir
> +
> +    echo [$name] make dist "(this will take a while)"
> +    echo make distdir=$distDir $ARGS dist                     >> $logFile
> +    make distdir=$distDir $ARGS dist 2>&1 | sed -e "s/^/  /g" >> $logFile
> +}
> +
> +function genDist {
> +    local name=$1
> +    local args=$2
> +
> +    makeClean $name
> +    runAutogen $name
> +    runConfigure $name "$args"
> +    makeDist $name
> +}
> +
> +function genListFile {
> +    local distFile=$1
> +    local listFile=$2
> +
> +    if [[ -z $distFile ]]
> +    then
> +       echo error: genListFile: distFile is empty >&2
> +       exit 1
> +    fi
> +
> +    if [[ -z $listFile ]]
> +    then
> +       echo error: genListFile: listFile is empty >&2
> +       exit 1
> +    fi
> +
> +    tar -tf $distFile | cut -d "/" -f 2- | sort > $listFile
> +}
> +
> +NORMAL_LIST_FILE=
> +
> +# checkNormal
> +#
> +# Builds a distribution tarball with the standard configure options
> +# and checks whether this distribution contains the set of expected
> +# files.  The list of files contained in the 'normal' distribution is
> +# used to check against the distribution tarballs built using
> +# different configure parameters.
> +function checkNormal {
> +    local name=normal
> +
> +    local logFile
> +    formatLogFile $name logFile
> +    echo "Profile $name" > $logFile
> +
> +    makeClean expected
> +
> +    local expectedFile
> +    formatExpectedFile expected expectedFile
> +
> +    writeExpectedFile $expectedFile
> +
> +    genDist $name ""
> +
> +    local distFile
> +    formatDistFile $name distFile
> +
> +    local listFile=ganeti-${name}.lst
> +    genListFile $distFile $listFile
> +
> +    echo comm -23 $expectedFile $listFile >> $logFile
> +    local diffOutput=$(comm -23 $expectedFile $listFile)
> +
> +    if [[ -n $diffOutput ]]
> +    then
> +       echo [$name] ERROR: files missing from distribution tarball:
> +       echo -e "$diffOutput"
> +
> +       echo ERROR: files missing from distribution tarball: >> $logFile
> +       echo -e "$diffOutput" 2>&1 | sed -e "s/^/  /g"       >> $logFile
> +
> +       exit 1
> +    fi
> +
> +    NORMAL_LIST_FILE=$listFile
> +}
> +
> +# check profile args
> +#
> +# Builds a distribution tarball with the given profile name and
> +# configure args, and checks whether this distribution contains the
> +# same set of files as the 'normal' distribution.
> +function check {
> +    local name=$1
> +    local args=$2
> +    local expectedFile=$NORMAL_LIST_FILE
> +
> +    local logFile
> +    formatLogFile $name logFile
> +    echo "Profile $name" > $logFile
> +
> +    genDist $name "$args"
> +
> +    local distFile
> +    formatDistFile $name distFile
> +
> +    local listFile=ganeti-${name}.lst
> +    genListFile $distFile $listFile
> +
> +    echo diff $expectedFile $listFile >> $logFile
> +
> +    if ! diff $expectedFile $listFile >> $logFile
> +    then
> +       echo [$name] ERROR: distribution tarball files differ
> +       exit 1
> +    fi
> +}
> +
> +checkNormal
> +
> +OPTS_NUM=3
> +ENABLE_OPTS_NUM=$OPTS_NUM
> +WITH_OPTS_NUM=$OPTS_NUM
> +
> +./autogen.hs
> +
> +# Extract the enable/disable configure options and select
> +# $ENABLE_OPTS_NUM random options, but never select
> +# 'disable-option-checking' 'disable-FEATURE' or 'enable-FEATURE'
> +ENABLE_OPTS=$(./configure --help | \
> +    sed -n -e "/Optional Features/,/^\$/ p" | \
> +    cut -d " " -f 3 | \
> +    sed "/^\$/d" | \
> +    grep -v -e disable-option-checking -e disable-FEATURE -e
> enable-FEATURE | \
> +    sort -R | \
> +    head -n $ENABLE_OPTS_NUM)
> +
> +for flag in $ENABLE_OPTS
> +do
> +    name=$(echo $flag | cut -d "-" -f 3-)
> +    check $name $flag
> +done
> +
> +
> +# Extract the '--with-...' configure options and select $WITH_OPTS_NUM
> +# random options, but never select 'with-PACKAGE' or
> +# 'without-PACKAGE'.
> +WITH_OPTS=$(./configure --help | \
> +    sed -n -e "/Optional Packages/,/^\$/ p" | \
> +    cut -d " " -f 3 | \
> +    sed "/^\$/d" | \
> +    grep -v -e with-PACKAGE -e without-PACKAGE | \
> +    sort -R | \
> +    head -n $WITH_OPTS_NUM)
> +
> +# Given that '--with-...' configure options require an argument, below
> +# are the values used in those arguments.  This is performed by
> +# substituting the string shown by configure.  For example, the string
> +# 'DIR' is substituted by '/foo/dir'.
> +WITH_DIR="\/foo\/dir"
> +WITH_GROUPNAME="foo_groupname"
> +WITH_NUM=10
> +WITH_PATH="\/foo\/path"
> +WITH_PREFIX="foo_prefix\-"
> +WITH_SCRIPT="\/foo\/script"
> +WITH_STRING="foo_string"
> +WITH_USERNAME="foo_username"
> +
> +WITH_LIST=$WITH_DIR,$WITH_PATH
> +
> +for flag in $WITH_OPTS
> +do
> +    name=$(echo $flag | cut -d "=" -f 1 | cut -d "-" -f 3-)
> +    value=$(echo $flag | \
> +       sed -e "s/DIR/$WITH_DIR/g" \
> +           -e "s/GROUPNAME/$WITH_GROUPNAME/g" \
> +           -e "s/LIST/$WITH_LIST/g" \
> +           -e "s/PATH/$WITH_PATH/g" \
> +           -e "s/PREFIX/\"$WITH_PREFIX\"/g" \
> +           -e "s/NUM/$WITH_NUM/g" \
> +           -e "s/SCRIPT/\"$WITH_SCRIPT\"/g" \
> +           -e "s/STRING/$WITH_STRING/g" \
> +           -e "s/USERNAME/$WITH_USERNAME/g")
> +    # echo -e $name "\t" $value
> +    check $name "$value"
> +done
> --
> 1.8.5.1
>
>

Reply via email to