"Fossies" - the Fresh Open Source Software Archive

Member "dosfstools-4.2/tests/test-label" (31 Jan 2021, 1736 Bytes) of package /linux/misc/dosfstools-4.2.tar.gz:


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 and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 # Copyright (C) 2018  Pali Rohár <pali.rohar@gmail.com>
    3 #
    4 # This program is free software: you can redistribute it and/or modify
    5 # it under the terms of the GNU General Public License as published by
    6 # the Free Software Foundation, either version 3 of the License, or
    7 # (at your option) any later version.
    8 #
    9 # This program is distributed in the hope that it will be useful,
   10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12 # GNU General Public License for more details.
   13 #
   14 # You should have received a copy of the GNU General Public License
   15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
   16 #
   17 #
   18 # This script expects a testname.label file as its sole argument. It must
   19 # be a label of the corresponding hex dump file testname.xxd that can be
   20 # converted to a file system image with xxd.
   21 
   22 
   23 run_label () {
   24     $RUN "../src/fatlabel" "$@"
   25 }
   26 
   27 
   28 if [ $# -ne 1 ]; then
   29     echo "$0 called with wrong number of arguments"
   30     exit 99
   31 fi
   32 testname=$(basename "$1" .label)
   33 
   34 
   35 if [ "$XXD_FOUND" != "yes" ]; then
   36     echo "xxd not available, required by test"
   37     exit 77  # report test skipped
   38 fi
   39 
   40 
   41 echo "Test $testname"
   42 
   43 # make sure there aren't files remaining from earlier run
   44 rm -f "${testname}.img" "${testname}.out"
   45 
   46 xxd -r "${srcdir}/${testname}.xxd" "${testname}.img" || exit 99
   47 run_label "${testname}.img" 1> "${testname}.out" 2> "${testname}.err" || exit 99
   48 
   49 
   50 echo "Comparing..."
   51 diff "${testname}.out" "${srcdir}/${testname}.label"
   52 success=$?
   53 
   54 
   55 echo "Error output:"
   56 cat "${testname}.err"
   57 if [ "$CHECK_ERRORS" = "1" ] && [ -s "${testname}.err" ]; then
   58     success=2
   59 fi
   60 
   61 
   62 rm -f "${testname}.img" "${testname}.out" "${testname}.err"
   63 exit $success