<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/testsuite/+/17938">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Benjamin Keith Ford: Looks good to me, but someone else must approve
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">func_evalexten: Add tests for EVAL_EXTEN function<br><br>Adds tests for the new EVAL_EXTEN function to<br>ensure that it functions correctly.<br><br>Additionally, this tests the refactoring of some<br>code into pbx_parse_location (new public API)<br>to ensure that parsing is done properly, as this<br>is required by both EVAL_EXTEN and the PBX core.<br><br>pbx_substitute_variables_helper_full_location is<br>also tested by this test suite.<br><br>ASTERISK-29486<br><br>Change-Id: Ib12fde79e06c3c02b1303ba09fabb21f75b12f5a<br>---<br>A tests/funcs/func_evalexten/configs/ast1/extensions.conf<br>A tests/funcs/func_evalexten/test-config.yaml<br>M tests/funcs/tests.yaml<br>3 files changed, 115 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/funcs/func_evalexten/configs/ast1/extensions.conf b/tests/funcs/func_evalexten/configs/ast1/extensions.conf</span><br><span>new file mode 100644</span><br><span>index 0000000..6f64c4e</span><br><span>--- /dev/null</span><br><span>+++ b/tests/funcs/func_evalexten/configs/ast1/extensions.conf</span><br><span>@@ -0,0 +1,55 @@</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%);">+ same => n,Set(GLOBAL(evalexten)=isreallycool)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Set(i=0)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,While($[${INC(i)}<=11])</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Originate(Local/${i}@evalexten,app,Wait,5,,,a)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,EndWhile()</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 style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[evalexten]</span><br><span style="color: hsl(120, 100%, 40%);">+exten => success,1,UserEvent(EvalExtenSuccess,Result: Pass)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Hangup()</span><br><span style="color: hsl(120, 100%, 40%);">+exten => fail,1,UserEvent(EvalExtenFailure,Result: Fail ${RECEIVESFSTATUS} ${digits},Reason: ${digits})</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Hangup()</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 1,1,GotoIf($["${EVAL_EXTEN(ee-context-1,${EPOCH},1)}"="4545"]?success,1:fail,1) ; make sure evaluated extension is argument, not current dialplan extension</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 2,1,GotoIf($["${EVAL_EXTEN(ee-context-2,${EPOCH},1)}"=""]?success,1:fail,1) ; non-existent evaluation extension</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 3,1,GotoIf($[${EVAL_EXTEN(ee-context-3,${EXTEN},1)}>${EPOCH}]?success,1:fail,1) ; ensure variable substitution occurs correctly</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 4,1,GotoIf($[${EVAL_EXTEN(ee-context-4,212,1)}=200]?success,1:fail,1) ; ensure pattern matching works correctly</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 5,1,GotoIf($[${EVAL_EXTEN(ee-context-4,312,1)}=300]?success,1:fail,1) ; ensure pattern matching works correctly</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 6,1,GotoIf($[${EVAL_EXTEN(ee-context-4,332,1)}=330]?success,1:fail,1) ; ensure pattern matching works correctly</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 7,1,GotoIf($["${EVAL_EXTEN(ee-context-4,332,2)}"="isreallycool"]?success,1:fail,1) ; ensure non-1 priorities work correctly</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 8,1,GotoIf($[${EVAL_EXTEN(100,1)}=50]?success,1:fail,1) ; implicit context</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 9,1,GotoIf($[${EVAL_EXTEN(2)}=60]?success,1:fail,1) ; implicit context and extension</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Return(60)</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 10,1,GotoIf($["${EVAL_EXTEN(ee-context-5,353,1)}"="353"]?success,1:fail,1) ; EXTEN evaluation</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 11,1,GotoIf($["${EVAL_EXTEN(ee-context-5,354,1)}"="1"]?success,1:fail,1) ; EXTEN evaluation</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 100,1,Return(50)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[ee-context-1]</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 1,1,Return(0)</span><br><span style="color: hsl(120, 100%, 40%);">+exten => _X!,1,Return(4545)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[ee-context-2]</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 0,1,Return(4545)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[ee-context-3]</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 1,1,Return(${EPOCH})</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 2,1,Return($[${EPOCH}+1])</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 3,1,Return($[${EPOCH}+2])</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[ee-context-4]</span><br><span style="color: hsl(120, 100%, 40%);">+exten => _2XX,1,Return(200)</span><br><span style="color: hsl(120, 100%, 40%);">+exten => _3XX,1,Return(300)</span><br><span style="color: hsl(120, 100%, 40%);">+exten => _33X,1,Return(330)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Return(${evalexten})</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[ee-context-5]</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 353,1,Return(${EXTEN})</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 354,1,Return($["${EXTEN}"="354"])</span><br><span>diff --git a/tests/funcs/func_evalexten/test-config.yaml b/tests/funcs/func_evalexten/test-config.yaml</span><br><span>new file mode 100644</span><br><span>index 0000000..db26e2d</span><br><span>--- /dev/null</span><br><span>+++ b/tests/funcs/func_evalexten/test-config.yaml</span><br><span>@@ -0,0 +1,59 @@</span><br><span style="color: hsl(120, 100%, 40%);">+testinfo:</span><br><span style="color: hsl(120, 100%, 40%);">+ summary: 'Ensure that func_evalexten functions correctly.'</span><br><span style="color: hsl(120, 100%, 40%);">+ description: |</span><br><span style="color: hsl(120, 100%, 40%);">+ 'This tests the EVAL_EXTEN function to ensure it properly</span><br><span style="color: hsl(120, 100%, 40%);">+ evaluates in different scenarios.'</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: 'EvalExtenSuccess'</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: 11</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%);">+ - funcs</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: 'func_evalexten'</span><br><span style="color: hsl(120, 100%, 40%);">+ - asterisk: 'pbx_config'</span><br><span>diff --git a/tests/funcs/tests.yaml b/tests/funcs/tests.yaml</span><br><span>index ff99541..9994168 100644</span><br><span>--- a/tests/funcs/tests.yaml</span><br><span>+++ b/tests/funcs/tests.yaml</span><br><span>@@ -7,3 +7,4 @@</span><br><span> - test: 'func_push'</span><br><span> - test: 'func_srv'</span><br><span> - test: 'func_talkdetect'</span><br><span style="color: hsl(120, 100%, 40%);">+ - test: 'func_evalexten'</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/testsuite/+/17938">change 17938</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/+/17938"/><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: Ib12fde79e06c3c02b1303ba09fabb21f75b12f5a </div>
<div style="display:none"> Gerrit-Change-Number: 17938 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>