<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/testsuite/+/19676">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span></span><br></pre><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_if: Add tests for conditional branch apps<br><br>Adds tests for If, ElseIf, Else, ExitIf, and<br>EndIf applications.<br><br>ASTERISK-29497<br><br>Change-Id: Iff228c42c9338e1461950ab9fb85f3edf404daae<br>---<br>A tests/apps/if/configs/ast1/extensions.conf<br>A tests/apps/if/test-config.yaml<br>M tests/apps/tests.yaml<br>3 files changed, 211 insertions(+), 0 deletions(-)<br><br></pre>
<pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/apps/if/configs/ast1/extensions.conf b/tests/apps/if/configs/ast1/extensions.conf</span><br><span>new file mode 100644</span><br><span>index 0000000..450821c</span><br><span>--- /dev/null</span><br><span>+++ b/tests/apps/if/configs/ast1/extensions.conf</span><br><span>@@ -0,0 +1,135 @@</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[default]</span><br><span style="color: hsl(120, 100%, 40%);">+exten => s,1,Answer()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test If true</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Pass)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test If false</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test If false</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Else() ; shouldn't execute this</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test ExitIf</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ExitIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test Else</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Else()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Goto(after)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n(after),NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test ElseIf</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ElseIf(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ElseIf(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Goto(after)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ElseIf(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Pass)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Else()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n(after),NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test ElseIf #2</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ElseIf(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ElseIf(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ElseIf(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Goto(after2)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Else()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n(after2),NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test nested If</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Pass)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ExitIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Pass)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ExitIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Pass)</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test really nested</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Else()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Pass)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ExitIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Pass)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ExitIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Pass)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ExitIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test that Else doesn't execute after true If</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Else()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test that ElseIf doesn't execute after true If</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ExitIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ElseIf(1) ; needed to exit If before ElseIf (but not before Else)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test that Else/ElseIf doesn't execute after true If</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ExitIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ElseIf(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Else()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test that If matches Else only if it's before its EndIf</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Else()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; test that If matches ElseIf only if it's before its EndIf</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,If(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ExitIf() ; needed to exit If before ElseIf (but not before Else)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,ElseIf(1)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Fail)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndIf()</span><br><span style="color: hsl(120, 100%, 40%);">+ ; all tests succeeded</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,UserEvent(IfSuccess,Result: Pass)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Hangup()</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[nothing]</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 0,1,Answer()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Wait(10)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Hangup()</span><br><span>diff --git a/tests/apps/if/test-config.yaml b/tests/apps/if/test-config.yaml</span><br><span>new file mode 100644</span><br><span>index 0000000..ac0f892</span><br><span>--- /dev/null</span><br><span>+++ b/tests/apps/if/test-config.yaml</span><br><span>@@ -0,0 +1,61 @@</span><br><span style="color: hsl(120, 100%, 40%);">+testinfo:</span><br><span style="color: hsl(120, 100%, 40%);">+ summary: 'Ensure that app_if functions correctly.'</span><br><span style="color: hsl(120, 100%, 40%);">+ description: |</span><br><span style="color: hsl(120, 100%, 40%);">+ 'This tests the If, ElseIf, Else, EndIf, and ExitIf applications to make sure</span><br><span style="color: hsl(120, 100%, 40%);">+ that they work correctly. This includes nesting application calls to ensure</span><br><span style="color: hsl(120, 100%, 40%);">+ that nesting behavior is correct and that different combos of app calls use</span><br><span style="color: hsl(120, 100%, 40%);">+ the appropriate logic.'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+test-modules:</span><br><span style="color: hsl(120, 100%, 40%);">+ test-object:</span><br><span style="color: hsl(120, 100%, 40%);">+ config-section: test-object-config</span><br><span style="color: hsl(120, 100%, 40%);">+ typename: 'test_case.TestCaseModule'</span><br><span style="color: hsl(120, 100%, 40%);">+ modules:</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ config-section: caller-originator</span><br><span style="color: hsl(120, 100%, 40%);">+ typename: 'pluggable_modules.Originator'</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ config-section: hangup-monitor</span><br><span style="color: hsl(120, 100%, 40%);">+ typename: 'pluggable_modules.HangupMonitor'</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ config-section: ami-config</span><br><span style="color: hsl(120, 100%, 40%);">+ typename: 'pluggable_modules.EventActionModule'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+test-object-config:</span><br><span style="color: hsl(120, 100%, 40%);">+ connect-ami: True</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+caller-originator:</span><br><span style="color: hsl(120, 100%, 40%);">+ channel: 'Local/s@default'</span><br><span style="color: hsl(120, 100%, 40%);">+ context: 'nothing'</span><br><span style="color: hsl(120, 100%, 40%);">+ exten: '0'</span><br><span style="color: hsl(120, 100%, 40%);">+ priority: '1'</span><br><span style="color: hsl(120, 100%, 40%);">+ trigger: 'ami_connect'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+hangup-monitor:</span><br><span style="color: hsl(120, 100%, 40%);">+ ids: '0'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ami-config:</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ ami-events:</span><br><span style="color: hsl(120, 100%, 40%);">+ conditions:</span><br><span style="color: hsl(120, 100%, 40%);">+ match:</span><br><span style="color: hsl(120, 100%, 40%);">+ Event: 'UserEvent'</span><br><span style="color: hsl(120, 100%, 40%);">+ UserEvent: 'IfSuccess'</span><br><span style="color: hsl(120, 100%, 40%);">+ requirements:</span><br><span style="color: hsl(120, 100%, 40%);">+ match:</span><br><span style="color: hsl(120, 100%, 40%);">+ Result: 'Pass'</span><br><span style="color: hsl(120, 100%, 40%);">+ count: 9</span><br><span style="color: hsl(120, 100%, 40%);">+ stop_test:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+properties:</span><br><span style="color: hsl(120, 100%, 40%);">+ tags:</span><br><span style="color: hsl(120, 100%, 40%);">+ - dial</span><br><span style="color: hsl(120, 100%, 40%);">+ - apps</span><br><span style="color: hsl(120, 100%, 40%);">+ dependencies:</span><br><span style="color: hsl(120, 100%, 40%);">+ - python: 'twisted'</span><br><span style="color: hsl(120, 100%, 40%);">+ - python: 'starpy'</span><br><span style="color: hsl(120, 100%, 40%);">+ - asterisk: 'app_dial'</span><br><span style="color: hsl(120, 100%, 40%);">+ - asterisk: 'app_userevent'</span><br><span style="color: hsl(120, 100%, 40%);">+ - asterisk: 'app_originate'</span><br><span style="color: hsl(120, 100%, 40%);">+ - asterisk: 'app_if'</span><br><span style="color: hsl(120, 100%, 40%);">+ - asterisk: 'pbx_config'</span><br><span>diff --git a/tests/apps/tests.yaml b/tests/apps/tests.yaml</span><br><span>index 6dd267f..f74ba8e 100644</span><br><span>--- a/tests/apps/tests.yaml</span><br><span>+++ b/tests/apps/tests.yaml</span><br><span>@@ -29,3 +29,4 @@</span><br><span> - test: 'mf'</span><br><span> - test: 'sf'</span><br><span> - test: 'read'</span><br><span style="color: hsl(120, 100%, 40%);">+ - test: 'if'</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/testsuite/+/19676">change 19676</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/testsuite/+/19676"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: Iff228c42c9338e1461950ab9fb85f3edf404daae </div>
<div style="display:none"> Gerrit-Change-Number: 19676 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <asterisk@phreaknet.org> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>