[diags] use temporary buffer for diag output (#2992)

This commit is contained in:
Shu Chen
2018-08-28 09:24:23 -07:00
committed by Jonathan Hui
parent 2f605e9953
commit 026badad96
7 changed files with 70 additions and 75 deletions
+3 -2
View File
@@ -243,10 +243,11 @@ void TestDiag(void)
for (const TestCommand *test = &tests[0]; test->mCommand != NULL; test++)
{
const char *output = NULL;
char output[OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE];
printf("\nCommand: %s", MakePrintable(test->mCommand));
output = otDiagProcessCmdLine(test->mCommand);
output[sizeof(output) - 1] = '\0';
otDiagProcessCmdLine(test->mCommand, output, sizeof(output) - 1);
printf("\nOutput: %s\n", MakePrintable(output));
VerifyOrQuit(strcmp(output, test->mExpectedOutput) == 0, "diagnostics output does not match expected result\n");