jenkins: add glue for testing on a windows vm
authorJustus Winter <justus@g10code.com>
Wed, 11 Jan 2017 11:02:51 +0000 (12:02 +0100)
committerJustus Winter <justus@g10code.com>
Wed, 11 Jan 2017 11:05:07 +0000 (12:05 +0100)
Signed-off-by: Justus Winter <justus@g10code.com>
misc/jenkins/bin/build.bash
misc/jenkins/bin/gnupg-2.0-w32.patch [new file with mode: 0644]
misc/jenkins/bin/gnupg-2.2-w32.patch [new symlink]
misc/jenkins/bin/gnupg-w32.patch [new file with mode: 0644]
misc/jenkins/bin/run-tests-w32.bash [new file with mode: 0755]
misc/jenkins/bin/run-tests.bat

index eb5d973..72f18ab 100755 (executable)
@@ -171,6 +171,8 @@ case "$XTARGET" in
        case "$JOB_NAME" in
                gnupg/*|gnupg-2.2/*)
                        bash /home/jenkins/bin/make-windows-cd.sh
+                       # We need to pass the absolute path of the iso.
+                       bash $HOME/bin/run-tests-w32.bash "$(readlink -f gnupg-test.iso)" || true
                        ;;
        esac
         ;;
diff --git a/misc/jenkins/bin/gnupg-2.0-w32.patch b/misc/jenkins/bin/gnupg-2.0-w32.patch
new file mode 100644 (file)
index 0000000..0cd6e59
--- /dev/null
@@ -0,0 +1,21 @@
+diff --git a/autogen.sh b/autogen.sh
+index 605babfa9..1a9654f0d 100755
+--- a/autogen.sh
++++ b/autogen.sh
+@@ -87,15 +87,7 @@ if test "$1" = "--build-w32"; then
+     $tsdir/configure --enable-maintainer-mode --prefix=${w32root}  \
+              --host=${host} --build=${build} \
+              --enable-gpgtar \
+-             --with-gpg-error-prefix=${w32root} \
+-           --with-ksba-prefix=${w32root} \
+-           --with-libgcrypt-prefix=${w32root} \
+-           --with-libassuan-prefix=${w32root} \
+-           --with-zlib=${w32root} \
+-           --with-regex=${w32root} \
+-             --with-pth-prefix=${w32root} \
+-             --with-libiconv-prefix=${w32root} \
+-             --with-adns=${w32root} "$@"
++           "$@"
+     rc=$?
+     exit $rc
+ fi
diff --git a/misc/jenkins/bin/gnupg-2.2-w32.patch b/misc/jenkins/bin/gnupg-2.2-w32.patch
new file mode 120000 (symlink)
index 0000000..d829c6e
--- /dev/null
@@ -0,0 +1 @@
+gnupg-w32.patch
\ No newline at end of file
diff --git a/misc/jenkins/bin/gnupg-w32.patch b/misc/jenkins/bin/gnupg-w32.patch
new file mode 100644 (file)
index 0000000..1927ceb
--- /dev/null
@@ -0,0 +1,18 @@
+diff --git a/autogen.rc b/autogen.rc
+index 36948178f..4aa1993d8 100644
+--- a/autogen.rc
++++ b/autogen.rc
+@@ -15,13 +15,6 @@ esac
+ case "$myhost" in
+   w32)
+     configure_opts="
+-      --with-gpg-error-prefix=@SYSROOT@
+-      --with-ksba-prefix=@SYSROOT@
+-      --with-libgcrypt-prefix=@SYSROOT@
+-      --with-libassuan-prefix=@SYSROOT@
+-      --with-zlib=@SYSROOT@
+-      --with-regex=@SYSROOT@
+-      --with-npth-prefix=@SYSROOT@
+       --disable-g13
+       "
+     ;;
diff --git a/misc/jenkins/bin/run-tests-w32.bash b/misc/jenkins/bin/run-tests-w32.bash
new file mode 100755 (executable)
index 0000000..44e303d
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+# Locking.
+exec 9<"$0"
+echo -n "Aquiring lock on $0... "
+if ! flock --timeout 15 9 ; then
+    echo "failed!"
+    exit 1
+fi
+echo "ok."
+
+set -ex
+
+URI="qemu:///system"
+GUEST="win8.1"
+GUEST_CDROM="sda"
+SSH="gpg@192.168.122.117"
+
+function vdo() {
+    virsh -c "$URI" "$@"
+}
+
+function vssh() {
+    # OpenSSH on Windows does not cope well with a closed stdin.
+    timeout </dev/zero 10m ssh "$SSH" "$@"
+}
+
+function vping() {
+    if ssh </dev/zero >/dev/null 2>&1 -oConnectTimeout=1 \
+                                      "$SSH" "echo pong" ; then
+       return 0
+    else
+       return 1
+    fi
+}
+
+function vwait() {
+    echo >&2 -n "Waiting for the machine to boot... "
+    while ! vping ; do echo >&2 -n . ; sleep 1 ; done
+}
+
+# Revert to current snapshot and start the machine.
+vdo snapshot-revert --current --force --running "$GUEST"
+
+# Insert the CD.
+vdo change-media --update "$GUEST" "$GUEST_CDROM" "$1"
+
+set +x
+vwait
+set -x
+
+#sleep 5 # XXX: Let things settle.
+
+if [ "$2" ]; then
+    scp "$2" "$SSH:"
+    sleep 1 # XXX: openssh on windows is a bit fragile...
+    time vssh "cmd /c $(basename $2)"
+else
+    time vssh "cmd /c d:/run-tests.bat"
+fi
+
+sleep 1 # XXX: openssh on windows is a bit fragile...
+
+# The scp server is a bit fragile as well, and I believe globbing does
+# not work.  Simply use gpgtar.
+vssh 'powershell -Command "cd c:\temp\logs ; d:/gnupg/gpgtar.exe --create ."' | tar x --warning=no-timestamp
+
+# Shutdown.
+vdo shutdown "$GUEST"
index d88e197..adef960 100644 (file)
@@ -1,27 +1,21 @@
 @echo off
-cd /d d:\
 
-set TARGET=gnupg-test
-
-set GNUPGHOME=c:/%TARGET%/tests/openpgp
-c:/%TARGET%/gpg-connect-agent.exe killagent /bye
-rem is there a nicer way to sleep?
-ping -n 1 localhost > nul
-set GNUPGHOME=
-
-rmdir /q /s c:\%TARGET%
-mkdir c:\%TARGET%
-xcopy /q /s d:\gnupg c:\%TARGET%
-
-set GPGSCM_PATH=c:/%TARGET%/tests/gpgscm;c:/%TARGET%/tests/openpgp
+set BIN_PREFIX=d:\gnupg
+set GPGSCM_PATH=%BIN_PREFIX%/tests/gpgscm;%BIN_PREFIX%/tests/openpgp
 set EXEEXT=.exe
-set srcdir=/%TARGET%/tests/openpgp
-set BIN_PREFIX=c:/%TARGET%
+set srcdir=%BIN_PREFIX%/tests/openpgp
 set TMP=c:\temp
+set WD=c:\temp\logs
 mkdir %TMP%
+mkdir %WD%
+
+cd /d %BIN_PREFIX%
+%BIN_PREFIX%\gpgscm.exe --verbose tests/gpgscm/t-child.scm
+
+cd /d %WD%
 
-cd /d c:\%TARGET%
-c:\%TARGET%\gpgscm.exe --verbose tests/gpgscm/t-child.scm
+rem the gpgtar.scm is acting up (looping), and we don't deal with that
+rem well atm, so we simply omit it
 
-cd /d c:\%TARGET%\tests\openpgp
-c:\%TARGET%\gpgscm.exe run-tests.scm --shared version.scm mds.scm decrypt.scm decrypt-dsa.scm sigs.scm sigs-dsa.scm encrypt.scm encrypt-dsa.scm seat.scm clearsig.scm encryptp.scm detach.scm detachm.scm armsigs.scm armencrypt.scm armencryptp.scm signencrypt.scm signencrypt-dsa.scm armsignencrypt.scm armdetach.scm armdetachm.scm genkey1024.scm conventional.scm conventional-mdc.scm multisig.scm verify.scm gpgv-forged-keyring.scm armor.scm import.scm ecc.scm 4gb-packet.scm tofu.scm gpgtar.scm use-exact-key.scm default-key.scm export.scm ssh.scm quick-key-manipulation.scm issue2015.scm issue2346.scm issue2417.scm issue2419.scm
+echo Running tests...
+%BIN_PREFIX%\gpgscm.exe %srcdir%/run-tests.scm --parallel version.scm enarmor.scm mds.scm decrypt.scm decrypt-multifile.scm decrypt-dsa.scm decrypt-session-key.scm sigs.scm sigs-dsa.scm encrypt.scm encrypt-multifile.scm encrypt-dsa.scm compression.scm seat.scm clearsig.scm encryptp.scm detach.scm detachm.scm armsigs.scm armencrypt.scm armencryptp.scm signencrypt.scm signencrypt-dsa.scm armsignencrypt.scm armdetach.scm armdetachm.scm genkey1024.scm conventional.scm conventional-mdc.scm multisig.scm verify.scm verify-multifile.scm gpgv-forged-keyring.scm armor.scm import.scm import-revocation-certificate.scm ecc.scm 4gb-packet.scm tofu.scm use-exact-key.scm default-key.scm export.scm ssh-import.scm ssh-export.scm quick-key-manipulation.scm key-selection.scm delete-keys.scm gpgconf.scm issue2015.scm issue2346.scm issue2417.scm issue2419.scm