From f7edeb468a963c5e4c0594aaa221e42b763477fd Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Sat, 28 Jun 2008 21:31:36 +0000 Subject: Add builder - a script to test-build dahdi vs. various kernel versions. Also include other test_kernel_git from http://svn.digium.com/view/zaptel?view=rev&revision=4375 git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@4473 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- build_tools/builder | 168 ++++++++++++++++++++++++++++++++++++++++++++ build_tools/test_kernel_git | 15 ++-- 2 files changed, 179 insertions(+), 4 deletions(-) create mode 100755 build_tools/builder (limited to 'build_tools') diff --git a/build_tools/builder b/build_tools/builder new file mode 100755 index 0000000..e85be77 --- /dev/null +++ b/build_tools/builder @@ -0,0 +1,168 @@ +#!/bin/sh + +# build_test - a build testing script +# +# Copyright (C) 2008 by Xorcom +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Setup: +# +# 0. Copy this script under build_tools/ and +# +# chmod +x build_tools/builder +# +# 1. Make sure you have git and sqlite3 installed. If the sqlite3 binary +# is called differently, fix the line "SQLITE=" in the script or in +# build_tools/test_build.conf . +# +# 2. Run: +# +# ./build_tools/test_kernel_git init /path/to/some/dir +# +# /path/to/some/dir must exist . This will download a recent kernel +# git repository to /path/to/some/dir/linux-2.6 . Use +# './build_tools/test_kernel_git update' to pull a fresh update there. +# +# 3. Run: +# +# ./build_tools/builder init +# +# +# Usage: +# +# ./build_tools build +# +# The past results are in a sqlite database in the logs subdirectory. For +# a simple list of results: +# +# ./build_tools report +# +# You can also look at the build log for a specific build in the logs +# directory. + +BIN_DIR=`dirname $0` +BASE_DIR=`dirname $BIN_DIR` +SQLITE=sqlite3 +HOSTS="localhost" +LOGS_DIR="$BASE_DIR/logs" +DB=$LOGS_DIR/builds.db +BUILD_SCRIPT=$BIN_DIR/test_kernel_git +KERNELS_localhost="2.6.12 2.6.18 2.6.25" + +usage() { + me=`basename $0` + echo "$me: test building Zaptel/DAHDI with various kernels" + echo "" + echo "Usage: $0 command " + echo " init Create results directory and database." + echo " build [] Run the test builds. The default list: " + echo " $KERNELS_localhost" + echo " report [] Print all results [matching ]" + echo " Default is to print all the resaults." + echo "" + echo "Filters:" + echo " failed: Only failed tests." + echo " fail_type Where fail_type matches ." + echo " 2.6* Only builds for a matching kernel version." + echo " Else: Match a string from the build name, which " + echo " is essentially the time it started." + echo "" +} + +set -e + +if [ -r $BIN_DIR/test_build.conf ]; then . $BIN_DIR/test_build.conf; fi + +# Runs the test script, logs the result, and fails if the test command +# has failed. +build_and_check() { + test_name="$1" + test_cmd="$2" + log_file="$3" + results_str="$4" + fail_type='' + + set +e + $BUILD_SCRIPT $test_cmd >$log_file 2>&1 + rc=$? + set -e + if [ $rc != 0 ]; then + fail_type="$test_name" + echo "$results_str, $rc, '$fail_type', '$log_file');" | $SQLITE $DB + fi + return $rc +} + +build_zaptel() { + build_name="$1" + host="$2" + kvers="$3" + log_base="build__${build_name}__${host}__${kvers}" + log_base_full="$LOGS_DIR/$log_base" + log_file="$log_base_full.log" + results_str="INSERT INTO results VALUES ('$build_name', '$host', '$kvers'" + # Due to 'set -e' a failed test exists the script. + build_and_check setver "setver $kvers" "$log_file" "$results_str" + build_and_check clean "test clean" "$log_file" "$results_str" + build_and_check build "build" "$log_file" "$results_str" + + # If we got here, all was well. + echo "$results_str, 0, 'complete', '$log_file');" | $SQLITE $DB +} + +case "$1" in +init) + mkdir -p $LOGS_DIR + cat <&2 "$0: Unknown command '$1'. Aborting." + exit 1 +esac diff --git a/build_tools/test_kernel_git b/build_tools/test_kernel_git index a0610cf..e6bf083 100755 --- a/build_tools/test_kernel_git +++ b/build_tools/test_kernel_git @@ -12,6 +12,8 @@ usage() { echo " $me checkout Pull a kernel version into " echo " $me update Update (pull) the kernel tree." echo " $me setver Set the kernel version" + echo " $me versions Print available versions" + echo " $me version Print current (kernel) version" echo " $me build Test-build" echo " $me git Run " echo "" @@ -62,14 +64,20 @@ case "$command" in cd "$kernel_dir" git tag -l $2 | cut -c2- ;; + version) + cd "$kernel_dir" + echo "Configured: $kernel_ver" + echo -n "Actual: " + git describe | cut -c2- + ;; setver) kernel_ver="$2" tag="v$kernel_ver" cd "$kernel_dir" git-reset --hard "$tag" - make clean - make defconfig prepare - make SUBDIRS=scripts # generate scripts/mod/modpost + make distclean + make defconfig modules_prepare + #make SUBDIRS=scripts # generate scripts/mod/modpost set_var kernel_ver "$kernel_ver" ;; test|build) @@ -78,7 +86,6 @@ case "$command" in # 1. Set th value of MAKE_PARAMS in git_test.conf . # 2. Any extra command-line parameter. shift - make KSRC="$kernel_dir" KVERS=$kernel_ver $MAKE_PARAMS clean make KSRC="$kernel_dir" KVERS=$kernel_ver $MAKE_PARAMS "$@" ;; *) -- cgit v1.2.3