From fe1da2b50694609be375b2950245c71ddc379595 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Sun, 1 Dec 2024 22:17:42 -0800 Subject: [PATCH] Skip a test that will fail with ubsan in case that sanitizer is enabled. UBSAN is good in knowing beforehand that tests some out-of-range mitigation, that the value in question is indeed out of range and will complain. --- verible/verilog/formatting/verilog-token_test.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/verible/verilog/formatting/verilog-token_test.cc b/verible/verilog/formatting/verilog-token_test.cc index 9db52d83b..af5ffb476 100644 --- a/verible/verilog/formatting/verilog-token_test.cc +++ b/verible/verilog/formatting/verilog-token_test.cc @@ -25,6 +25,8 @@ namespace { using FTT = FormatTokenType; +// UBSAN check will notice, that 9999 is out of range; skip test in that case +#ifndef UNDEFINED_BEHAVIOR_SANITIZER // Test that GetFormatTokenType() correctly converts a TokenInfo enum to FTT TEST(VerilogTokenTest, GetFormatTokenTypeTestUnknown) { const int FAKE_TOKEN = 9999; @@ -32,6 +34,7 @@ TEST(VerilogTokenTest, GetFormatTokenTypeTestUnknown) { verible::PreFormatToken format_token(&token_info); EXPECT_EQ(FTT::unknown, GetFormatTokenType(verilog_tokentype(FAKE_TOKEN))); } +#endif struct GetFormatTokenTypeTestCase { verilog_tokentype token_info_type;