#!/bin/csh -f
#
# checkparam - tell me whether a given config directory has param
# files that are missing a definition for some parameter.
#
# This is a good idea to run before recompiling any config directory.
# A problem is likely to show up when an old configs directory is 
# compiled after new things have been added to the main source tree; 
# if boolean parameters are not defined, it is as if they are #undef,
# which is not necessarily what you intended.
#
# Part of
#              The STARFISH Parallel file-system simulator
#        (Simulation Tool for Advanced Research in File Systems)
# 
#                               David Kotz
#                           Dartmouth College
#                              Version 3.0
#                              October 1996
#                          dfk@cs.dartmouth.edu

if ($#argv != 2) then 
 echo '\
 usage: checkparam config-dir test-dir\
   The first directory is the config directory in question; \
   the second directory is the development "test" directory, where \
   the latest source can be found. (usually research/dmcache/src/test)'
 exit 1
endif

set configdir=$1
set testdir=$2

if (! -d $configdir) then
    echo $configdir is not a directory
    exit 1
endif

if (! -d $testdir) then
    echo $testdir is not a directory
    exit 1
endif

set configlist=/tmp/checkparam$$a
set testlist=/tmp/checkparam$$b
set out=1
onintr cleanup

# First check the list of param files, to see if there are any new
# ones
(cd $configdir; /bin/ls *.param > $configlist)
(cd $testdir; /bin/ls *.param > $testlist)

if (! { cmp -s $configlist $testlist } ) then
    echo In $configdir, 
    diff $configlist $testlist | sed -n -e 's/>/add/p'  -e 's/</remove/p' 
    goto cleanup
endif

# Then make a list of the parameters in each directory's files:
cat $configdir/*.param | cols 2 | sort > $configlist
cat $testdir/*.param | cols 2 | sort > $testlist

if (! { cmp -s $configlist $testlist } ) then
    echo In $configdir, 
    diff $configlist $testlist | sed -n -e 's/>/add/p'  -e 's/</remove/p' 
    goto cleanup
endif

set out=0

cleanup:
rm -f $configlist $testlist

exit $out
