Annotation of embedaddon/curl/tests/objnames-test08.sh, revision 1.1
1.1 ! misho 1: #!/bin/sh
! 2: # ***************************************************************************
! 3: # * _ _ ____ _
! 4: # * Project ___| | | | _ \| |
! 5: # * / __| | | | |_) | |
! 6: # * | (__| |_| | _ <| |___
! 7: # * \___|\___/|_| \_\_____|
! 8: # *
! 9: # * Copyright (C) 2013 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
! 10: # *
! 11: # * This software is licensed as described in the file COPYING, which
! 12: # * you should have received as part of this distribution. The terms
! 13: # * are also available at https://curl.haxx.se/docs/copyright.html.
! 14: # *
! 15: # * You may opt to use, copy, modify, merge, publish, distribute and/or sell
! 16: # * copies of the Software, and permit persons to whom the Software is
! 17: # * furnished to do so, under the terms of the COPYING file.
! 18: # *
! 19: # * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
! 20: # * KIND, either express or implied.
! 21: # *
! 22: # ***************************************************************************
! 23:
! 24: #
! 25: # This Bourne shell script file is used by test case 1222 to do
! 26: # unit testing of curl_8char_object_name() shell function which
! 27: # is defined in file objnames.inc and sourced by this file and
! 28: # any other shell script that may use it.
! 29: #
! 30:
! 31: #
! 32: # argument validation
! 33: #
! 34:
! 35: if test $# -eq 1; then
! 36: :
! 37: else
! 38: echo "Usage: ${0} srcdir"
! 39: exit 1
! 40: fi
! 41:
! 42: if test -f "${1}/runtests.pl"; then
! 43: :
! 44: else
! 45: echo "${0}: Wrong srcdir"
! 46: exit 1
! 47: fi
! 48:
! 49: srcdir=${1}
! 50:
! 51: if test -f "$srcdir/objnames.inc"; then
! 52: :
! 53: else
! 54: echo "$0: Missing objnames.inc"
! 55: exit 1
! 56: fi
! 57:
! 58: #
! 59: # Some variables
! 60: #
! 61:
! 62: logdir=log
! 63: tstnum=1222
! 64:
! 65: list_c=$logdir/${tstnum}_list_c
! 66: list_obj=$logdir/${tstnum}_list_obj
! 67: list_obj_c=$logdir/${tstnum}_list_obj_c
! 68: list_obj_uniq=$logdir/${tstnum}_list_obj_uniq
! 69:
! 70:
! 71: #
! 72: # Source curl_8char_object_name() function definition
! 73: #
! 74:
! 75: . $srcdir/objnames.inc
! 76:
! 77: #
! 78: # Some curl_8char_object_name() unit tests
! 79: #
! 80:
! 81: echo 'Testing curl_8char_object_name...'
! 82: echo ""
! 83:
! 84: argstr=123__678__ABC__FGH__KLM__PQRSTUV
! 85: expect=16AFKPQR
! 86: outstr=`curl_8char_object_name $argstr`
! 87: echo "result: $outstr expected: $expect input: $argstr"
! 88:
! 89: argstr=123__678__ABC__FGH__KLM__PQ.S.UV
! 90: expect=16AFKPQ
! 91: outstr=`curl_8char_object_name $argstr`
! 92: echo "result: $outstr expected: $expect input: $argstr"
! 93:
! 94: argstr=123__678__ABC..FGH..KLM..PQRSTUV
! 95: expect=16ABC
! 96: outstr=`curl_8char_object_name $argstr`
! 97: echo "result: $outstr expected: $expect input: $argstr"
! 98:
! 99: argstr=123__678_.ABC._FGH__KLM__PQRSTUV
! 100: expect=16
! 101: outstr=`curl_8char_object_name $argstr`
! 102: echo "result: $outstr expected: $expect input: $argstr"
! 103:
! 104: argstr=123.567.90ABCDEFGHIJKLMNOPQRSTUV
! 105: expect=123
! 106: outstr=`curl_8char_object_name $argstr`
! 107: echo "result: $outstr expected: $expect input: $argstr"
! 108:
! 109: argstr=1234567.90A.CDEFGHIJKLMNOPQRSTUV
! 110: expect=1234567
! 111: outstr=`curl_8char_object_name $argstr`
! 112: echo "result: $outstr expected: $expect input: $argstr"
! 113:
! 114: argstr=1234567890.BCD.FGHIJKLMNOPQRSTUV
! 115: expect=12345678
! 116: outstr=`curl_8char_object_name $argstr`
! 117: echo "result: $outstr expected: $expect input: $argstr"
! 118:
! 119: argstr=12=45-78+0AB.DE.GHIJKLMNOPQRSTUV
! 120: expect=1470AB
! 121: outstr=`curl_8char_object_name $argstr`
! 122: echo "result: $outstr expected: $expect input: $argstr"
! 123:
! 124: argstr=1234567890ABCDEFGHIJKLMNOPQRSTUV
! 125: expect=12345678
! 126: outstr=`curl_8char_object_name $argstr`
! 127: echo "result: $outstr expected: $expect input: $argstr"
! 128:
! 129: argstr=123_567_90A_CDE_GHIJKLMNOPQRSTUV
! 130: expect=159CGHIJ
! 131: outstr=`curl_8char_object_name $argstr`
! 132: echo "result: $outstr expected: $expect input: $argstr"
! 133:
! 134: argstr=123_567_90A_CDEFGHIJKLMNOPQRSTUV
! 135: expect=159CDEFG
! 136: outstr=`curl_8char_object_name $argstr`
! 137: echo "result: $outstr expected: $expect input: $argstr"
! 138:
! 139: argstr=123_567_90ABCDEFGHIJKLMNOPQRSTUV
! 140: expect=1590ABCD
! 141: outstr=`curl_8char_object_name $argstr`
! 142: echo "result: $outstr expected: $expect input: $argstr"
! 143:
! 144: argstr=123_567890ABCDEFGHIJKLMNOPQRSTUV
! 145: expect=1567890A
! 146: outstr=`curl_8char_object_name $argstr`
! 147: echo "result: $outstr expected: $expect input: $argstr"
! 148:
! 149: argstr=1234567890ABCDEFGHIJKLMNOPQRSTUV
! 150: expect=12345678
! 151: outstr=`curl_8char_object_name $argstr`
! 152: echo "result: $outstr expected: $expect input: $argstr"
! 153:
! 154: #
! 155: # Verify that generated object name is distinct for
! 156: # all *.c source files in lib and src subdirectories.
! 157: #
! 158:
! 159: ls $srcdir/../lib/*.c > $list_c
! 160: ls $srcdir/../src/*.c >> $list_c
! 161:
! 162: rm -f $list_obj
! 163:
! 164: for c_fname in `cat $list_c`; do
! 165: obj_name=`curl_8char_object_name $c_fname`
! 166: echo "$obj_name" >> $list_obj
! 167: done
! 168:
! 169: sort -u $list_obj > $list_obj_uniq
! 170:
! 171: cnt_c=`cat $list_c | wc -l`
! 172: cnt_u=`cat $list_obj_uniq | wc -l`
! 173:
! 174: echo ""
! 175: echo ""
! 176: echo ""
! 177: if test $cnt_c -eq $cnt_u; then
! 178: echo "8-characters-or-less generated object names are unique."
! 179: obj_name_clash="no"
! 180: else
! 181: echo "8-characters-or-less generated object names are clashing..."
! 182: obj_name_clash="yes"
! 183: fi
! 184:
! 185: if test $obj_name_clash = "yes"; then
! 186: #
! 187: # Show clashing object names and respective source file names
! 188: #
! 189: echo ""
! 190: paste $list_obj $list_c | sort > $list_obj_c
! 191: prev_match="no"
! 192: prev_line="unknown"
! 193: prev_obj_name="unknown"
! 194: while read this_line; do
! 195: obj_name=`echo "$this_line" | cut -f1`
! 196: if test "x$obj_name" = "x$prev_obj_name"; then
! 197: if test "x$prev_match" != "xyes"; then
! 198: echo "$prev_line"
! 199: echo "$this_line"
! 200: prev_match="yes"
! 201: else
! 202: echo "$this_line"
! 203: fi
! 204: else
! 205: prev_match="no"
! 206: fi
! 207: prev_line=$this_line
! 208: prev_obj_name=$obj_name
! 209: done < $list_obj_c
! 210: fi
! 211:
! 212: rm -f $list_c
! 213: rm -f $list_obj
! 214: rm -f $list_obj_c
! 215: rm -f $list_obj_uniq
! 216:
! 217: # end of objnames-test.sh
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>