Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run TDML tests with user-chosen TDML implementation
Define TDMLImplementation using simple enumerated type in dafext.xsd. Add TDML implementation option to Daffodil's CLI test subcommand and pass Option[TDMLImplementation] argument to Runner to allow CLI to run TDML tests with different TDMLImplementations (formerly we had to edit the TDML file, but that become undesirable). Remove tunable tdmlImplementation from dafext.xsd and runtime2 TDML files. Modify runtime2 Scala tests to pass TDMLImplementation.DaffodilC to Runner instead. Look up TDML_IMPLEMENTATION environment variable in DFDLTestSuite to allow "sbt test" to run tests with different TDML implementations too. Add CLI integration tests to increase test coverage of new and changed lines. Interaction between environment variable, CLI option, and JUnit tests is simple to understand. CLI option or JUnit argument passed to Runner always specifies TDML implementation. In their absence, environment variable specifies TDML implementation. Otherwise, tests run with TDMLImplementation.Daffodil (runtime1). Also fix some inconsistencies with fill bits overlooked by a previous pull request which extended runtime2 to read and write N-bit numbers. See more detailed changelog below. DAFFODIL-2697 testNonCompatibleImplementation.tdml: Add another test schema and test case to increase test coverage of "daffodil test -I" option. Util.scala: Use standard Scala idioms for getting DAFFODIL_HOME environment variable and composing environment variables. TestCLIexecuting.scala: Add new error and normal test cases to increase test coverage of "daffodil test -I" option. Update "not compatible" error test case due to change in error message. Main.scala: Import TDMLImplementation (defined in dafext.xsd) to tell CLI and user which TDML implementations Daffodil supports. Add TDML implementation option to CLI test subcommand. Pass specified TDML implementation or None to Runner for TDML file's tests. Include TDML implementation's name in "not compatible with implementation" message. tdml.xsd: Update names of TDML implementations to match names of TDML implementations in dafext.xsd. Change runtime2 implementation name from "daffodil-runtime2" to "daffodilC" because a TDML implementation name must be a valid identifier in both XML and Scala and you can't embed a dash within a Scala identifier. dafext.xsd: Remove tdmlImplementation tunable to avoid overly complicated interaction between tunable, environment variable, and CLI -I option. Add TunableTDMLImplementation simple type (can't remove "Tunable" from its name because TunableGenerator filters out types not beginning with "Tunable") with enumerations listing every TDML implementation Daffodil supports, which also creates a TDMLImplementation enumerated type we can import into Scala files. Add comment to clarify you still need different classpaths to call ibm as a cross tester. Change all enumerated simple types to use standard xs:token idiom instead of xs:string. parsers.c: Rename parse_fill_bytes to parse_fill_bits and make it read exactly N fill bits (no more, no less). parsers.h: Rename parse_fill_bytes to parse_fill_bits and rename its first parameter to correct name end_bitPos0b (not end_bytePos0b). unparsers.c: Rename unparse_fill_bytes to unparse_fill_bits and make it write exactly N fill bits (no more, no less). unparsers.h: Rename unparse_fill_bytes to unparse_fill_bits and rename its first parameter to correct name end_bitPos0b (not end_bytePos0b). CodeGenerator.scala: Use standard Scala idiom for getting CC and PATH environment variables. CodeGeneratorState.scala: Rename calls of (un)parse_fill_bytes to (un)parse_fill_bits in generated C code. ex_nums.tdml: Make comments show how to run CLI test subcommand with both daffodil and daffodilC implementations. Remove config-runtime1 and config-runtime2 since tunable tdmlImplementation doesn't exist anymore. Add implementation-specific error tests with implementations="daffodil" and implementations="daffodilC" to demonstrate how runtime1 and runtime2 handle non-fixed values in elements with fixed attributes slightly differently depending on validation levels. Combine runtime2 error_limited and error_on tests into error_parse since runtime2 doesn't have a validation option. nested.tdml: Replace tdmlImplementation configs with comments showing how to run CLI test subcommand with different TDML implementations. RunnerFactory.scala: Extend Runner API with TDMLImplementation parameter in first apply method, Option[TDMLImplementation] parameter in new two-argument apply method, and Option[TDMLImplementation] parameter in base constructor to allow CLI and JUnit code to pass TDML implementation to Runner(...) if they choose to. Put all known TDML implementations in defaultImplementationsDefaultDefault to make it easier to run TDML tests with any TDML implementation. TDMLRunner.scala: Extend DFDLTestSuite constructor with Option[TDMLImplementation] parameter to allow Runner to pass TDML implementation, also remove __nl parameter which was only difference between first and second constructors since second constructor isn't called anymore and can be removed. Make DFDLTestSuite responsible for defining defaultTDMLImplementation (either sys.env.get("TDML_IMPLEMENTATION") or daffodil) and tdmlDFDLProcessorFactory (moved to DFDLTestSuite from TestCase) to try to minimize number of times code looks up TDML_IMPLEMENTATION and matching TDMLDFDLProcessorFactory class and constructs new factory. Unfortunately, both CLI Main class and JUnit tests run individual TDML test cases one by one, not en masse, and each individual test calls Runner.getTS which always creates a new DFDLTestSuite, so every single test will fail and throw TDMLException if TDML_IMPLEMENTATION names an invalid TDML implementation. Didn't try it, but maybe could move defaultTDMLImplementation and tdmlDFDLProcessorFactory to Runner and pass tdmlDFDLProcessorFactory instead of optTDMLImplementation to DFDLTestSuite. Then only first test might fail and rest of tests might run with daffodil implementation. Runtime2TDMLDFDLProcessor.scala: Don't set implementationName to "daffodil-runtime2" literal string, set it to TDMLImplementation.DaffodilC.toString to get the correct name instead. TestRunnerFactory.java: Pass Option.apply(null) [closest Java equivalent to passing None] to Runner in first test case. Noticed that IDEA complains TestRunnerFactory is calling private Runner constructor, but sbt still compiles TestRunnerFactory with no problem. ISRM_green_to_orange_60000.tdml: Replace tunable configs with comments showing how to run CLI test subcommand with different TDML implementations. ISRM_orange_to_green_60002.tdml: Replace tunable configs with comments showing how to run CLI test subcommand with different TDML implementations. MPU_green_to_orange_60004.tdml: Replace tunable configs with comments showing how to run CLI test subcommand with different TDML implementations. MPU_orange_to_green_60006.tdml: Replace tunable configs with comments showing how to run CLI test subcommand with different TDML implementations. collisions.tdml: Replace tunable configs with comments showing how to run CLI test subcommand with different TDML implementations. egress_xdcc_bw.tdml: Replace tunable configs with comments showing how to run CLI test subcommand with different TDML implementations. ingress_xdcc_bw.tdml: Replace tunable configs with comments showing how to run CLI test subcommand with different TDML implementations. orion.tdml: Replace tunable configs with comments showing how to run CLI test subcommand with different TDML implementations. TestCollisions.scala: Pass TDMLImplementation.DaffodilC to Runner. TestEgressXdccBw.scala: Pass TDMLImplementation.DaffodilC to Runner. TestExNums.scala: Pass TDMLImplementation.Daffodil and TDMLImplementation.DaffodilC to two Runners to run both runtime1 and runtime2 tests side by side. Combine runtime2 error_limited and error_on tests into error_parse since runtime2 doesn't have a validation option. TestIngressXdccBw.scala: Pass TDMLImplementation.DaffodilC to Runner. TestIsrmGreenToOrange60000.scala: Pass TDMLImplementation.DaffodilC to Runner. TestIsrmOrangeToGreen60002.scala: Pass TDMLImplementation.DaffodilC to Runner. TestMpuGreenToOrange60004.scala: Pass TDMLImplementation.DaffodilC to Runner. TestMpuOrangeToGreen60006.scala: Pass TDMLImplementation.DaffodilC to Runner. TestNested.scala: Pass TDMLImplementation.DaffodilC to Runner. TestOrion.scala: Pass TDMLImplementation.DaffodilC to Runner.
- Loading branch information