mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
212 lines
6.1 KiB
Text
212 lines
6.1 KiB
Text
# 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"
|