Skip to content

Commit d4271c9

Browse files
committed
examples: line-buffer stdout so tests reliably capture server output
1 parent b608ac3 commit d4271c9

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

examples/tpmcertserver/tpmcertclient.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ int main(int argc, char* argv[])
101101
byte txt[] = "hello from tpmcertclient\n";
102102
byte rxBuf[TPMCC_BUF_SZ];
103103

104+
/* Line-buffer stdout so output is visible immediately when redirected. */
105+
setvbuf(stdout, NULL, _IOLBF, 0);
106+
104107
for (i = 1; i < argc; i++) {
105108
if (XSTRCMP(argv[i], "-p") == 0 && i + 1 < argc)
106109
port = (word16)atoi(argv[++i]);

examples/tpmcertserver/tpmcertserver.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ int main(int argc, char* argv[])
244244
byte certDer[TPMCS_CERT_MAX];
245245
word32 certDerSz = (word32)sizeof(certDer);
246246

247+
/* Line-buffer stdout so progress is visible immediately when redirected to
248+
* a file (the server runs while a test reads its output). */
249+
setvbuf(stdout, NULL, _IOLBF, 0);
250+
247251
XMEMSET(&dev, 0, sizeof(dev));
248252
XMEMSET(&hostKey, 0, sizeof(hostKey));
249253

0 commit comments

Comments
 (0)