Re: [PATCH bpf-next v2 2/4] selftests/bpf: test_progs: remove global fail/success counts
From: Stanislav Fomichev <sdf@fomichev.me>
Date: 2019-08-21 17:11:54
Also in:
bpf
On 08/21, Daniel Borkmann wrote:
On 8/19/19 9:17 PM, Stanislav Fomichev wrote:quoted
Now that we have a global per-test/per-environment state, there is no longer need to have global fail/success counters (and there is no need to save/get the diff before/after the test).Thanks for the improvements, just a small comment below, otherwise LGTM.quoted
Introduce QCHECK macro (suggested by Andrii) and covert existing tests to it. QCHECK uses new test__fail() to record the failure. Cc: Andrii Nakryiko <redacted> Signed-off-by: Stanislav Fomichev <redacted>[...]quoted
@@ -96,17 +93,25 @@ extern struct ipv6_packet pkt_v6; #define _CHECK(condition, tag, duration, format...) ({ \ int __ret = !!(condition); \ if (__ret) { \ - error_cnt++; \ + test__fail(); \ printf("%s:FAIL:%s ", __func__, tag); \ printf(format); \ } else { \ - pass_cnt++; \ printf("%s:PASS:%s %d nsec\n", \ __func__, tag, duration); \ } \ __ret; \ }) +#define QCHECK(condition) ({ \ + int __ret = !!(condition); \ + if (__ret) { \ + test__fail(); \ + printf("%s:FAIL:%d ", __func__, __LINE__); \ + } \ + __ret; \ +})I know it's just a tiny nit but the name QCHECK() really doesn't tell me anything if I don't see its definition. Even just a CHECK_FAIL() might be 'better' and more aligned with the CHECK() and CHECK_ATTR() we have, at least I don't think many would automatically derive 'quiet' from the Q prefix [0].
CHECK_FAIL sounds good, will respin! Thanks!
[0] https://lore.kernel.org/bpf/CAEf4BzbUGiUZBWkTWe2=LfhkXYhQGndN9gR6VTZwfV3eytstUw@mail.gmail.com/ (local)quoted
#define CHECK(condition, tag, format...) \ _CHECK(condition, tag, duration, format) #define CHECK_ATTR(condition, tag, format...) \