From d9db3cd6c49aec5dea17876992812af0c3d3b6f1 Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Mon, 7 Jan 2002 17:09:23 +0000 Subject: [PATCH] Jan Kok's fixes. --- util/config/LBCtest | 212 +++++++++++++++++++++++++++++++ util/config/LBCtest-config-files | 28 ++++ 2 files changed, 240 insertions(+) create mode 100644 util/config/LBCtest create mode 100644 util/config/LBCtest-config-files diff --git a/util/config/LBCtest b/util/config/LBCtest new file mode 100644 index 0000000000..fbf0c72e2d --- /dev/null +++ b/util/config/LBCtest @@ -0,0 +1,212 @@ +# This is a regression test for the NLBConfig tool. + +# Set this to the top of your LinuxBIOS tree. +# Should be an absolute path ("~" at the beginning is OK). +top=~/src/bios/freebios + +# How the old and new tools to be compared are invoked. +# Make sure this works regardless of current directory ($PWD). +old_tool="python $top/util/config/NLBConfig.py" +new_tool="$top/util/config/NLBConfig" + +# Do we need to make the target (build) directory before running the tools? +# Should be 0 or 1. +mkdir_target_old=1 +mkdir_target_new=0 + +# Want to reduce noise in diff output? Set to 0 if old_tool and new_tool +# should give similar Makefiles. Set to 1 if there are large differences. +dolby=1 + +# Where the test results will be stored. +# The structure will be +# $results_dir/ +# old/ +# 1/ +# test-config (the top-level config file that is run for this test) +# test-out (stdout of config tool) +# test-err (stderr of config tool) +# Makefile, Makefile.settings, etc. (the files generated by the tool) +# 2/... +# 3/... (etc., one directory for each config file tested.) +# new/ (similar structure to old.) +results_dir=$top/LBCtest-res + +# Name for target directory. +# WARNING: ~/$target_dir, /tmp/$target_dir and $top/$target_dir will be +# removed along with their contents and recreated. +target_dir=LBCtest-rundir + +# Config file name to be fed to the config tools. +test_config_name=LBCtest-config + +# This file should contain a list of config files to test. The file names +# should be relative to $top. For example, the file could contain: +# util/config/via.config +# src/mainboard/rcn/dc1100s/Example.config +# (without the "#" signs, of course). +config_files=$top/util/config/LBCtest-config-files + +# Check that directories we want to create don't exist yet. +function should_not_exist +{ + what="$1" + path=$2 + option=$3 + + if [ -e $path ] + then + echo "The $what already exists. Please check carefully, then" + echo "rm $option$path" + echo "or move it aside." + exit 1 + fi +} + +function run_test +{ + invoke_tool="$1" + mkdir_target=$2 + target_prefix="$3" # may be null + results_subdir=$4 + config_file=$5 + + the_target_dir=$target_prefix$target_dir + config_source=$top/$config_file + config_testfile=$target_prefix$test_config_name + the_results_dir=$results_dir/$results_subdir + + if [ $mkdir_target != 0 ] + then + mkdir $the_target_dir + if [ $? != 0 ] + then + echo "Couldn't create target directory $the_target_dir" + echo "I give up..." + exit 1 + fi + fi + + mkdir $the_results_dir + if [ $? != 0 ] + then + echo "Couldn't create result subdirectory $the_results_dir" + echo "This is too wierd, I'm outa here." + exit 1 + fi + + # Create a config file to crunch on. Add in some comments at the top. + { + echo "# source of this config file is: $config_source" + echo "# working directory (PWD) is $PWD" + + invocation="$invoke_tool $config_testfile $top" + echo "# test will run as: $invocation" + echo + + # "sed" the source config file to replace the target dir with + # what we want. + regx="s%^[ \t]*target.*$%target $the_target_dir%" + # echo "regx='$regx'" >&2 + sed -e "$regx" $config_source + + } > $config_testfile + # echo "sed result=`grep '^target ' $config_testfile`" + + # Call the config program. + $invocation > /tmp/LBCtest-out 2> /tmp/LBCtest-err + + # Move test results to results dir. + mv $the_target_dir/* $the_results_dir + mv $config_testfile $the_results_dir/test-config + mv /tmp/LBCtest-out $the_results_dir/test-out + mv /tmp/LBCtest-err $the_results_dir/test-err + if true #[ -d $the_target_dir ] + then : + else + echo "***** No target directory '$the_target_dir' was created! *****" + fi + + if [ -f $the_results_dir/Makefile ] + then + if [ $dolby != 0 ] + then + # This is optional... If there are a lot of differences in the + # Makefiles, the following sort and grep can reduce the noise. + sort -o $the_results_dir/Makefile $the_results_dir/Makefile + mv $the_results_dir/Makefile $the_results_dir/Mfl + grep -v "# from\|^$\|^SOURCES " $the_results_dir/Mfl > $the_results_dir/Makefile + rm $the_results_dir/Mfl + fi + else + echo "***** Oops, no Makefile generated! *****" + fi + + # Clean up. + rmdir $the_target_dir +} + + +##### Do some sanity checks before running tests. ##### + +if [ ! -d $top ] +then + echo "The 'top' directory $top does not exist." + echo "Please check the number and try your call again." + exit 1 +fi + +# Most of the tests will be run from $top. +cd $top + +if [ ! -r $config_files ] +then + echo "The file containing the list of config files to test," + echo "$config_files was not found" + echo "Do not pass GO, do not collect \$200." + exit 1 +fi + +# Check directories. +should_not_exist "results directory" $results_dir "-rf " +should_not_exist "target directory" $top/$target_dir "-rf " +should_not_exist "target directory" ~/$target_dir "-rf " +should_not_exist "target directory" /tmp/$target_dir "-rf " + +# Check files. +should_not_exist "config file" $top/$test_config_name "" +should_not_exist "config file" ~/$test_config_name "" +should_not_exist "config file" /tmp/$test_config_name "" + + +##### Run the tests ##### + +# Create the results directories. +mkdir $results_dir $results_dir/old $results_dir/new + +# Initialize the test number. +result_num=1 + +for cf in `< $config_files` +do + echo "Test $result_num: $cf" + run_test "$old_tool" $mkdir_target_old "" old/$result_num $cf + run_test "$new_tool" $mkdir_target_new "" new/$result_num $cf + let result_num=($result_num + 1) + save_cf=$cf +done + +echo "Test $result_num: Re-running the last test from /tmp with target as ~/$target_dir" +cd /tmp +run_test "$old_tool" $mkdir_target_old ~/ old/$result_num $save_cf +run_test "$new_tool" $mkdir_target_new ~/ new/$result_num $save_cf +let result_num=($result_num + 1) + +echo "Test $result_num: Re-running the last test from ~ with target as /tmp/$target_dir" +cd ~ +run_test "$old_tool" $mkdir_target_old /tmp/ old/$result_num $save_cf +run_test "$new_tool" $mkdir_target_new /tmp/ new/$result_num $save_cf +let result_num=($result_num + 1) + +echo "All config files ran. Check results by doing" +echo "cd $results_dir ; diff -ryw --suppress-common-lines old new | more" diff --git a/util/config/LBCtest-config-files b/util/config/LBCtest-config-files new file mode 100644 index 0000000000..006bc8cec7 --- /dev/null +++ b/util/config/LBCtest-config-files @@ -0,0 +1,28 @@ +util/config/sis550.config +util/config/winfast.config +util/config/l440gx.config +util/config/viavt5426.config +util/config/winfast-test12.config +util/config/pcchips.config +util/config/matsonic.config +util/config/sis540.config +util/config/ds10.config +util/config/asus_cua_doc.config +util/config/via.config +util/config/l440bx-test12.config +src/mainboard/irobot/proto1/proto1.config.example +src/mainboard/pcchips/m810lmr/example.tftpboot.config +src/mainboard/rcn/dc1100s/Example.config +src/mainboard/tyan/s1846/sample_config +src/mainboard/lanner/em-370/example.config +src/mainboard/asus/cua/config.DoC +src/mainboard/asus/cua/SampleConfig.config +src/mainboard/digitallogic/smartcore-p5/config.example +src/mainboard/technoland/sbc710/config.example +src/mainboard/gigabit/ga-6bxc/ga-6bxc.config.example +src/mainboard/matsonic/ms7308e/example.tftpboot.config +src/mainboard/ibm/t23/config.example +util/config/test2 +util/config/test3 +util/config/test4 +util/config/test5