You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2022/01/21 14:32:08 UTC

[GitHub] [daffodil] stevedlawrence commented on a change in pull request #731: Add test that reproduces Runtime SDE bug.

stevedlawrence commented on a change in pull request #731:
URL: https://github.com/apache/daffodil/pull/731#discussion_r789701899



##########
File path: daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/setVarWIthValueLength.tdml
##########
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testSuite
+  xmlns="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
+  xmlns:daf="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext"
+  xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:f="http://example.com"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  defaultRoundTrip="onePass"
+  defaultValidation="on">
+
+  <tdml:defineSchema name="s1" elementFormDefault="unqualified" useDefaultNamespace="false"
+                     xmlns="http://www.w3.org/2001/XMLSchema">
+
+
+    <include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+
+    <dfdl:format ref="f:GeneralFormat"
+                 representation="binary"/>
+
+    <dfdl:defineVariable name="someVar" type="xs:int"/>
+
+
+    <element name="root">
+      <complexType>
+        <sequence>
+          <element name="someElement" type="xs:int"/>
+          <!--
+          DAFFODIL-2629 This setVariable calling dfdl:valueLength on the prior element. Causes Runtime SDE."
+          -->
+          <sequence>
+            <annotation>
+              <appinfo source="http://www.ogf.org/dfdl/">
+                <dfdl:setVariable ref="f:someVar">{ dfdl:valueLength(someElement, "bytes") }

Review comment:
       If you use the `value` attribute for the expression does it still fail? Might be good to add a test for both syntaxes to make sure however this is resolved works for both.

##########
File path: daffodil-test/src/test/resources/org/apache/daffodil/section07/variables/setVarWIthValueLength.tdml
##########
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<testSuite
+  xmlns="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
+  xmlns:daf="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext"
+  xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:f="http://example.com"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  defaultRoundTrip="onePass"
+  defaultValidation="on">
+
+  <tdml:defineSchema name="s1" elementFormDefault="unqualified" useDefaultNamespace="false"
+                     xmlns="http://www.w3.org/2001/XMLSchema">
+
+
+    <include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"/>
+
+    <dfdl:format ref="f:GeneralFormat"
+                 representation="binary"/>
+
+    <dfdl:defineVariable name="someVar" type="xs:int"/>
+
+
+    <element name="root">
+      <complexType>
+        <sequence>
+          <element name="someElement" type="xs:int"/>
+          <!--
+          DAFFODIL-2629 This setVariable calling dfdl:valueLength on the prior element. Causes Runtime SDE."
+          -->
+          <sequence>
+            <annotation>
+              <appinfo source="http://www.ogf.org/dfdl/">
+                <dfdl:setVariable ref="f:someVar">{ dfdl:valueLength(someElement, "bytes") }
+                </dfdl:setVariable>
+              </appinfo>
+            </annotation>
+          </sequence>

Review comment:
       Is it worth added an inputValueCalc and/or outputValueCalc to ensure that the variable actually gets the right value? I could imagine a but where the SDE goes away but doesn't actually calculate the correct value and we wouldn't know.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org