diff --git a/CMakeLists.txt b/CMakeLists.txt index 5693eef6f..a6f26877c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ set(CMAKE_VERBOSE_MAKEFILE ON) macro(add_patch submodule patch working_directory patch_list) add_custom_command(OUTPUT ${patch}.applied WORKING_DIRECTORY ${working_directory} - COMMAND patch --forward -p0 < ${patchdir}/${submodule}/${patch} + COMMAND patch --forward -p0 < ${patchdir}/${submodule}/${patch} || true COMMAND touch ${CMAKE_BINARY_DIR}/${patch}.applied COMMENT "Applying ${patch}") list(APPEND ${patch_list} ${patch}.applied) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9655ccef1..7e8d370c8 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,7 +9,8 @@ RUN apt -y install autoconf automake autotools-dev bc \ gperf libgmp-dev libmpc-dev libmpfr-dev libtool texinfo tmux \ patchutils zlib1g-dev wget bzip2 patch vim-common lbzip2 python \ pkg-config libglib2.0-dev libpixman-1-dev libssl-dev screen \ - device-tree-compiler expect makeself unzip cpio rsync cmake ninja-build p7zip-full + device-tree-compiler expect makeself unzip cpio rsync cmake ninja-build \ + p7zip-full socat RUN apt-get update && apt-get install --reinstall ca-certificates RUN git clone https://github.com/keystone-enclave/keystone /keystone diff --git a/docker/Dockerfile.32.nobuild b/docker/Dockerfile.32.nobuild index 1f38ba6af..d5754ef17 100644 --- a/docker/Dockerfile.32.nobuild +++ b/docker/Dockerfile.32.nobuild @@ -9,7 +9,8 @@ RUN apt -y install autoconf automake autotools-dev bc \ gperf libgmp-dev libmpc-dev libmpfr-dev libtool texinfo tmux \ patchutils zlib1g-dev wget bzip2 patch vim-common lbzip2 python \ pkg-config libglib2.0-dev libpixman-1-dev libssl-dev screen \ - device-tree-compiler expect makeself unzip cpio rsync cmake ninja-build p7zip-full + device-tree-compiler expect makeself unzip cpio rsync cmake ninja-build \ + p7zip-full socat RUN apt-get update && apt-get install --reinstall ca-certificates RUN git clone https://github.com/keystone-enclave/keystone /keystone diff --git a/docker/Dockerfile.nobuild b/docker/Dockerfile.nobuild index 54f8b9fcf..640725d6e 100644 --- a/docker/Dockerfile.nobuild +++ b/docker/Dockerfile.nobuild @@ -9,7 +9,8 @@ RUN apt -y install autoconf automake autotools-dev bc \ gperf libgmp-dev libmpc-dev libmpfr-dev libtool texinfo tmux \ patchutils zlib1g-dev wget bzip2 patch vim-common lbzip2 python \ pkg-config libglib2.0-dev libpixman-1-dev libssl-dev screen \ - device-tree-compiler expect makeself unzip cpio rsync cmake ninja-build p7zip-full + device-tree-compiler expect makeself unzip cpio rsync cmake ninja-build \ + p7zip-full socat RUN apt-get update && apt-get install --reinstall ca-certificates RUN git clone https://github.com/keystone-enclave/keystone /keystone diff --git a/scripts/run-qemu.sh.in b/scripts/run-qemu.sh.in index 5d625d109..8f3cb79ec 100755 --- a/scripts/run-qemu.sh.in +++ b/scripts/run-qemu.sh.in @@ -31,4 +31,5 @@ done; -netdev user,id=net0,net=192.168.100.1/24,dhcpstart=192.168.100.128,hostfwd=tcp::${HOST_PORT}-:22 \ -device virtio-net-device,netdev=net0 \ -device virtio-rng-pci \ - -smp $SMP + -smp $SMP \ + -monitor unix:qemu-monitor.sock,server,nowait diff --git a/scripts/travis.sh b/scripts/travis.sh index f7040c893..da831f2c7 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -1,19 +1,39 @@ #!/bin/bash EXPECTED_LOG_DIR=$1 +MONITOR_SOCKET=qemu-monitor.sock +ATTEMPTS=10 +ATTEMPT_DELAY=5 -# Launch QEMU test +# Launch QEMU screen -L -dmS qemu ./scripts/run-qemu.sh -# TODO: check for connectivity before starting, instead of sleeping -sleep 20 +sleep 1 + +# Verify VM is running before running tests - abort after 10 failed attempts +for ((i = 0;;)); do + result=$( (echo "info status" && sleep 1) | \ + socat - unix-connect:$MONITOR_SOCKET | \ + grep -oF "running") + [[ -z "$result" ]] || break + echo "VM not yet running. (check $((++i))/$ATTEMPTS)" + if [[ $i -eq $ATTEMPTS ]]; then + echo "[FAIL] VM not confirmed as running after max of $ATTEMPTS checks - aborting." + exit 1 + fi + sleep $ATTEMPT_DELAY +done + +# Clean up socket +rm $MONITOR_SOCKET +echo "VM confirmed to be running. Proceeding to run test(s)." + ./scripts/test-qemu.sh 2>&1 | grep -v "Warning: Permanently added" | tee output.log diff output.log $EXPECTED_LOG_DIR/test-qemu.expected.log -if [ $? -eq 0 ] -then - echo "[PASS] output.log matches with the expected output" - exit 0 +if [ $? -eq 0 ]; then + echo "[PASS] output.log matches with the expected output" + exit 0 else - echo "[FAIL] output.log does not match with the expected output" - exit 1 + echo "[FAIL] output.log does not match with the expected output" + exit 1 fi