2 # ***************************************************************************
4 # * Project ___| | | | _ \| |
5 # * / __| | | | |_) | |
6 # * | (__| |_| | _ <| |___
7 # * \___|\___/|_| \_\_____|
9 # * Copyright (C) 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
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 http://curl.haxx.se/docs/copyright.html.
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.
19 # * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # * KIND, either express or implied.
22 # ***************************************************************************
25 # This Bourne shell script file is used by test case 1221 to do
26 # unit testing of curl_10char_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.
35 if test $# -eq 1; then
38 echo "Usage: ${0} srcdir"
42 if test -f "${1}/runtests.pl"; then
45 echo "${0}: Wrong srcdir"
51 if test -f "$srcdir/../lib/objnames.inc"; then
54 echo "$0: Missing objnames.inc"
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
72 # Source curl_10char_object_name() function definition
75 . $srcdir/../lib/objnames.inc
78 # Some curl_10char_object_name() unit tests
81 echo 'Testing curl_10char_object_name...'
84 argstr=123__678__ABC__FGH__KLM__PQRSTUV
86 outstr=`curl_10char_object_name $argstr`
87 echo "result: $outstr expected: $expect input: $argstr"
89 argstr=123__678__ABC__FGH__KLM__PQ.S.UV
91 outstr=`curl_10char_object_name $argstr`
92 echo "result: $outstr expected: $expect input: $argstr"
94 argstr=123__678__ABC..FGH..KLM..PQRSTUV
96 outstr=`curl_10char_object_name $argstr`
97 echo "result: $outstr expected: $expect input: $argstr"
99 argstr=123__678_.ABC._FGH__KLM__PQRSTUV
101 outstr=`curl_10char_object_name $argstr`
102 echo "result: $outstr expected: $expect input: $argstr"
104 argstr=123.567.90ABCDEFGHIJKLMNOPQRSTUV
106 outstr=`curl_10char_object_name $argstr`
107 echo "result: $outstr expected: $expect input: $argstr"
109 argstr=1234567.90A.CDEFGHIJKLMNOPQRSTUV
111 outstr=`curl_10char_object_name $argstr`
112 echo "result: $outstr expected: $expect input: $argstr"
114 argstr=1234567890.BCD.FGHIJKLMNOPQRSTUV
116 outstr=`curl_10char_object_name $argstr`
117 echo "result: $outstr expected: $expect input: $argstr"
119 argstr=12=45-78+0AB.DE.GHIJKLMNOPQRSTUV
121 outstr=`curl_10char_object_name $argstr`
122 echo "result: $outstr expected: $expect input: $argstr"
124 argstr=1234567890ABCDEFGHIJKLMNOPQRSTUV
126 outstr=`curl_10char_object_name $argstr`
127 echo "result: $outstr expected: $expect input: $argstr"
129 argstr=123_567_90A_CDE_GHIJKLMNOPQRSTUV
131 outstr=`curl_10char_object_name $argstr`
132 echo "result: $outstr expected: $expect input: $argstr"
134 argstr=123_567_90A_CDEFGHIJKLMNOPQRSTUV
136 outstr=`curl_10char_object_name $argstr`
137 echo "result: $outstr expected: $expect input: $argstr"
139 argstr=123_567_90ABCDEFGHIJKLMNOPQRSTUV
141 outstr=`curl_10char_object_name $argstr`
142 echo "result: $outstr expected: $expect input: $argstr"
144 argstr=123_567890ABCDEFGHIJKLMNOPQRSTUV
146 outstr=`curl_10char_object_name $argstr`
147 echo "result: $outstr expected: $expect input: $argstr"
149 argstr=1234567890ABCDEFGHIJKLMNOPQRSTUV
151 outstr=`curl_10char_object_name $argstr`
152 echo "result: $outstr expected: $expect input: $argstr"
155 # Verify that generated object name is distinct for
156 # all *.c source files in lib and src subdirectories.
159 ls $srcdir/../lib/*.c > $list_c
160 ls $srcdir/../src/*.c >> $list_c
164 for c_fname in `cat $list_c`; do
165 obj_name=`curl_10char_object_name $c_fname`
166 echo "$obj_name" >> $list_obj
169 sort -u $list_obj > $list_obj_uniq
171 cnt_c=`cat $list_c | wc -l`
172 cnt_u=`cat $list_obj_uniq | wc -l`
177 if test $cnt_c -eq $cnt_u; then
178 echo "10-characters-or-less generated object names are unique."
181 echo "10-characters-or-less generated object names are clashing..."
185 if test $obj_name_clash = "yes"; then
187 # Show clashing object names and respective source file names
190 paste $list_obj $list_c | sort > $list_obj_c
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
208 prev_obj_name=$obj_name
217 # end of objnames-test10.sh