#!/bin/bash # $HeadURL$ $LastChangedRevision$ PROGNAME=`basename $0` SANDPIT=`pwd` . $(ade-config ade_share_prefix)/include/adetestsupport.sh ############################################################################## # # Purpose of test: to verify that the 'other names' a hard-linked file has # are always put in the same order in a fad record whatever # the order of links in the directory catalogue. # ############################################################################## filter_variant_data() { # Previously here we did not squeeze blanks, but I saw that the indentation # made by Data::Dumper does sometimes vary a little (maybe the terminal itself # had changed size and Data::Dumper was using its width to calculate how # much it should indent?). So now we remove all leading and trailing and # squash the rest to one. # sed -e "s/'\(dev\|inode\|group\|owner\)' => .*/'\1' => BLANKED_BY_$PROGNAME/" \ -e "s/'[0-9][^']*'/'BLANKED_BY_$PROGNAME'/" \ -e "s/\(Unix-Time\): .*/\1: BLANKED_BY_$PROGNAME/" \ -e "s/^ *//g" \ -e "s/ *\$//g" \ -e "s/ */ /g" } invert_rc() { local CMD RC CMD="$1" { sh -c "$CMD" && RC=$?; } || RC=$? [ $RC != 0 ] } echo "creating scanable tree ..." umask 022 mkdir $SANDPIT/root echo one > $SANDPIT/root/file1 echo two > $SANDPIT/root/file2 echo "making two scans each of different input ..." mkdir $SANDPIT/scans ( cd $SANDPIT/root; echo file1 | mkfad ) > scans/file1.fad ( cd $SANDPIT/root; echo file2 | mkfad ) > scans/file2.fad echo "combining scans ..." # We cannot display FAD files since there is no guarantee that the records # will be consistently displayed in the same order. (It's a hash remember!) fadcat scans/* | wc -l echo "combining scans and searching for file1 only ..." # In this case we can cat it because there is only one record. No! No! # To think so is bug FAD-3. The order of records is inconsistent but # *also* the order of attributes within a single records is inconsistent, # therefore not even a single file can be displayed. The best we can # do is to compare it against an empty FAD file. # # Here is what we used to do: # fadcat -g file1 scans/* | filter_variant_data # # And here is what we do now. echo " combining ..." fadcat -g file1 scans/file1.fad scans/file2.fad > scans/file3.fad echo " creating empty fad file ..." mkfad < /dev/null > scans/empty.fad echo " diffing ..." faddiff scans/empty.fad scans/file3.fad || true echo " cleaning ..." rm -f scans/file3.fad scans/empty.fad echo "joining the same file twice to verify clashes detected ..." # Here it is the error message we are interested in. invert_rc "fadcat scans/file1.fad scans/file1.fad > /dev/null" echo "all done"