<div dir="ltr"><div dir="ltr">On Thu, Apr 28, 2022 at 2:18 AM Philip Prindeville <<a href="mailto:philipp_subx@redfish-solutions.com">philipp_subx@redfish-solutions.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I'm working on some changes to various parts of Asterisk that currently don't have good test coverage.<br>
<br>
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.<br>
<br>
I've written a mockup of a function that runs a pipeline, collects stdout and stderr into buffers, and returns the processes exit code.<br>
<br>
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.<br>
<br>
It's also useful for commands that generate temporal (or ephemeral) results that can't use "canned" data in their generation.<br>
<br>
Here's some details:<br>
<br>
typedef struct {<br>
char *outbuf;<br>
size_t outlen;<br>
char *errbuf;<br>
size_t errlen;<br>
int exitcode;<br>
} ast_test_capture_cmd_t;<br>
<br>
int ast_test_capture_cmd_run(ast_test_capture_cmd_t *results, const char *cmd);<br>
<br>
ast_test_capture_cmd_free(ast_test_capture_cmd_t *results);<br>
<br>
Note that commands are run with stdin set to /dev/null.<br>
<br>
What do you all think about adding this functionality?<br></blockquote><div><br></div><div>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? </div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-family:tahoma,sans-serif"><font color="#073763">Joshua C. Colp</font></div><div style="font-family:tahoma,sans-serif"><font color="#073763">Asterisk Technical Lead</font></div><div style="font-family:tahoma,sans-serif"><font color="#073763">Sangoma Technologies</font></div><div style="font-family:tahoma,sans-serif"><font color="#073763">Check us out at <a href="http://www.sangoma.com" target="_blank">www.sangoma.com</a> and <a href="http://www.asterisk.org" target="_blank">www.asterisk.org</a></font><br></div></div></div></div></div></div></div></div></div></div></div>