@@ -141,122 +141,26 @@ def <sFuncName>_generic(<sVal>: <sTasName>, filename: str) -> Union[int, Asn1Scc
141141/* Encode Decode End*/
142142
143143PrintMain(sTestSuiteFilename) ::= <<
144- import sys
145- import pathlib
146- sys.path.insert(0, str(pathlib.Path(__file__).parent.parent.parent))
147-
148- from testsuite import asn1scc_run_generated_testsuite, TestOutput
149-
150- def printf_tests_failed(testCount: int, failedCount: int):
151- print(f"[test failed] {failedCount} out of {testCount} failed.")
152-
153-
154- def printf_tests_passed(testCount: int):
155- print(f"[test success] All test cases ({testCount}) run successfully.")
156-
157-
158- def printf_null() -> None:
159- pass
160-
161- def printf_null_char(s: str):
162- pass
163-
164- def printf_message(message: str):
165- print(f"{message}")
166-
167- def print_test_case_success(message: str, duration: int):
168- print(f"test case '{message}' succeeded, duration was \t\t\t\t{duration} ms")
169-
170- if __name__ == "__main__":
171- output = TestOutput(
172- report_tests_failed = printf_tests_failed,
173- report_all_tests_passed = printf_tests_passed,
174- report_suite_begin = printf_null,
175- report_suite_end = printf_null,
176- report_case_begin = printf_null_char,
177- report_case_end = printf_null,
178- report_failure_begin = printf_null,
179- report_failure_end = printf_null,
180- report_failure_message = printf_message,
181- report_test_case_success = print_test_case_success
182- )
183-
184- res = asn1scc_run_generated_testsuite(output)
185- System.exit(res)
186144>>
187145
188146
189147
190148
191149
192150PrintSuite_call_codec_generate_dat_file(sModName, sTasName, sAmber, sEnc, sStreamName) ::= <<
193- # TODO
194- if result:
195- static byte encBuff[<sTasName>_REQUIRED_BYTES_FOR_<sEnc>ENCODING + 1] # +1 for zerosized types
196- bitStrm: <sStreamName>Stream
197- <sStreamName>Stream_Init(&bitStrm, encBuff, <sTasName>_REQUIRED_BYTES_FOR_<sEnc>ENCODING);
198-
199- result = <sTasName>_<sEnc>Encode(<sAmber>tmp, &bitStrm, &errCode, TRUE);
200-
201- if not os.path.exists("asn1scc_<sEnc>.dat"):
202- print("fopen failed !!!\n");
203- return None;
204-
205- with open("asn1scc_<sEnc>.dat","wb") as fp:
206- fp.write(encBuff)
151+ #PrintSuite_call_codec_generate_dat_file
207152>>
208153
154+ //intentionally left blank - no testrunner written
209155PrintATCRunnerDefinition() ::= <<
210- from dataclasses import dataclass
211- from typing import Callable
212-
213- @dataclass
214- class TestOutput:
215- report_tests_failed: Callable[[int, int], None]
216- report_all_tests_passed: Callable[[int], None]
217-
218- report_suite_begin: Callable[[], None]
219- report_suite_end: Callable[[], None]
220-
221- report_case_begin: Callable[[str], None]
222- report_case_end: Callable[[], None]
223-
224- report_failure_begin: Callable[[], None]
225- report_failure_end: Callable[[], None]
226- report_failure_message: Callable[[str], None]
227- report_test_case_success: Callable[[str, int], None]
228-
229-
230156>>
231157
232158PrintATCRunner(sTestSuiteFilename, arrsIncludedModules, arrsVars, arrsTestFunctions, arrsUsedPackages, arrsInitCalls, bGenerateDatFile) ::= <<
233- # Code automatically generated by asn1scc tool (stg macro : PrintATCRunner)
234- <arrsIncludedModules:{a|from <a> import *}; separator="\n">
235-
236-
237- def asn1scc_run_generated_testsuite(output: TestOutput) -> int:
238- totalErrors: int = 0
239- <arrsVars; separator="\n">
240-
241-
242- output.report_suite_begin()
243-
244- <arrsTestFunctions;separator="\n">
245-
246- output.report_suite_end()
247-
248- if totalErrors > 0:
249- output.report_tests_failed(<arrsTestFunctions.Length>, totalErrors)
250- return 1
251- else:
252- output.report_all_tests_passed(<arrsTestFunctions.Length>)
253- return 0
254159>>
255160
256161
257162
258163invokeTestCaseAsFunc(sFuncName) ::= <<
259- totalErrors += <sFuncName>(output)
260164>>
261165
262166
@@ -281,8 +185,6 @@ def <sFuncName>() -> None:
281185
282186 _ = <sTasName>_<sEnc>enc_dec(tc_data, "<sFuncName>")
283187 _ = <sTasName>_<sEnc>enc_dec_generic(tc_data, "<sFuncName>_generic")
284-
285- <! Always empty - not generating: <sGenerateDatFile>!>
286188>>
287189
288190
@@ -297,7 +199,6 @@ import time
297199
298200from asn1pylib.asn1src import *
299201from asn1pylib.asn1python import *
300- <!<arrsIncludedModules:{aim|from asn1pylib.asn1src.<aim> import *}; separator="\n">!>
301202
302203<arrsTestFunctionBodies;separator="\n\n">
303204
0 commit comments