On Tue, Sep 24, 2013 at 1:16 PM, Jose A. Lopes <[email protected]> wrote: > Add script that creates distribution tarballs with different configure > options and tests whether these tarballs contain the same set of > files. > > * profiles: the script tests different distribution profiles. A > profile is basically a collection of configure options. For > example, the 'normal' profile is just > > PYTHON=python2.6 --prefix=/usr --sysconfdir=/etc \ > --localstatedir=/var --with-user-prefix=gnt- --with-group-prefix=gnt- > > and the profile with 'confd' disabled, called 'disable-confd', is > > PYTHON=python2.6 --prefix=/usr --sysconfdir=/etc \ > --localstatedir=/var --with-user-prefix=gnt- --with-group-prefix=gnt- \ > --disable-confd > > * steps: for each profile, the script will perform the following > steps, where '$args' is the configure options we want to > enable/disable/change: > > ./autogen.sh > ./configure ... $args > make dist > tar -tf ... > listFile
Besides this, could we also check that the dist contains a set of "expected" files (eg. all design docs, all haskell and python source files, etc) This would avoid errors like the other day, when we weren't shipping some .rst in the tarball. > > * logging: each of these steps is logging to a file, whose filename is > determined by the profile. For example, the 'disable-confd' profile > logs to the file 'ganeti-disable-confd.log'. > > * list of files: the script will generate distribution tarballs for > each of the profiles and then it must compare the list of files of > each of these tarballs against the table of files of the normal > profile. To achieve this, a list of files is calculated from the > tarball and written to a file whose filename also depends on the > profile. For example, for the 'disable-confd' profile this filename > is 'ganeti-disable-confd.lst'. > > * TODO: > > ** not all configure options have been included in the script yet > because I wanted to get feedback on the script before completing it > Maybe you just want to generate at random one or two, and test those, instead of testing all every time? > ** 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 > > ** currently, the intermediate files (i.e., the diff file, log file, > and distribution tarball) are not being cleaned up. In case of > success, these files could be removed, but in case of an error it > would be nice to have these files around. I don't know what the > buildbot policy is. > > Feedback is highly appreciated. > > Signed-off-by: Jose A. Lopes <[email protected]> > --- > devel/test-dists | 109 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 109 insertions(+) > create mode 100755 devel/test-dists > > diff --git a/devel/test-dists b/devel/test-dists > new file mode 100755 > index 0000000..9c15d3b > --- /dev/null > +++ b/devel/test-dists > @@ -0,0 +1,109 @@ > +#!/bin/bash > + > +# Argument to the script with be given directly to 'make' > +# > +# Example: > +# ./test-dists.sh -j8 This example has ".sh" but the file name is just called test-dists. > +ARGS="$@" > + > +# The filename for the file holding the 'diff' between the list of > +# files of two distribution tarballs of two different profiles. > +function diffFile { > + local name1=$1 > + local name2=$2 > + echo "$name1-$name2.diff" > +} > + > +# The filename for the file holding the list of files extracted from > +# the distribution tarball. > +function listFile { > + echo "ganeti-$1".lst > +} > + > +# The filename for the file holding the output of all build commands, > +# namely, 'autogen', 'configure', and 'make'. > +function logFile { > + echo "ganeti-$1".log > +} > + Doing it this way means that you have to spawn a bash shell just to get "ganeti-$var.log" as output... Kind of expensive. You could instead pass the output variable name to the function, and just do the assignment inside, for example. > +# Performs a distclean whether there is a 'Makefile' present or not. > +function makeClean { > + local name=$1 > + > + if [[ -f Makefile ]] > + then > + echo [$name] Running make distclean > + make distclean > $(logFile $name) > + else > + echo [$name] Running ./autogen.sh && ./configure && make distclean > + ./autogen.sh && ./configure && make distclean > $(logFile $name) > + fi > +} ...here you bail out if one of the commands fails > + > +# Performs 'autogen', 'configure', 'make dist', and 'tar -tf'. > +function makeDist { > + local name=$1 > + local args=$2 > + > + makeClean $name > + echo [$name] Running ./autogen.sh > + ./autogen.sh &> $(logFile $name) > + echo [$name] Running ./configure ... > + ./configure PYTHON=python2.6 --prefix=/usr --sysconfdir=/etc \ > + --localstatedir=/var --with-user-prefix=gnt- --with-group-prefix=gnt- > \ > + "$args" &>> $(logFile $name) > + echo [$name] Running make dist... this will take a while > + make distdir="ganeti-$name" $ARGS dist &>> $(logFile $name) > + tar -tf "ganeti-$name.tar.gz" | cut -d "/" -f 2- > $(listFile $name) > +} > + but here you don't. set -e advised at the top. > +# Performs 'makeDist' and a 'diff' on the list of files between two > +# distribution tarballs. > +function runDiff { > + local name1=$1 > + local name2=$2 > + > + if diff $(listFile $1) $(listFile $2) > $(diffFile $1 $2) > + then > + echo diff $1 $2: [ok] > + else > + echo diff $1 $2: [failed] > + fi > +} > + output is good, but as you say above return codes are better, so a human doesn't have to look at this and see if it failed. > +# Performs 'runDiff' against the normal profile. > +function runNormalDiff { > + runDiff normal $1 > +} Do you need a function for this? > + > +# Performs 'makeDist' and 'runNormalDiff' on a given profile. > +function check { > + local name=$1 > + local args="$2" > + > + makeDist $name "$args" > + runNormalDiff $name > +} > + > +makeDist normal > + > +check enable-version-full "--enable-version-full" > +check enable-symlinks "--enable-symlinks" > +check with-ssh-initscript "--with-ssh-initscript=/foo" > + > +check with-export-dir "--with-export-dir=/foo" > +check with-ssh-config-dir "--with-ssh-config-dir=/foo" > +check with-xen-config-dir "--with-xen-config-dir=/foo" > +check with-os-search-path "--with-os-search-path=/foo" > +check with-extstorage-search-path "--with-extstorage-search-path=/foo" > +check with-iallocator-search-path "--with-iallocator-search-path=/foo" > +check with-xen-bootloader "--with-xen-bootloader=/foo" > + > +check disable-drbd-barriers "--enable-drbd-barriers=no" > +check enable-syslog "--enable-syslog=yes" > +check only-syslog "--enable-syslog=only" > + > +check enable-restricted-commands "--enable-restricted-commands=yes" > +check disable-confd "--disable-confd" > +check disable-monitoring "--disable-monitoring" > +check disable-split-query "--disable-split-query" You could extract those from configure.ac or Makefile.am, maybe? Thanks, Guido
