FreeCalypso > hg > tcs211-pirelli
comparison gpf/BIN/MKTC.bat @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 @echo off | |
2 @pushd | |
3 rem --------------------------------------------------------------------------- | |
4 rem Project : | |
5 rem Modul : | |
6 rem --------------------------------------------------------------------------- | |
7 rem Copyright 2002 Texas Instruments Berlin, AG | |
8 rem All rights reserved. | |
9 rem | |
10 rem This file is confidential and a trade secret of Texas | |
11 rem Instruments Berlin, AG | |
12 rem The receipt of or possession of this file does not convey | |
13 rem any rights to reproduce or disclose its contents or to | |
14 rem manufacture, use, or sell anything it may describe, in | |
15 rem whole, or in part, without the specific written consent of | |
16 rem Texas Instruments Berlin, AG. | |
17 rem --------------------------------------------------------------------------- | |
18 rem Purpose : Generate a test case. | |
19 rem --------------------------------------------------------------------------- | |
20 @if x%_4ver% == x goto Need4NT | |
21 | |
22 @rem Check %PROST | |
23 @iff x%PROST == x then | |
24 @echo Which Protocol Stack shall be tested? | |
25 @echo set the environment variable PROST to the name of the stack. | |
26 @echo e.g. set PROST=GSM or set PROST=WARP will work | |
27 @goto end | |
28 @endiff | |
29 | |
30 @rem Check for gnumake | |
31 set gnumake=%GPF%\tools\bin\gnumake.exe | |
32 iff NOT exist %gnumake% then | |
33 echo You need %gnumake% to generate test cases | |
34 goto end | |
35 endiff | |
36 | |
37 @set TC_GENTDS=0 | |
38 set tc_cons_output=0 | |
39 iff "x%TDSCHECK_ENABLED" == "x" then | |
40 set enable_check=0 | |
41 else | |
42 set enable_check=1 | |
43 endiff | |
44 set tc_furtherincludes= | |
45 set tc_testconfig= | |
46 set tc_testdlldir= | |
47 set tc_toolerror=0 | |
48 set tc_testenv=new | |
49 set tc_gendir=%GPF%\util\tap\gen | |
50 set tc_testpref= | |
51 | |
52 @rem Check Parameters | |
53 :check_options | |
54 @if x%1 == x goto How2Use | |
55 @iff "%1" == "-gen" then | |
56 gosub prepare_gen | |
57 if %tc_toolerror% == 1 goto end | |
58 set TC_GENTDS=1 | |
59 shift 1 | |
60 goto check_options | |
61 elseiff "%1" == "-eut" then | |
62 set tc_testconfig=EUT=%@UPPER[%2] | |
63 shift 2 | |
64 goto check_options | |
65 elseiff "%1" == "-tty" then | |
66 set tc_cons_output=1 | |
67 shift 1 | |
68 goto check_options | |
69 elseiff "%1" == "-oe" then | |
70 set tc_gendir=%GPF%\tap | |
71 set tc_testenv=old | |
72 shift 1 | |
73 goto check_options | |
74 elseiff "%1" == "-oed" then | |
75 set tc_gendir=%GPF%\tap | |
76 set tc_testenv=old | |
77 set tc_testpref=oe_ | |
78 shift 1 | |
79 goto check_options | |
80 elseiff "%1" == "-debug" then | |
81 echo on | |
82 shift 1 | |
83 goto check_options | |
84 elseiff "%1" == "-chk" then | |
85 rem Generate tds files first | |
86 set TC_GENTDS=1 | |
87 rem Call TDSCheck after generating tds files | |
88 set enable_check=1 | |
89 shift 1 | |
90 goto check_options | |
91 elseiff "%1" == "-td" then | |
92 if "x%2" == "x" (echo Missing testdll directory for "-td" & goto How2Use) | |
93 set tc_testdlldir=%2 | |
94 shift 2 | |
95 goto check_options | |
96 elseiff "%1" == "-i" then | |
97 if "x%2" == "x" (echo Missing include directory for "-i" & goto How2Use) | |
98 iff "%@INSTR[0,1,%2]" == "." .OR. "%@INSTR[0,1,%2]" == "/" .OR. "%@INSTR[0,1,%2]" == "\" .OR. "%@INSTR[1,1,%2]" == ":" then | |
99 set tc_furtherincludes=%tc_furtherincludes% -I %2 | |
100 else | |
101 set tc_furtherincludes=%tc_furtherincludes% -I %TDSDIR%/%2 | |
102 endiff | |
103 shift 2 | |
104 goto check_options | |
105 endiff | |
106 | |
107 set grep=%GPF%\tools\bin\grep.exe | |
108 iff NOT exist %grep% then | |
109 echo You need %grep% to generate test cases | |
110 set tc_toolerror=1 | |
111 endiff | |
112 | |
113 @if %#% GT 3 goto How2Use | |
114 if "%@INSTR[0,1,%1]" == "-" goto unknown_option | |
115 @if x%2 == x goto How2Use | |
116 iff "x%3" != "x" then | |
117 iff "x%tc_testconfig" != "x" then | |
118 echo Warning: parameter "%3" ignored, because -eut was set | |
119 else | |
120 set tc_testconfig=%@UPPER[%3] | |
121 endiff | |
122 else | |
123 if "x%tc_testconfig" == "x" set tc_testconfig=%@UPPER[%1] | |
124 endiff | |
125 | |
126 @rem Check style of second parameter (e.g. 037 or cc037) | |
127 @set ENTI=%@UPPER[%1] | |
128 @set FC2=%@INSTR[0,1,%2] | |
129 @iff %@NUMERIC[%FC2] == 1 then | |
130 set tc_bnam=%ENTI%%@UPPER[%2] | |
131 @else | |
132 set tc_bnam=%@UPPER[%2] | |
133 @endiff | |
134 set TCBASE=%TDSDIR%\%ENTI%\%tc_bnam% | |
135 | |
136 @if not exist %TCBASE%.tds .AND. not exist %TSTDOCDIR%\%ENTI%.doc goto NoThing | |
137 | |
138 @%TESTDRIVE% | |
139 | |
140 @rem Stack-Specifics | |
141 iff "x%TCDIR%" == "x" then | |
142 iff "%PROST" == "WARP" .OR. "%PROST%" == "g23net" then | |
143 set TCDIR=%BINDIR% | |
144 else | |
145 set TCDIR=%TESTROOT%\%SIDE%\TEST | |
146 endiff | |
147 endiff | |
148 | |
149 iff "x%tc_testdlldir" =="x" then | |
150 iff "x%TCNOTSUBSTRUCT" == "x" then | |
151 set TESTDLLDIR=%TCDIR%\%tc_testpref%%ENTI%_test | |
152 else | |
153 set TESTDLLDIR=%TCDIR% | |
154 endiff | |
155 else | |
156 iff "%@INSTR[0,1,%tc_testdlldir%]" == "." .OR. "%@INSTR[0,1,%tc_testdlldir%]" == "/" .OR. "%@INSTR[0,1,%tc_testdlldir%]" == "\" .OR. "%@INSTR[1,1,%tc_testdlldir%]" == ":" then | |
157 set TESTDLLDIR=%tc_testdlldir% | |
158 else | |
159 set TESTDLLDIR=%TCDIR%\%tc_testdlldir% | |
160 endiff | |
161 endiff | |
162 | |
163 iff NOT exist %TESTDLLDIR% then | |
164 echo "Creating test directory %TESTDLLDIR% ..." | |
165 mkdir /S %TESTDLLDIR% | |
166 endiff | |
167 | |
168 | |
169 rem check if tds directory exists | |
170 @iff NOT exist %TDSDIR%\%ENTI% then | |
171 @echo "Creating test directory %TDSDIR%\%ENTI% ..." | |
172 @mkdir /S %TDSDIR%\%ENTI% | |
173 @endiff | |
174 | |
175 rem Check for tdscheck.exe | |
176 iff %enable_check% == 1 then | |
177 set tdscheck=%GPF%\BIN\tdscheck.exe | |
178 iff NOT EXIST %tdscheck% then | |
179 echo You need %tdscheck% to check your tds files | |
180 goto end | |
181 endiff | |
182 endiff | |
183 | |
184 @if %TC_GENTDS% == 1 goto remake | |
185 | |
186 @if not exist %TCBASE%.tds goto NoSuchFile | |
187 | |
188 @set TC_RESP=n | |
189 @iff exist %TSTDOCDIR%\%ENTI%.doc then | |
190 @iff %@FILEAGE[%TSTDOCDIR%\%ENTI%.doc] gt %@FILEAGE[%TCBASE%.tds] then | |
191 @echo Testdocument %TSTDOCDIR%\%ENTI%.doc is newer than | |
192 @echo test case %TCBASE%.tds. | |
193 @inkey /k"yn" /c Remake it?[yn] %%TC_RESP | |
194 @endiff | |
195 @endiff | |
196 @if %TC_RESP% != y goto compile | |
197 | |
198 :remake | |
199 gosub prepare_gen | |
200 if %tc_toolerror% == 1 goto end | |
201 %doc2txt% %doc2txt_opts% %TSTDOCDIR%\%ENTI%.doc | |
202 rem hack for office 2000 where a blank is inserted after a backslash-newline | |
203 move /q %TSTDOCDIR%\%ENTI%.txt %TSTDOCDIR%\%ENTI%.txt_ | |
204 %sed% -e "s/\\ $/\\/" %TSTDOCDIR%\%ENTI%.txt_ > %TSTDOCDIR%\%ENTI%.txt | |
205 del /q %TSTDOCDIR%\%ENTI%.txt_ > nul | |
206 rem end of hack | |
207 %tdsgen% %TCDIR% %ENTI% %TSTDOCDIR% %TDSDIR%\%ENTI% | |
208 if %tc_cons_output% == 1 type %TDSDIR%\%ENTI%\%ENTI%.err | |
209 @if errorlevel GT 0 goto tdsgenerr | |
210 @if not exist %TCBASE%.tds goto NoTc | |
211 gosub gen_suites | |
212 @iff %enable_check% == 1 then | |
213 call %tdscheck% %TDSDIR%\%ENTI% %ENTI% | |
214 @if errorlevel GT 1 goto tapcheckerrors | |
215 @endiff | |
216 | |
217 :compile | |
218 cd %tc_gendir% | |
219 iff %tc_testenv% == new then | |
220 %grep% SCRIPT_BEGIN %TCBASE%.tds > nul | |
221 iff %? == 0 then | |
222 set tc_testlanguage=TCSL | |
223 else | |
224 set tc_testlanguage=TDS | |
225 endiff | |
226 endiff | |
227 @echo Compiling and Linking Testcase %tc_bnam% | |
228 @set EQINP2=%@WORDS["=",%tc_testconfig] | |
229 @iff %EQINP2% GT 1 then | |
230 set TSTDLLCONF="%tc_testconfig%" | |
231 @else | |
232 set TSTDLLCONF="CONFDLL=%tc_testconfig%" | |
233 @endiff | |
234 set tc_comperror=0 | |
235 %gnumake% -f testdll.mk OUTDLL=%TESTDLLDIR%/%tc_bnam%.DLL %TSTDLLCONF% TSTDOCNAM=%ENTI% TC_NAME=%tc_bnam% TC_FURTHERINCLUDES="%tc_furtherincludes" TC_TESTLANGUAGE=%tc_testlanguage% all > %TCBASE%.err | |
236 iff %tc_cons_output% == 1 then | |
237 if %? != 0 set tc_comperror=1 | |
238 type %TCBASE%.err | |
239 if %tc_comperror% == 0 del /q %TCBASE%.err | |
240 else | |
241 @iff %? == 0 then | |
242 @echo ^sdone. | |
243 @echo Generated Test Case %TESTDLLDIR%\%tc_bnam%.DLL | |
244 del /q %TCBASE%.err | |
245 @else | |
246 @echo See %TCBASE%.err | |
247 @endiff | |
248 @endiff | |
249 | |
250 @goto end | |
251 | |
252 :prepare_gen | |
253 set doc2txt=%GPF%\tools\bin\Doc2txt.exe | |
254 iff NOT exist %doc2txt% then | |
255 echo You need %doc2txt% to generate test cases | |
256 set tc_toolerror=1 | |
257 endiff | |
258 set tdsgen=%GPF%\BIN\tdsGen.exe% | |
259 iff NOT exist %tdsgen% then | |
260 echo You need %tdsgen% to generate test cases | |
261 set tc_toolerror=1 | |
262 endiff | |
263 set doc2txt_opts=-O -w -f wdFormatTextLineBreaks | |
264 set sed=%GPF%\tools\bin\sed.exe | |
265 iff NOT exist %sed% then | |
266 echo You need %sed% to generate tests | |
267 goto error | |
268 endiff | |
269 return | |
270 | |
271 :gen_suites | |
272 %grep% Suites %TSTDOCDIR%\%ENTI%.txt > nul | |
273 iff %? == 0 then | |
274 set gawk=%GPF%\tools\bin\gawk.exe | |
275 set gensuites=%GPF%\BIN\gensuites.awk | |
276 iff NOT EXIST %gensuites% .OR. NOT EXIST %gawk% then | |
277 echo Warning: You need %gensuites% and %gawk% to generate suites | |
278 return | |
279 endiff | |
280 %gawk% -f %gensuites% %TSTDOCDIR%\%ENTI%.txt | tee %TDSDIR%\%ENTI%\%ENTI%.sui > %TESTDLLDIR%\%ENTI%.sui | |
281 echo Generated %TDSDIR%\%ENTI%\%ENTI%.sui | |
282 echo ^s^s^s^s^s^sand %TESTDLLDIR%\%ENTI%.sui | |
283 else | |
284 echo No Suites | |
285 endiff | |
286 return | |
287 | |
288 :NoThing | |
289 @echo What is %ENTI%? | |
290 @echo Neither %TCBASE%.tds | |
291 @echo nor %TSTDOCDIR%\%ENTI%.doc exist! | |
292 @goto end | |
293 | |
294 :NoSuchFile | |
295 @echo "%TCBASE%.tds - no such file!" | |
296 @goto end | |
297 | |
298 :NoTc | |
299 @echo ...nevertheless: a test case "%TCBASE%.tds" does not exist | |
300 @goto end | |
301 | |
302 :tdsgenerr | |
303 iff %?%==2 @echo Parse error in test case document. See %TDSDIR%\%ENTI%\%ENTI%.err | |
304 iff %?%==3 @echo Error while opening file during generation of test cases | |
305 @goto end | |
306 | |
307 :tapcheckerrors | |
308 @echo "tdscheck has found problems in %TSTDOCDIR%\%ENTI%.doc" | |
309 @echo "inspect %TDSDIR%\%ENTI%\%ENTI%.chk" | |
310 @goto end | |
311 | |
312 | |
313 :Need4NT | |
314 @echo "Error: 4DOS or 4NT is needed | |
315 @goto end | |
316 | |
317 :unknown_option | |
318 echo Unknown Option: %1 | |
319 | |
320 :How2Use | |
321 text | |
322 MkTc : Create a DLL containing a Test Case | |
323 Usage : MkTc [-chk] [-gen] [-tty] [-oe] [-oed] [-i <incdir>] [-eut <entity>] [-td <testdlldir>] <Entity> <TestCase> [config] | |
324 -chk : Regenerate tds-Files from Word-Document, then call TDSCheck | |
325 -gen : Regenerate tds-Files from Word-Document | |
326 -tty : write tools output to console | |
327 -i : set <incdir> as additional include directory for test case compilation | |
328 -td : set <testdlldir> as directory for the test cases | |
329 -oe : old environment; generate test case for Tap on old frame | |
330 -oed: same as -oe, but create test cases in a differently named directory | |
331 -eut : same as EUT=<entity> as last parameter | |
332 config : EUT=<entity> where the names of testdoc and entity differ | |
333 Example : MkTc CC [CC]001 | |
334 endtext | |
335 | |
336 :end | |
337 @popd |