Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c5ad61b7fb
Fetching contributors…

Cannot retrieve contributors at this time

executable file 171 lines (126 sloc) 5.128 kb
#!/bin/bash
#
# Testing script to take a stable kernel patch set, build it on a remote
# machine using ktest, and email back the results.
#
# Copyright 2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
#
# Released under the GPLv2 only.
#
#
# Some variables you might want to mess with are:
#
# EMAIL: who to send the email to
# REMOTE_STABLE_GIT: on the remote machine, where the linux-stable git tree is located
# REMOTE_WORK: on the remote machine, what temporary location we can use to create a subdirectory and do our work in
# REMOTE_SERVER: the remote machine name
# REMOTE_USER: the username to run the script on the remote machine
# LOCAL_WORK: temporay location on the local machine to create some files before we copy them to the remote machine
# LOCAL_KTEST: local location of a version of ktest.pl that you want to run remotely (usually better than the version in the stable tree under testing due to age issues.)
# QUEUE_DIR: local location of the stable-queue git tree we are wanting to test
EMAIL="greg@kroah.com"
REMOTE_STABLE_GIT="/home/gregkh/linux/stable/linux-stable/"
REMOTE_WORK="/home/gregkh/tmp/"
REMOTE_SERVER="build"
REMOTE_USER="gregkh"
REMOTE_STABLE_GIT="/home/ec2-user/linux/stable/linux-stable/"
REMOTE_WORK="/home/ec2-user/tmp/"
#REMOTE_SERVER="ec2-50-112-17-159.us-west-2.compute.amazonaws.com" # not mine
#REMOTE_SERVER="ec2-50-112-71-91.us-west-2.compute.amazonaws.com" # mine - really big
REMOTE_SERVER="ec2-50-112-51-233.us-west-2.compute.amazonaws.com" # mine - really big
SSH_OPTIONS="-i /home/gregkh/.ssh/stable_build.pem"
REMOTE_USER="ec2-user"
LOCAL_WORK="/tmp/"
LOCAL_KTEST="/home/gregkh/linux/gregkh/tools/testing/ktest/ktest.pl"
QUEUE_DIR="/home/gregkh/linux/stable/stable-queue/"
#######################################################
# I doubt you need to touch anything below this line,
# unless you want to fix my bugs, or rewrite the scripts
# to be saner (hint, feel free to do so...)
#######################################################
# grab the kernel version from the command line
KERNEL_VERSION="$1"
if [ "${KERNEL_VERSION}" == "" ] ; then
echo "$0 KERNEL_VERSION"
exit;
fi
# create the local temporary directory to do the work in.
SCRIPT_HOME=`mktemp -d ${LOCAL_WORK}/stable_test_XXXXX`
echo "Using ${SCRIPT_HOME} for our local files"
# create the remote directory
REMOTE_DIR=`ssh ${SSH_OPTIONS} ${REMOTE_USER}@${REMOTE_SERVER} mktemp -d ${REMOTE_WORK}/stable_test_XXXXX`
echo "Using ${REMOTE_DIR} for the remote directory"
# figure out how many processors are on the remote machine
NUM_PROCESSORS=`ssh ${SSH_OPTIONS} ${REMOTE_USER}@${REMOTE_SERVER} grep -c "processor" /proc/cpuinfo`
echo "Remote machine has ${NUM_PROCESSORS} processors."
# tar up stable patch queue for just this kernel version
cd ${QUEUE_DIR}/queue-${KERNEL_VERSION}/
tar -c . | gzip > ${SCRIPT_HOME}/stable_queue.tar.gz
# create the script to run remotely
cat << __EOF__ > ${SCRIPT_HOME}/run_test.sh
#!/bin/bash
# Test script for the ${KERNEL_VERSION}-stable kernel
# autogenerated, do not edit by hand
#
STABLE_GIT="${REMOTE_STABLE_GIT}"
KERNEL_VERSION="${KERNEL_VERSION}"
PATCHES="stable_queue.tar.gz"
cd ${REMOTE_DIR}
# create the linux clone
git clone -s ${REMOTE_STABLE_GIT} linux
cd linux
# checkout the branch we need
git checkout -t -b linux-${KERNEL_VERSION}.y origin/linux-${KERNEL_VERSION}.y
# remove the .git directory as we don't need that space hanging around anymore
#rm -rf .git/
# create a patches/ directory for the stable patches to apply
mkdir patches
cd patches
tar -zxvf ${REMOTE_DIR}/\${PATCHES}
cd ..
# Apply the patch queue
QUILT_PATCHES=patches QUILT_SERIES=patches/series quilt push -aq --quiltrc
# get initial time
TIME=\$(date +%s)
# build stuff
../ktest.pl ../ktest.conf
KTEST_RUN=\$?
echo "KTEST_RUN = \${KTEST_RUN}"
# get time it took to do the build
TIME="\$((\$(date +%s)-TIME))"
echo "Took \${TIME} seconds to build"
cd ..
if [ "\${KTEST_RUN}" = "0" ]; then
# test succeeded
SUBJECT="Build of ${KERNEL_VERSION} was good"
else
SUBJECT="Build of ${KERNEL_VERSION} FAILED!"
fi
mutt -s "\${SUBJECT}" -a linux/log -- ${EMAIL} < output_log
# now that we are done, clean up after ourselves
rm -rf ${REMOTE_DIR}
__EOF__
chmod 755 ${SCRIPT_HOME}/run_test.sh
# create the ktest.conf file
cat <<__EOF__ > ${SCRIPT_HOME}/ktest.conf
TEST_START
TEST_TYPE = build
DEFAULTS
BUILD_TYPE = allmodconfig
OUTPUT_DIR = \${PWD}/output
LOG_FILE = \${PWD}/log
LOCALVERSION = -test
BUILD_OPTIONS = -j${NUM_PROCESSORS}
MACHINE = aws
BUILD_DIR = \${PWD}
__EOF__
# copy a version of ktest that we want to run
cp ${LOCAL_KTEST} ${SCRIPT_HOME}
# copy the files we created to the remote machine
scp ${SSH_OPTIONS} -q ${SCRIPT_HOME}/* ${REMOTE_USER}@${REMOTE_SERVER}:${REMOTE_DIR}
# remove the local files as we don't need them anymore
rm -rf ${SCRIPT_HOME}
# execute the script on the remote machine
#ssh ${REMOTE_USER}@${REMOTE_SERVER} "${REMOTE_DIR}/run_test.sh > ${REMOTE_DIR}/output_log"
ssh ${SSH_OPTIONS} -n -f ${REMOTE_USER}@${REMOTE_SERVER} "sh -c \"cd ${REMOTE_DIR}; nohup ./run_test.sh > ${REMOTE_DIR}/output_log 2>&1 &\" "
exit
Jump to Line
Something went wrong with that request. Please try again.