Thread (7 messages) 7 messages, 3 authors, 2019-08-21

Re: [PATCH bpf-next v2 2/4] selftests/bpf: test_progs: remove global fail/success counts

From: Daniel Borkmann <daniel@iogearbox.net>
Date: 2019-08-21 12:17:07
Also in: bpf

On 8/19/19 9:17 PM, Stanislav Fomichev wrote:
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.
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 hunk ↗ jump to hunk
@@ -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].

   [0] https://lore.kernel.org/bpf/CAEf4BzbUGiUZBWkTWe2=LfhkXYhQGndN9gR6VTZwfV3eytstUw@mail.gmail.com/ (local)
  #define CHECK(condition, tag, format...) \
  	_CHECK(condition, tag, duration, format)
  #define CHECK_ATTR(condition, tag, format...) \
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help