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