#!/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 # # 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" 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 ${REMOTE_USER}@${REMOTE_SERVER} mktemp -d ${REMOTE_WORK}/stable_test_XXXXX` echo "Using ${REMOTE_DIR} for the remote directory" # 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 # build stuff perl ../ktest.pl ../ktest.conf KTEST_RUN=$? echo "KTEST_RUN = \${KTEST_RUN}" 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 = -j16 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 -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} "cd ${REMOTE_DIR} && nohup \"cd ${REMOTE_DIR} && ./run_test.sh & > ${REMOTE_DIR} output_log \" " #ssh ${REMOTE_USER}@${REMOTE_SERVER} "cd ${REMOTE_DIR} && nohup \"${REMOTE_DIR}/run_test.sh & > ${REMOTE_DIR}/output_log\"" #ssh ${REMOTE_USER}@${REMOTE_SERVER} "nohup ${REMOTE_DIR}/run_test.sh > ${REMOTE_DIR}/output_log &" #ssh ${REMOTE_USER}@${REMOTE_SERVER} "${REMOTE_DIR}/run_test.sh > ${REMOTE_DIR}/output_log" ssh -n -f ${REMOTE_USER}@${REMOTE_SERVER} "sh -c \"cd ${REMOTE_DIR}; nohup ./run_test.sh > ${REMOTE_DIR}/output_log 2>&1 &\" " exit