path: root/tools/testing/selftests/bpf/test_progs.h
diff options
authorStanislav Fomichev <sdf@google.com>2019-08-30 19:34:26 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2019-09-03 15:13:14 +0200
commitd80507d15d45e285fc596d23665c9b88cf0dfec3 (patch)
tree2c3d5c5ca47d649db2a21bdbb00a459cba133efa /tools/testing/selftests/bpf/test_progs.h
parentMerge branch 'bpf-xdp-unaligned-chunk' (diff)
selftests/bpf: test_progs: fix verbose mode garbage
fseeko(.., 0, SEEK_SET) on a memstream just puts the buffer pointer to the beginning so when we call fflush on it we get some garbage log data from the previous test. Let's manually set terminating byte to zero at the reported buffer size. To show the issue consider the following snippet: stream = open_memstream (&buf, &len); fprintf(stream, "aaa"); fflush(stream); printf("buf=%s, len=%zu\n", buf, len); fseeko(stream, 0, SEEK_SET); fprintf(stream, "b"); fflush(stream); printf("buf=%s, len=%zu\n", buf, len); Output: buf=aaa, len=3 buf=baa, len=1 Fixes: 946152b3c5d6 ("selftests/bpf: test_progs: switch to open_memstream") Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/test_progs.h')
0 files changed, 0 insertions, 0 deletions