From aa9f7fb1f6ef5d2abaa5448df462a8561a67c9e0 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Wed, 21 Oct 2015 16:18:21 -0500 Subject: [PATCH] test: add ability to run tests remotely Create a "make remote" target and a poor man's ansible to allow setting up a remote F22 system and running integration tests on it. To run tests remotely: make remote SSH_HOST=my.remote.f22.box --- test/integration/f22/Makefile | 30 ++++++++++++++++++++- test/integration/f22/remote-setup | 45 +++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100755 test/integration/f22/remote-setup diff --git a/test/integration/f22/Makefile b/test/integration/f22/Makefile index 891ce9b..3e566d3 100644 --- a/test/integration/f22/Makefile +++ b/test/integration/f22/Makefile @@ -1,4 +1,11 @@ -all: clean +all: + $(error please specify local or remote) + +local: slow + +remote: remote_slow + +slow: clean ../kpatch-test quick: clean @@ -9,3 +16,24 @@ cached: clean: rm -f *.ko *.log COMBINED.patch + +check_host: +ifndef SSH_HOST + $(error SSH_HOST is undefined) +endif + +SSH_USER ?= root + +remote_setup: check_host + ssh $(SSH_USER)@$(SSH_HOST) exit + ssh $(SSH_USER)@$(SSH_HOST) "ls kpatch-setup &> /dev/null" || \ + (scp remote-setup $(SSH_USER)@$(SSH_HOST):kpatch-setup && \ + ssh $(SSH_USER)@$(SSH_HOST) "./kpatch-setup") + +remote_sync: remote_setup + ssh $(SSH_USER)@$(SSH_HOST) "rm -rf kpatch-test" + rsync -Cavz --include=core $(shell readlink -f ../../..) $(SSH_USER)@$(SSH_HOST):kpatch-test + ssh $(SSH_USER)@$(SSH_HOST) "cd kpatch-test/kpatch && make" + +remote_slow: remote_sync + ssh $(SSH_USER)@$(SSH_HOST) "cd kpatch-test/kpatch/test/integration/f22 && make slow" diff --git a/test/integration/f22/remote-setup b/test/integration/f22/remote-setup new file mode 100755 index 0000000..e5a5965 --- /dev/null +++ b/test/integration/f22/remote-setup @@ -0,0 +1,45 @@ +#!/bin/bash -x + +# install rpms on a Fedora 22 system to prepare it for kpatch integration tests + +set -o errexit + +[[ $UID != 0 ]] && sudo=sudo + +warn() { + echo "ERROR: $1" >&2 +} + +die() { + warn "$@" + exit 1 +} + +install_rpms() { + # crude workaround for a weird dnf bug where it fails to download + $sudo dnf install -y $* || $sudo dnf install -y $* +} + +install_rpms gcc elfutils elfutils-devel rpmdevtools pesign openssl numactl-devel wget patchutils + +$sudo dnf builddep -y kernel || $sudo dnf builddep -y kernel + +# install kernel debuginfo and devel RPMs for target kernel +kverrel=$(uname -r) +kverrel=${kverrel%.x86_64} +kver=${kverrel%%-*} +krel=${kverrel#*-} +install_rpms https://kojipkgs.fedoraproject.org/packages/kernel/$kver/$krel/x86_64/kernel-debuginfo-$kver-$krel.x86_64.rpm https://kojipkgs.fedoraproject.org/packages/kernel/$kver/$krel/x86_64/kernel-debuginfo-common-x86_64-$kver-$krel.x86_64.rpm https://kojipkgs.fedoraproject.org/packages/kernel/$kver/$krel/x86_64/kernel-devel-$kver-$krel.x86_64.rpm + +# install version of gcc which was used to build the target kernel +gccver=$(gcc --version |head -n1 |cut -d' ' -f3-) +kgccver=$(readelf -p .comment /usr/lib/debug/lib/modules/$(uname -r)/vmlinux |grep GCC: | tr -s ' ' | cut -d ' ' -f6-) +if [[ $gccver != $kgccver ]]; then + gver=$(echo $kgccver | awk '{print $1}') + grel=$(echo $kgccver | sed 's/.*-\(.*\))/\1/') + grel=$grel.$(rpm -q gcc |sed 's/.*\.\(.*\)\.x86_64/\1/') + install_rpms https://kojipkgs.fedoraproject.org/packages/gcc/$gver/$grel/x86_64/cpp-$gver-$grel.x86_64.rpm https://kojipkgs.fedoraproject.org/packages/gcc/$gver/$grel/x86_64/gcc-$gver-$grel.x86_64.rpm https://kojipkgs.fedoraproject.org/packages/gcc/$gver/$grel/x86_64/libgomp-$gver-$grel.x86_64.rpm +fi + +install_rpms ccache +ccache -M 5G