From 289a75e3572069b41a6d1ad08dfd4e1e3eb168fd Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 7 Jul 2017 10:10:24 +0100 Subject: [PATCH 1/1] Add working libguestfs tests. --- check-release.sh | 37 ++++++++++++++++++- check-syntax.sh | 30 ++++++++++++++-- test-functions | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+), 3 deletions(-) create mode 100644 test-functions diff --git a/check-release.sh b/check-release.sh index d46d99a..63d2c05 100755 --- a/check-release.sh +++ b/check-release.sh @@ -1,3 +1,38 @@ #!/bin/bash - -echo check-release called: $@ +set -e + +d="$(dirname $0)" +source $d/test-functions + +pick_project "$@" +checkout_sources +apply_patches "$@" +local_config + +cd $project + +./localconfigure + +case "$project" in + libguestfs) + make ||: + rm po-docs/podfiles; make -C po-docs update-po + make + ;; + *) + make + ;; +esac + +# Run the tests. + +case "$project" in + libguestfs) + #make check-release # one day + make check + ;; + *) + make check + ;; +esac diff --git a/check-syntax.sh b/check-syntax.sh index 65f5a5f..2fc9ddd 100755 --- a/check-syntax.sh +++ b/check-syntax.sh @@ -1,4 +1,30 @@ #!/bin/bash - -echo check-syntax called: $@ -exit 1 +set -e + +d="$(dirname $0)" +source $d/test-functions + +pick_project "$@" +checkout_sources +apply_patches "$@" +local_config + +cd $project + +./localconfigure + +case "$project" in + libguestfs) + make ||: + rm po-docs/podfiles; make -C po-docs update-po + make + ;; + *) + make + ;; +esac + +# XXX +# make check-syntax is not implemented in any project yet. +exit 77 diff --git a/test-functions b/test-functions new file mode 100644 index 0000000..78f7054 --- /dev/null +++ b/test-functions @@ -0,0 +1,108 @@ +# -*- shell-script -*- +# These are some common functions used to test libguestfs. + +function pick_project () +{ + # Try to guess which project this patch series is for. + # You should put [PATCH hivex ...] or [PATCH supermin ...] + # in the subject line. + subject="$(grep -i -m1 '^Subject: ' $1)" + project=libguestfs + if [[ "$subject" =~ \[PATCH.*hivex.*\] ]]; then + project=hivex + elif [[ "$subject" =~ \[PATCH.*supermin.*\] ]]; then + project=supermin + elif [[ "$subject" =~ \[PATCH.*nbdkit.*\] ]]; then + project=nbdkit + fi + url=https://github.com/libguestfs/$project +} + +function checkout_sources () +{ + echo + echo "Checking out sources from $url ..." + echo + + # Save network by using the local copy if it exists. + if [ -d $HOME/d/$project ]; then + cp -a $HOME/d/$project . + pushd $project + git checkout -f master + git clean -xdf + git pull + popd + else + git clone $url + fi +} + +# Try to apply the patches. +function apply_patches () +{ + echo + echo "Applying patches ..." + echo + cp "$@" $project/ + pushd $project + git am "$@" + popd +} + +# Set up localconfigure and localenv appropriately. +function local_config () +{ + pushd $project + case "$project" in + libguestfs) + cat > localconfigure <<'EOF' +./autogen.sh \ + --prefix /usr \ + --libdir /usr/lib64 \ + --disable-static \ + --enable-werror \ + --disable-golang \ + -C \ + "$@" +EOF + cat > localenv <<'EOF' +export SKIP_TEST_PARALLEL_MOUNT_LOCAL=1 +export SKIP_TEST_FUSE_UMOUNT_RACE_SH=1 +export SKIP_TEST_GUESTMOUNT_FD=1 +export SKIP_TEST_XFS_ADMIN=1 +export SKIP_TEST_XFS_MISC_PL=1 +export SKIP_TEST_SYSLINUX_PL=1 +EOF + ;; + + hivex) + cat > localconfigure <<'EOF' +./autogen.sh \ + --prefix /usr \ + --libdir /usr/lib64 \ + --enable-gcc-warnings +EOF + ;; + + supermin) + cat > localconfigure <<'EOF' +./autogen.sh \ + --prefix /usr \ + --libdir /usr/lib64 \ + --enable-werror +EOF + ;; + + nbdkit) + cat > localconfigure <<'EOF' +./configure \ + --prefix /usr \ + --libdir /usr/lib64 \ + --enable-gcc-warnings \ + "$@" +EOF + ;; + esac + chmod +x localconfigure + popd +} -- 1.8.3.1