[Asterisk-code-review] app_assert: Add Assert application (asterisk[master])

N A asteriskteam at digium.com
Sun Oct 24 11:06:48 CDT 2021


Attention is currently required from: Joshua Colp.
N A has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/16629 )

Change subject: app_assert: Add Assert application
......................................................................


Patch Set 1:

(1 comment)

Patchset:

PS1: 
> Or to be more general, there is functionality already such as ExecIf which can be combined with othe […]
It's supposed to be analogous to the C function, to make doing this easy.
First of all, it would not be one line of dialplan but multiple, since we need to log a warning that the assertion failed, THEN hang up.
And one thing that comes to mind is that doing this manually won't print out the dialplan that actually "failed" the test.
I didn't do this before, but it probably also makes sense to print out the location here, which would make this even more cumbersome to do manually.

Think about test suite, for instance, where we can just have a bunch of them, and if it makes it to the end, it passes:

same => n,Assert($[${cond}=${cond2}])
same => n,Assert($[${EPOCH}=${EPOCH}])
same => n,Assert(...)

Much cleaner than:
same => n,GotoIf($[${cond}!=${cond2}]?fail1)
same => n,GotoIf($[${EPOCH}!=${EPOCH}]?fail2)
...
same => n,Goto(success)
same => n(fail1),Log(WARNING,fail1 happened: cond was not equal to cond2)
same => n,Hangup()
same => n(fail2),Log(WARNING,EPOCH was not equal to EPOCH)
same => n,Hangup()
...
well, you get the idea...

Now, it's very clean for this to be in dialplan everywhere, without cluttering things up with ExecIf/Log/Hangup/GotoIf all over the place, and it's easy to interpret why it's there since everyone knows what assert() means in C.



-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16629
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ia089c2debf608f42f5f87e6c29d50e8ebcc093e5
Gerrit-Change-Number: 16629
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-CC: Joshua Colp <jcolp at sangoma.com>
Gerrit-Attention: Joshua Colp <jcolp at sangoma.com>
Gerrit-Comment-Date: Sun, 24 Oct 2021 16:06:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211024/ce1ea382/attachment.html>


More information about the asterisk-code-review mailing list