examples: line-buffer stdout so tests reliably capture server output

pull/1043/head
aidan garske 2026-07-02 13:03:24 -07:00 committed by David Garske
parent 5f715daf02
commit 8dfdb63168
2 changed files with 7 additions and 0 deletions

View File

@ -101,6 +101,9 @@ int main(int argc, char* argv[])
byte txt[] = "hello from tpmcertclient\n";
byte rxBuf[TPMCC_BUF_SZ];
/* Line-buffer stdout so output is visible immediately when redirected. */
setvbuf(stdout, NULL, _IOLBF, 0);
for (i = 1; i < argc; i++) {
if (XSTRCMP(argv[i], "-p") == 0 && i + 1 < argc)
port = (word16)atoi(argv[++i]);

View File

@ -244,6 +244,10 @@ int main(int argc, char* argv[])
byte certDer[TPMCS_CERT_MAX];
word32 certDerSz = (word32)sizeof(certDer);
/* Line-buffer stdout so progress is visible immediately when redirected to
* a file (the server runs while a test reads its output). */
setvbuf(stdout, NULL, _IOLBF, 0);
XMEMSET(&dev, 0, sizeof(dev));
XMEMSET(&hostKey, 0, sizeof(hostKey));