Add working libguestfs tests.
authorRichard W.M. Jones <rjones@redhat.com>
Fri, 7 Jul 2017 09:10:24 +0000 (10:10 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Fri, 7 Jul 2017 10:28:31 +0000 (11:28 +0100)
check-release.sh
check-syntax.sh
test-functions [new file with mode: 0644]

index d46d99a..63d2c05 100755 (executable)
@@ -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
index 65f5a5f..2fc9ddd 100755 (executable)
@@ -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 (file)
index 0000000..78f7054
--- /dev/null
@@ -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
+}