Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify VM is running before running tests #315

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.32.nobuild
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.nobuild
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion scripts/run-qemu.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 29 additions & 9 deletions scripts/travis.sh
Original file line number Diff line number Diff line change
@@ -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