0

Is possible to suppress unit test functions? I have address sanitizer in my project and I am getting reports with info about stack-buffer-overflow, which I want to supress.

It's already one stackoverflow page with similar problem here , but solution for this question is not what I want to have (I don't want to disable test).

For example

TEST_F(classA, testA) {
  some_struct a;
  a.p = 100;
  ASSERT_FALSE(&foo());
}

I want to not use address sanitizer in this test. Test should be run but I don't want to have any address sanitizer report

daasz
  • 9
  • 5
  • Usually test runners run several tests built with different configs, for example test+coverage, test+address, test+ub, test+thread. Disabling one test case when it is built for address-sanitizer is a good solution, a disabled test case will run in other build configs. – 273K Dec 22 '21 at 17:44

1 Answers1

0

I am getting reports with info about stack-buffer-overflow, which I want to supress.

If you are going to just ignore errors, one solution is to not to test with address sanitizer at all.

I want to not use address sanitizer in this test.

If you want to suppress sanitizer reports for this particular test case, while keeping the sanitizer for other test cases within this source file, using disable_sanitizer_instrumentation attribute might do the trick.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362