test: exploitability: Fix preprocessor guards for Linux

Guard the Linux specific tests by checking for __linux__, as it does
not only not work on Windows but not on macOS either.
Change-Id: I0e710a6da8e6686f11bc8ea23e07ac19f3b4beb2
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3928026
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Marvin Scholz 2022-09-30 14:12:02 +02:00 committed by Mike Frysinger
parent e3af4457b8
commit bcffe4fe60

View file

@ -37,12 +37,12 @@
#include "google_breakpad/processor/basic_source_line_resolver.h"
#include "google_breakpad/processor/minidump_processor.h"
#include "google_breakpad/processor/process_state.h"
#ifndef _WIN32
#ifdef __linux__
#include "processor/exploitability_linux.h"
#endif // _WIN32
#endif // __linux__
#include "processor/simple_symbol_supplier.h"
#ifndef _WIN32
#ifdef __linux__
namespace google_breakpad {
class ExploitabilityLinuxTest : public ExploitabilityLinux {
@ -64,15 +64,15 @@ class ExploitabilityLinuxTestMinidumpContext : public MinidumpContext {
};
} // namespace google_breakpad
#endif // _WIN32
#endif // __linux__
namespace {
using google_breakpad::BasicSourceLineResolver;
#ifndef _WIN32
#ifdef __linux__
using google_breakpad::ExploitabilityLinuxTest;
using google_breakpad::ExploitabilityLinuxTestMinidumpContext;
#endif // _WIN32
#endif // __linux__
using google_breakpad::MinidumpProcessor;
using google_breakpad::ProcessState;
using google_breakpad::SimpleSymbolSupplier;
@ -171,7 +171,7 @@ TEST(ExploitabilityTest, TestLinuxEngine) {
ExploitabilityFor("linux_executable_heap.dmp"));
ASSERT_EQ(google_breakpad::EXPLOITABILITY_HIGH,
ExploitabilityFor("linux_jmp_to_module_not_exe_region.dmp"));
#ifndef _WIN32
#ifdef __linux__
ASSERT_EQ(google_breakpad::EXPLOITABILITY_HIGH,
ExploitabilityFor("linux_write_to_nonwritable_module.dmp"));
ASSERT_EQ(google_breakpad::EXPLOITABILITY_HIGH,
@ -182,10 +182,10 @@ TEST(ExploitabilityTest, TestLinuxEngine) {
ExploitabilityFor("linux_write_to_outside_module_via_math.dmp"));
ASSERT_EQ(google_breakpad::EXPLOITABILITY_INTERESTING,
ExploitabilityFor("linux_write_to_under_4k.dmp"));
#endif // _WIN32
#endif // __linux__
}
#ifndef _WIN32
#ifdef __linux__
TEST(ExploitabilityLinuxUtilsTest, DisassembleBytesTest) {
ASSERT_FALSE(ExploitabilityLinuxTest::DisassembleBytes("", NULL, 0, 5, NULL));
uint8_t bytes[6] = {0xc7, 0x0, 0x5, 0x0, 0x0, 0x0};
@ -299,6 +299,6 @@ TEST(ExploitabilityLinuxUtilsTest, CalculateAddressTest) {
context,
&write_address));
}
#endif // _WIN32
#endif // __linux__
} // namespace