reduce counter.enabled checking in test_perf_event.cc
authorYonghong Song <yhs@fb.com>
Wed, 20 Oct 2021 06:17:40 +0000 (23:17 -0700)
committeryonghong-song <ys114321@gmail.com>
Wed, 20 Oct 2021 15:07:40 +0000 (08:07 -0700)
The test "attach perf event" is often flaky with the failure:

  3: /home/fedora/jenkins/workspace/bcc-pr/label/fc28/tests/cc/test_perf_event.cc:139: FAILED:
  3:   REQUIRE( counter.enabled >= 800000000 )
  3: with expansion:
  3:   774406106 (0x2e287fda)
  3:   >=
  3:   800000000 (0x2faf0800)

Previous workaround with 800000000 nano-second doesn't work 100%.
Let us change to 200000000 nano-second.

Signed-off-by: Yonghong Song <yhs@fb.com>
tests/cc/test_perf_event.cc

index b3b26031f0c68c044ba42b406e866dedf08fa8b5..d2a7b9abeed86c6e8d017b959633a9a29b891c99 100644 (file)
@@ -135,8 +135,9 @@ TEST_CASE("test attach perf event", "[bpf_perf_event]") {
   // the program slept one second between perf_event attachment and detachment
   // in the above, so the enabled counter should be 1000000000ns or
   // more. But in reality, most of counters (if not all) are 9xxxxxxxx,
-  // and I also saw one 8xxxxxxxx. So let us a little bit conservative here.
-  REQUIRE(counter.enabled >= 800000000);
+  // and I also saw 7xxxxxxxx. So let us a little bit conservative here and
+  // set 200000000 to avoie test flakiness.
+  REQUIRE(counter.enabled >= 200000000);
   REQUIRE(counter.running >= 0);
   REQUIRE(counter.running <= counter.enabled);
 #endif