1#!/bin/sh 2: ${srcdir=.} 3. "$srcdir/init.sh"; path_prepend_ . 4 5too_big=99999999999999999999999999999999999999999999999999999999999999999999 6result=0 7 8# test xstrtol 9${CHECKER} test-xstrtol 1 >> out 2>&1 || result=1 10${CHECKER} test-xstrtol -1 >> out 2>&1 || result=1 11${CHECKER} test-xstrtol 1k >> out 2>&1 || result=1 12${CHECKER} test-xstrtol ${too_big}h >> out 2>&1 && result=1 13${CHECKER} test-xstrtol $too_big >> out 2>&1 && result=1 14${CHECKER} test-xstrtol x >> out 2>&1 && result=1 15${CHECKER} test-xstrtol 9x >> out 2>&1 && result=1 16${CHECKER} test-xstrtol 010 >> out 2>&1 || result=1 17# suffix without integer is valid 18${CHECKER} test-xstrtol MiB >> out 2>&1 || result=1 19${CHECKER} test-xstrtol 1bB >> out 2>&1 && result=1 20 21# test xstrtoul 22${CHECKER} test-xstrtoul 1 >> out 2>&1 || result=1 23${CHECKER} test-xstrtoul -1 >> out 2>&1 && result=1 24${CHECKER} test-xstrtoul 1k >> out 2>&1 || result=1 25${CHECKER} test-xstrtoul ${too_big}h >> out 2>&1 && result=1 26${CHECKER} test-xstrtoul $too_big >> out 2>&1 && result=1 27${CHECKER} test-xstrtoul x >> out 2>&1 && result=1 28${CHECKER} test-xstrtoul 9x >> out 2>&1 && result=1 29${CHECKER} test-xstrtoul 010 >> out 2>&1 || result=1 30${CHECKER} test-xstrtoul MiB >> out 2>&1 || result=1 31${CHECKER} test-xstrtoul 1bB >> out 2>&1 && result=1 32 33# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr 34# does not understand '\r'. 35if echo solaris | tr -d '\r' | grep solais > /dev/null; then 36 cr='\015' 37else 38 cr='\r' 39fi 40 41# normalize output 42LC_ALL=C tr -d "$cr" < out > k 43mv k out 44 45# compare expected output 46cat > expected <<EOF 471->1 () 48-1->-1 () 491k->1024 () 50invalid suffix in X argument '${too_big}h' 51X argument '$too_big' too large 52invalid X argument 'x' 53invalid suffix in X argument '9x' 54010->8 () 55MiB->1048576 () 56invalid suffix in X argument '1bB' 571->1 () 58invalid X argument '-1' 591k->1024 () 60invalid suffix in X argument '${too_big}h' 61X argument '$too_big' too large 62invalid X argument 'x' 63invalid suffix in X argument '9x' 64010->8 () 65MiB->1048576 () 66invalid suffix in X argument '1bB' 67EOF 68 69compare expected out || result=1 70 71Exit $result 72