comparison gpf/BIN/mktchier.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 setlocal
3 rem ---------------------------------------------------------------------------
4 rem Project :
5 rem Modul : mktchier.bat
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 test case hierarchy.
19 rem ---------------------------------------------------------------------------
20 set tc_exitcode=0
21 loadbtm on
22 @pushd
23 @if x%_4ver% == x goto Need4NT
24
25 @rem Check %PROST
26 @iff x%PROST == x then
27 @echo Set the environment variable PROST to the name of the stack.
28 @echo e.g. set PROST=GSM or set PROST=WARP will work
29 goto error
30 @endiff
31
32 @rem Check for gnumake and grep
33 set grep=%GPF%\tools\bin\grep.exe
34 iff NOT exist %grep% then
35 echo You need %grep% to generate a test hierarchy
36 goto error
37 endiff
38 set sed=%GPF%\tools\bin\sed.exe
39 iff NOT exist %sed% then
40 echo You need %sed% to generate a test hierarchy
41 goto error
42 endiff
43 rem set gawk but check it later only if it is needed
44 set gawk=%GPF%\tools\bin\gawk.exe
45
46 set TC_FINALTESTS=0
47 :check_options
48 iff "%1" == "-f" then
49 rem Check for several tools in %PATH
50 set uniq=%GPF%\tools\bin\uniq.exe
51 set sort=%GPF%\tools\bin\sort.exe
52 iff NOT exist %uniq% then
53 echo You need %uniq% to generate a test hierarchy for final tests
54 goto error
55 endiff
56 iff NOT exist %sort% then
57 echo You need %sort% to generate a test hierarchy for final tests
58 goto error
59 endiff
60 iff NOT exist %gawk% then
61 echo You need %gawk% to generate a test hierarchy for final tests
62 goto error
63 endiff
64 iff %tc_gen_only% == 1 then
65 echo Use of "-f" ignored because "-to" was set
66 else
67 set TC_FINALTESTS=1
68 endiff
69 shift 1
70 goto check_options
71 endiff
72
73 @if %#% != 1 goto How2Use
74 if "%@INSTR[0,1,%1]" == "-" goto unknown_option
75
76 set ENTI=%@LOWER[%1]
77 if "x%tc_bnam%" == "x" set tc_bnam=%ENTI%
78
79 @rem Stack-Specifics
80 iff "x%TCDIR%" == "x" then
81 iff "%PROST" == "WARP" .OR. "%PROST%" == "g23net" then
82 set TCDIR=%BINDIR%
83 else
84 set TCDIR=%TESTROOT%\%SIDE%\TEST
85 endiff
86 endiff
87
88 %TESTDRIVE%
89
90 @if NOT exist %TDSDIR%\%ENTI%\*.tds goto NoTds
91 cd %TDSDIR%\%ENTI%
92 set tc_pream=%ENTI%_pream.txt
93 set tc_hier=%ENTI%_hier.txt
94 if exist %tc_hier% del /q %tc_hier%
95
96 iff %TC_FINALTESTS% == 1 then
97 set tc_nonfdummy=%ENTI%_nonfdummy.txt
98 if exist %tc_nonfdummy% del /q %tc_nonfdummy
99 %grep% -hi "#include.*tds" *.tds | %sed% -e "s/#include \"\([a-zA-Z0-9]*\).*\"/\1.td_/" > %tc_nonfdummy%
100 %grep% -Li "#include.*tds" *.tds | %sed% -e "s/.*\\//" -e "s/tds/td_/" >> %tc_nonfdummy
101 %sort% < %tc_nonfdummy% | %uniq% | %gawk% -- "{ print $1 > $1 }"
102 del /q %tc_nonfdummy
103 endiff
104
105 FOR %tcase IN (*.tds) do (
106 set act_file=%tcase%
107 gosub print_hier
108 )
109
110 goto clean_up
111
112 :print_hier
113 set tcname=%@NAME[%act_file%]
114 if EXIST %tcname%.td_ return
115
116 echo. >> %tc_hier%
117 echos %tcname% >> %tc_hier%
118 %grep% TITLE %act_file% | %sed% -e "s/TITLE://" >> %tc_hier%
119 :next_file
120 %grep% -hi "#include.*tds" %act_file% | %sed% -e "s/#include \"\([a-zA-Z0-9]*.*\)\"/\1/" > %tc_pream%
121 set file_handle=%@FILEOPEN[%tc_pream%,read]
122 if %file_handle == -1 return
123 set act_file=%@FILEREAD[%file_handle%]
124 set file_handle=%@FILECLOSE[%file_handle%]
125 iff %act_file% == **EOF** then
126 return
127 else
128 echos ^s^s%@NAME[%act_file%] >> %tc_hier%
129 %grep% TITLE %act_file% | %sed% -e "s/TITLE://" >> %tc_hier%
130 goto next_file
131 endiff
132
133 :clean_up
134 echo Generated test case hierarchy in %TDSDIR%\%ENTI%\%tc_hier%
135 if exist %tc_pream% del /q %tc_pream%
136 if exist *.td_ del /q *.td_
137 goto end
138
139 :NoDoc
140 @echo "%TSTDOCDIR%\%ENTI%.doc does not exist"
141 goto error
142
143 :NoTds
144 @echo "No tds-Files in %TDSDIR%\%ENTI%"
145 goto error
146
147 :Need4NT
148 @echo "Error: 4DOS or 4NT is needed
149 goto error
150
151 :unknown_option
152 echo Unknown Option: %1
153
154 :How2Use
155 text
156 mktchier : Get test case hierarchy
157 Usage : mktchier [-f] <TDOC>
158 Example : mktchier CC - creates test case hierarchy for CC
159 -f: consider final tests only
160 endtext
161
162 :error
163 set tc_exitcode=1
164
165 :end
166 endlocal
167 popd
168 quit %tc_exitcode%