1*4fee23f9Smrg#! /bin/bash 2*4fee23f9Smrg 3*4fee23f9Smrg#set -x 4*4fee23f9Smrg 5*4fee23f9Smrg######################################################################## 6*4fee23f9Smrg# 7*4fee23f9Smrg# File: reg-test 8*4fee23f9Smrg# Author: Janis Johnson 9*4fee23f9Smrg# Date: 2005/09/08 10*4fee23f9Smrg# 11*4fee23f9Smrg# For each of a list of patches, invoke separate tools to update 12*4fee23f9Smrg# sources, do a build, and run one or more tests. 13*4fee23f9Smrg# 14*4fee23f9Smrg# Define these in a file whose name is the argument to this script: 15*4fee23f9Smrg# REG_IDLIST: List of patch identifiers. 16*4fee23f9Smrg# REG_UPDATE: Pathname of script to update the source tree. 17*4fee23f9Smrg# REG_BUILD: Pathname of script to build enough of the product to run 18*4fee23f9Smrg# the test. 19*4fee23f9Smrg# REG_TEST: Pathname of script to run one or more tests. 20*4fee23f9Smrg# Optional: 21*4fee23f9Smrg# VERBOSITY: Default is 0, to print only errors and final message. 22*4fee23f9Smrg# DATE_IN_MSG If set to anything but 0, include the time and date in 23*4fee23f9Smrg# messages 24*4fee23f9Smrg# REG_STOP Pathname of a file whose existence says to quit; default 25*4fee23f9Smrg# is STOP in the current directory. 26*4fee23f9Smrg# 27*4fee23f9Smrg# 28*4fee23f9Smrg# Copyright (c) 2002, 2003, 2005 Free Software Foundation, Inc. 29*4fee23f9Smrg# 30*4fee23f9Smrg# This file is free software; you can redistribute it and/or modify 31*4fee23f9Smrg# it under the terms of the GNU General Public License as published by 32*4fee23f9Smrg# the Free Software Foundation; either version 3 of the License, or 33*4fee23f9Smrg# (at your option) any later version. 34*4fee23f9Smrg# 35*4fee23f9Smrg# This program is distributed in the hope that it will be useful, 36*4fee23f9Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 37*4fee23f9Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 38*4fee23f9Smrg# GNU General Public License for more details. 39*4fee23f9Smrg# 40*4fee23f9Smrg# For a copy of the GNU General Public License, write the the 41*4fee23f9Smrg# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 42*4fee23f9Smrg# Boston, MA 02111-1301, USA. 43*4fee23f9Smrg# 44*4fee23f9Smrg######################################################################## 45*4fee23f9Smrg 46*4fee23f9Smrg######################################################################## 47*4fee23f9Smrg# Functions 48*4fee23f9Smrg######################################################################## 49*4fee23f9Smrg 50*4fee23f9Smrg# Issue a message if its verbosity level is high enough. 51*4fee23f9Smrg 52*4fee23f9Smrgmsg() { 53*4fee23f9Smrg test ${1} -gt ${VERBOSITY} && return 54*4fee23f9Smrg 55*4fee23f9Smrg if [ "x${DATE_IN_MSG}" = "x" ]; then 56*4fee23f9Smrg echo "${2}" 57*4fee23f9Smrg else 58*4fee23f9Smrg echo "`${DATE}` ${2}" 59*4fee23f9Smrg fi 60*4fee23f9Smrg} 61*4fee23f9Smrg 62*4fee23f9Smrg# Issue an error message and exit with a nonzero status. 63*4fee23f9Smrg 64*4fee23f9Smrgerror() { 65*4fee23f9Smrg msg 0 "error: ${1}" 66*4fee23f9Smrg exit 1 67*4fee23f9Smrg} 68*4fee23f9Smrg 69*4fee23f9Smrg# Build the components to test using sources as of a particular patch 70*4fee23f9Smrg# and run a test case. Pass each of the scripts the patch identifier 71*4fee23f9Smrg# that we're testing; the first one needs it, the others can ignore it 72*4fee23f9Smrg# if they want. 73*4fee23f9Smrg 74*4fee23f9Smrgprocess_patch () { 75*4fee23f9Smrg TEST_ID=${1} 76*4fee23f9Smrg 77*4fee23f9Smrg ${REG_UPDATE} ${TEST_ID} 78*4fee23f9Smrg if [ $? -ne 0 ]; then 79*4fee23f9Smrg msg 0 "source update failed for id ${TEST_ID}" 80*4fee23f9Smrg return 81*4fee23f9Smrg fi 82*4fee23f9Smrg ${REG_BUILD} ${TEST_ID} 83*4fee23f9Smrg if [ $? -ne 0 ]; then 84*4fee23f9Smrg msg 0 "build failed for id ${TEST_ID}" 85*4fee23f9Smrg return 86*4fee23f9Smrg fi 87*4fee23f9Smrg ${REG_TEST} "${TEST_ID}" 88*4fee23f9Smrg} 89*4fee23f9Smrg 90*4fee23f9Smrg######################################################################## 91*4fee23f9Smrg# Main program (so to speak) 92*4fee23f9Smrg######################################################################## 93*4fee23f9Smrg 94*4fee23f9Smrg# If DATE isn't defined, use the default date command; the configuration 95*4fee23f9Smrg# file can override this. 96*4fee23f9Smrg 97*4fee23f9Smrgif [ "x${DATE}" = "x" ]; then 98*4fee23f9Smrg DATE=date 99*4fee23f9Smrgfi 100*4fee23f9Smrg 101*4fee23f9Smrg# Process the configuration file. 102*4fee23f9Smrg 103*4fee23f9Smrgif [ $# -ne 1 ]; then 104*4fee23f9Smrg echo Usage: $0 config_file 105*4fee23f9Smrg exit 1 106*4fee23f9Smrgfi 107*4fee23f9Smrg 108*4fee23f9SmrgCONFIG=${1} 109*4fee23f9Smrgif [ ! -f ${CONFIG} ]; then 110*4fee23f9Smrg error "configuration file ${CONFIG} does not exist" 111*4fee23f9Smrgfi 112*4fee23f9Smrg 113*4fee23f9Smrg# OK, the config file exists. Source it, make sure required parameters 114*4fee23f9Smrg# are defined and their files exist, and give default values to optional 115*4fee23f9Smrg# parameters. 116*4fee23f9Smrg 117*4fee23f9Smrg. ${CONFIG} 118*4fee23f9Smrg 119*4fee23f9Smrgtest "x${REG_IDLIST}" = "x" && error "REG_IDLIST is not defined" 120*4fee23f9Smrgtest "x${REG_UPDATE}" = "x" && error "REG_UPDATE is not defined" 121*4fee23f9Smrgtest "x${REG_BUILD}" = "x" && error "REG_BUILD is not defined" 122*4fee23f9Smrgtest "x${REG_TEST}" = "x" && error "REG_TEST is not defined" 123*4fee23f9Smrgtest -x ${REG_TEST} || error "REG_TEST is not an executable file" 124*4fee23f9Smrgtest "x${VERBOSITY}" = "x" && VERBOSITY=0 125*4fee23f9Smrgtest "x${REG_STOP}" = "x" && REG_STOP="STOP" 126*4fee23f9Smrg 127*4fee23f9Smrgmsg 2 "REG_IDLIST = ${REG_IDLIST}" 128*4fee23f9Smrgmsg 2 "REG_UPDATE = ${REG_UPDATE}" 129*4fee23f9Smrgmsg 2 "REG_BUILD = ${REG_BUILD}" 130*4fee23f9Smrgmsg 2 "REG_TEST = ${REG_TEST}" 131*4fee23f9Smrgmsg 2 "VERBOSITY = ${VERBOSITY}" 132*4fee23f9Smrg 133*4fee23f9Smrg# Process each patch identifier in the list. 134*4fee23f9Smrg 135*4fee23f9Smrgfor TEST_ID in $REG_IDLIST; do 136*4fee23f9Smrg 137*4fee23f9Smrg # If a file called STOP appears, stop; this allows a clean way to 138*4fee23f9Smrg # interrupt a search. 139*4fee23f9Smrg 140*4fee23f9Smrg if [ -f ${REG_STOP} ]; then 141*4fee23f9Smrg msg 0 "STOP file detected" 142*4fee23f9Smrg rm -f ${REG_STOP} 143*4fee23f9Smrg exit 1 144*4fee23f9Smrg fi 145*4fee23f9Smrg 146*4fee23f9Smrg # Process the new patch. 147*4fee23f9Smrg 148*4fee23f9Smrg msg 2 "process id ${TEST_ID}" 149*4fee23f9Smrg process_patch ${TEST_ID} 150*4fee23f9Smrgdone 151*4fee23f9Smrg 152*4fee23f9Smrgmsg 1 "done" 153