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

Joshua C. Colp jcolp at sangoma.com
Thu Apr 28 04:09:57 CDT 2022


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?

-- 
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/38a05eb0/attachment.html>


More information about the asterisk-dev mailing list