[asterisk-dev] Adding "pipe" support to test infrastructure

Joshua C. Colp jcolp at sangoma.com
Thu Apr 28 16:24:53 CDT 2022


On Thu, Apr 28, 2022 at 6:23 PM Philip Prindeville <
philipp_subx at redfish-solutions.com> wrote:

>
>
> > On Apr 28, 2022, at 3:09 AM, Joshua C. Colp <jcolp at sangoma.com> wrote:
> >
> > On Thu, Apr 28, 2022 at 2:18 AM Philip Prindeville <
> philipp_subx at redfish-solutions.com> wrote:
> > Hi,
> >
> > I'm working on some changes to various parts of Asterisk that currently
> don't have good test coverage.
> >
> > The easiest way (for what I'm doing) to add coverage is to interface
> with external commands that are known to provide correct results and test
> against them.
> >
> > I've written a mockup of a function that runs a pipeline, collects
> stdout and stderr into buffers, and returns the processes exit code.
> >
> > This is useful if, for instance, you generate data and want to verify it
> computationally internally, but then compare results with an external
> reference command.
> >
> > It's also useful for commands that generate temporal (or ephemeral)
> results that can't use "canned" data in their generation.
> >
> > Here's some details:
> >
> > typedef struct {
> >         char *outbuf;
> >         size_t outlen;
> >         char *errbuf;
> >         size_t errlen;
> >         int exitcode;
> > } ast_test_capture_cmd_t;
> >
> > int ast_test_capture_cmd_run(ast_test_capture_cmd_t *results, const char
> *cmd);
> >
> > ast_test_capture_cmd_free(ast_test_capture_cmd_t *results);
> >
> > Note that commands are run with stdin set to /dev/null.
> >
> > What do you all think about adding this functionality?
> >
> > Is there a reason that this needs to be part of the core unit testing
> capability? Is it so that you can just reuse the code within your use case?
> >
>
>
> Well, hopefully in multiple places as I get around to adding more test
> coverage... or for that matter, other people are welcome to leverage it too.
>
> I was thinking at first that I'd want to use it in test/test_crypto.c but
> then I realized that if I redid the crypto API as "res/res_crypto2.c" then
> I'd need similar test coverage there (more in fact), for longer keys, ECC,
> DH, AES-GCM, etc.
>
> Plus there are certain tests that might rely on external services, like
> STUN, that you'd want to confirm similar results with an external script or
> utility known to be good.
>
> Or am I misunderstanding the question?
>

No, you're not misunderstanding it. I was trying to determine the general
applicability of it. It's probably fine.

-- 
Joshua C. Colp
Asterisk Technical Lead
Sangoma Technologies
Check us out at www.sangoma.com and www.asterisk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20220428/5df1d588/attachment.html>


More information about the asterisk-dev mailing list