opentap / OpenTap.Python

Python integration for OpenTAP
Apache License 2.0
20 stars 6 forks source link

Output not propagating with RunChildStep after plan reload #147

Closed tom-mun closed 6 months ago

tom-mun commented 8 months ago

Environment Python package 3.0.0 (also tested on 3.1.0) OpenTAP 9.19.4

Details

It appears some outputs do not propagate when the following are true:

  1. The step with the input is run via the RunChildStep( inputStep ) method
  2. The test plan has been reloaded since the input / output steps were added

testPy.zip

I have attached some example code with 2 parent steps that both use the same child step. The only difference between the parent steps is one uses RunChildStep, and one uses RunChildSteps(). The child step will fail if it receives an input equal to 0 (default). If the output propagates, the child step input is set to 5, and the step passes.

To recreate, once the code is loaded,

  1. Add both parent steps and run. Both should pass
  2. Reload the plan somehow (change some setting back and forth)
  3. Run again, the RunChildSteps() parent will pass, the RunChildStep parent will fail
tom-mun commented 8 months ago

Just as a note, this occurs in the same manner when the output is set up via the UI instead of programmatically.

rmadsen-ks commented 6 months ago
    def __init__(self, *args):
        super().__init__(*args)

        self.outputProp = Double(0)

        self.childStep = ChildTest()
        self.ChildTestSteps.Add(self.childStep)
        self.InputOutputRelation(self.childStep, "inputProp", self, "outputProp")

    def InputOutputRelation(self, inputstep, inputparam: str, outputstep, outputparam: str):
        inmem = OpenTap.TypeData.GetTypeData(inputstep).GetMember(inputparam)
        outmem = OpenTap.TypeData.GetTypeData(outputstep).GetMember(outputparam)
        OpenTap.InputOutputRelation.Assign(inputstep, inmem, outputstep, outmem)

    def Run(self):
        self.outputProp = Double(5)
        self.RunChildStep(self.childStep)

self.childStep is not supported in this way. When the test plan is loaded ChildTestSteps are overwritten and self.childStep still refers to the old step. Instead of self.childStep, use self.ChildTestSteps[0] or something like that.