"Fossies" - the Fresh Open Source Software Archive

Member "libcdio-2.1.0/test/check_iso_read.sh.in" (12 Aug 2018, 7363 Bytes) of package /linux/privat/libcdio-2.1.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 #
    3 # check_iso_read.sh
    4 #
    5 # Author: Leo Baschy
    6 # Some small adaptions made to make it work in libcdio's test suite by
    7 # rocky.
    8 #
    9 # takes zero, one, or two optional parameters in any order
   10 #
   11 # ONE optional parameter:
   12 # an integer number for approximate size of .iso file in megabytes,
   13 # default is 1, for 1 megabyte,
   14 # to test approximately 5 gigabytes pass 5000
   15 #
   16 # OTHER optional parameter:
   17 # the iso-read command you want to test,
   18 # default is iso-read,
   19 # has to be named iso-read to be recognized,
   20 # could be for example src/iso-read
   21 #
   22 # Set environment variable VERBOSE=1 for more verbose output
   23 
   24 RM='@RM@'
   25 VERBOSE=${VERBOSE:-0}
   26 
   27 # Run $@ capturing output. Show output on an error or if VERBOSE is
   28 # set.
   29 run_cmd() {
   30     output=`$@ 2>&1`
   31     if [ $? -ne 0  -o $VERBOSE -ne 0 ]; then
   32     echo >&2 -- $output
   33     fi
   34 }
   35 
   36 # Remove file $1 if that file exists
   37 rm_if_exists() {
   38     file=$1
   39     [ -f $file ] && $RM $file
   40 }
   41 
   42 # Remove driectory $1 if that directory exists
   43 rmdir_if_exists() {
   44     dir=$1
   45     [ -d $dir ] && $RM -r $dir
   46 }
   47 
   48 cleanup() {
   49     for i in 0 1 2 3 4 5 6 7 8 9 ; do
   50     rm_if_exists 1Mfile${i}s-read.txt
   51     done
   52     for file in exampleIso1M.iso exampleIso1M.iso.tar.gz; do
   53     rm_if_exists $file
   54     done
   55     rmdir_if_exists exampleIso1M.iso.prep
   56 }
   57 
   58 # in $1 or $2 accept integer number as total .iso size in megabytes
   59 case "$1" in
   60     [0-9]* )
   61         size="$1" ;;
   62     *)
   63         case "$2" in
   64             [0-9]* )
   65                size="$2" ;;
   66         *)
   67           size="1" ;; # default
   68         esac
   69         ;;
   70 esac
   71 
   72 # in $1 or $2 accept a different location for iso-read,
   73 # e.g. ~/libcdio/src/iso-read
   74 case "$1" in
   75     iso-read )
   76         ISO_READ="$1" ;;
   77     *)
   78         case "$2" in
   79         iso-read )
   80             ISO_READ="$2" ;;
   81     *)
   82             ISO_READ="../src/iso-read" ;;
   83         esac
   84     ;;
   85 esac
   86 
   87 if [ ! -x ${ISO_READ} ]; then
   88     echo "-- $0: No ${ISO_READ}. Skipping."
   89     exit 77
   90 fi
   91 
   92 echo "-- Going to use ${ISO_READ}."
   93 echo "-- " `$ISO_READ --version`
   94 
   95 # pick for your system,
   96 # on a Mac mkisofs, otherwise people use newer genisoimage
   97 isomakingcommand="@ISO_MAKING_COMMAND@"
   98 if [ -z "$isomakingcommand" ]
   99 then
  100     echo "-- $0: Neither mkisofs nor genisoimage found. Skipping."
  101     exit 77
  102 fi
  103 
  104 echo "-- Working with a $size megabyte large .iso file in $datadir ."
  105 
  106 isoname="exampleIso"$size"M.iso"
  107 
  108 prepdir="prep"
  109 
  110 if [ ! -f "$isoname" ]
  111 then
  112 
  113     echo "-- Going to use " `which "$isomakingcommand"` " to prepare $isoname in $isoname.$prepdir ."
  114 
  115     mkdir "$isoname.$prepdir"
  116     mkdir "$isoname.$prepdir"/mixed
  117 
  118     # a large file with many of the same characters that will compress well
  119     run_cmd dd if=/dev/zero bs=1024 count=$size"00" | tr '\0' '\060' > "$isoname.$prepdir/mixed/file0l.txt"
  120     # a small file we will want to iso-read
  121     echo "content of short text file #0 we are looking for" > "$isoname.$prepdir/mixed/file0s.txt"
  122     # a few times over now
  123     run_cmd dd if=/dev/zero bs=1024 count=$size"00" | tr '\0' '\061' > "$isoname.$prepdir/mixed/file1l.txt"
  124     echo "content of short text file #1 we are looking for" > "$isoname.$prepdir/mixed/fileOneSmall.txt"
  125     run_cmd dd if=/dev/zero bs=1024 count=$size"00" | tr '\0' '\062' > "$isoname.$prepdir/mixed/file2l.txt"
  126     echo "content of short text file #2 we are looking for" > "$isoname.$prepdir/mixed/file2small.txt"
  127     run_cmd dd if=/dev/zero bs=1024 count=$size"00" | tr '\0' '\063' > "$isoname.$prepdir/mixed/file3l.txt"
  128     echo "content of short text file #3 we are looking for" > "$isoname.$prepdir/mixed/file3ThreeSmall.txt"
  129     run_cmd dd if=/dev/zero bs=1024 count=$size"00" | tr '\0' '\064' > "$isoname.$prepdir/mixed/file4l.txt"
  130     echo "content of short text file #4 we are looking for" > "$isoname.$prepdir/mixed/fileFourS.txt"
  131     run_cmd dd if=/dev/zero bs=1024 count=$size"00" | tr '\0' '\065' > "$isoname.$prepdir/mixed/file5l.txt"
  132     echo "content of short text file #5 we are looking for" > "$isoname.$prepdir/mixed/file5small.txt"
  133     run_cmd dd if=/dev/zero bs=1024 count=$size"00" | tr '\0' '\066' > "$isoname.$prepdir/mixed/file6l.txt"
  134     echo "content of short text file #6 we are looking for" > "$isoname.$prepdir/mixed/file6s.txt"
  135     run_cmd dd if=/dev/zero bs=1024 count=$size"00" | tr '\0' '\067' > "$isoname.$prepdir/mixed/file7l.txt"
  136     echo "content of short text file #7 we are looking for" > "$isoname.$prepdir/mixed/fileSevenSmall.txt"
  137     run_cmd dd if=/dev/zero bs=1024 count=$size"00" | tr '\0' '\068' > "$isoname.$prepdir/mixed/file8l.txt"
  138     echo "content of short text file #8 we are looking for" > "$isoname.$prepdir/mixed/file8s.txt"
  139     run_cmd dd if=/dev/zero bs=1024 count=$size"00" | tr '\0' '\069' > "$isoname.$prepdir/mixed/file9l.txt"
  140     echo "content of short text file #9 we are looking for" > "$isoname.$prepdir/mixed/file9s.txt"
  141 
  142     # a potentially huge .iso file, whatever you wrote above
  143     run_cmd "$isomakingcommand" -r -J -T -f -V "EXAMPLEISO"$size"M" -o "$isoname" "$isoname.$prepdir"
  144 
  145     # if you want to archive a test file, this compressed one is much smaller,
  146     # seen 4KB instead of 1MB, seen 5MB instead of 5GB
  147     v_opt=''
  148     [ $VERBOSE -ne 0 ] && v_opt='-v'
  149     tar $v_opt -cf "$isoname.tar" "$isoname"
  150     gzip $v_opt -9 "$isoname.tar"
  151 
  152 else
  153     echo "-- Using existing $isoname ."
  154 fi
  155 
  156 # remind of disk space use
  157 # ls -al
  158 # du -h .
  159 
  160 echo "
  161 -- ----------------------------------------
  162 -- Size $size megabyte .iso file read back:
  163 -- ----------------------------------------
  164 "
  165 for i in 0 1 2 3 4 5 6 7 8 9
  166 do
  167     echo "didn't read file #$i" > $size"Mfile"$i"s-read.txt"
  168 done
  169 #
  170 "$ISO_READ" -i "$isoname" -e "mixed/file0s.txt" -o $size"Mfile0s-read.txt"
  171 "$ISO_READ" -i "$isoname" -e "mixed/fileOneSmall.txt" -o $size"Mfile1s-read.txt"
  172 "$ISO_READ" -i "$isoname" -e "mixed/file2small.txt" -o $size"Mfile2s-read.txt"
  173 "$ISO_READ" -i "$isoname" -e "mixed/file3ThreeSmall.txt" -o $size"Mfile3s-read.txt"
  174 "$ISO_READ" -i "$isoname" -e "mixed/fileFourS.txt" -o $size"Mfile4s-read.txt"
  175 "$ISO_READ" -i "$isoname" -e "mixed/file5small.txt" -o $size"Mfile5s-read.txt"
  176 "$ISO_READ" -i "$isoname" -e "mixed/file6s.txt" -o $size"Mfile6s-read.txt"
  177 "$ISO_READ" -i "$isoname" -e "mixed/fileSevenSmall.txt" -o $size"Mfile7s-read.txt"
  178 "$ISO_READ" -i "$isoname" -e "mixed/file8s.txt" -o $size"Mfile8s-read.txt"
  179 "$ISO_READ" -i "$isoname" -e "mixed/file9s.txt" -o $size"Mfile9s-read.txt"
  180 #
  181 anybad=0
  182 for i in 0 1 2 3 4 5 6 7 8 9
  183 do
  184     readback=`cat $size"Mfile"$i"s-read.txt"`
  185     if [ "$readback" = "content of short text file #$i we are looking for" ]
  186     then
  187         echo "-- file #$i read back OK: $readback"
  188     else
  189         anybad=1
  190         echo "file #$i read DEFECT : $readback"
  191     fi
  192 done
  193 
  194 cleanup
  195 
  196 if [ $anybad -eq 0 ]
  197 then
  198     echo "-- $0: Overall success of $0 :)"
  199 else
  200     echo "$0: Overall FAILURE of $0 :("
  201 fi
  202 
  203 exit $anybad
  204 
  205 # if it worked correctly you should see the lines we wrote into the short files:
  206 #
  207 # content of short text file #i we are looking for
  208 #
  209 # IF however defect https://savannah.gnu.org/bugs/?39373 is still
  210 # in effect you might see lines such as:
  211 # 111111111111111111111111111111111111
  212 #
  213 # furthermore, IF however defect https://savannah.gnu.org/bugs/?39354 is still
  214 # in effect you might see lines such as:
  215 #
  216 # iso-read: Could not get ISO-9660 file information out of $isoname for file mixed/file2small.txt.
  217 # iso-read: iso-info may be able to show the contents of $isoname.