From a44475207c470be9c222b7ccaaed699505906fe1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 20 Jul 2018 17:48:43 -0400 Subject: [PATCH 1/3] arm_test_common: Add missing header guard --- src/tests/core/arm/arm_test_common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tests/core/arm/arm_test_common.h b/src/tests/core/arm/arm_test_common.h index b66922d61e..368f6f6c72 100644 --- a/src/tests/core/arm/arm_test_common.h +++ b/src/tests/core/arm/arm_test_common.h @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#pragma once + #include #include #include From a8bb1eb39fe2cf62545798a493f6350c3d1d5728 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 20 Jul 2018 17:51:29 -0400 Subject: [PATCH 2/3] arm_test_common: Make file static variable a member variable of the testing environment Gets rid of file-static behavior. --- src/tests/core/arm/arm_test_common.cpp | 2 -- src/tests/core/arm/arm_test_common.h | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tests/core/arm/arm_test_common.cpp b/src/tests/core/arm/arm_test_common.cpp index 7f9f27e192..2af487b6a4 100644 --- a/src/tests/core/arm/arm_test_common.cpp +++ b/src/tests/core/arm/arm_test_common.cpp @@ -10,8 +10,6 @@ namespace ArmTests { -static Memory::PageTable* page_table = nullptr; - TestEnvironment::TestEnvironment(bool mutable_memory_) : mutable_memory(mutable_memory_), test_memory(std::make_shared(this)) { diff --git a/src/tests/core/arm/arm_test_common.h b/src/tests/core/arm/arm_test_common.h index 368f6f6c72..7fdbda494c 100644 --- a/src/tests/core/arm/arm_test_common.h +++ b/src/tests/core/arm/arm_test_common.h @@ -11,6 +11,10 @@ #include "common/common_types.h" #include "core/memory_hook.h" +namespace Memory { +struct PageTable; +} + namespace ArmTests { struct WriteRecord { @@ -81,6 +85,7 @@ private: bool mutable_memory; std::shared_ptr test_memory; std::vector write_records; + Memory::PageTable* page_table = nullptr; }; } // namespace ArmTests From 48733744bb38d3a18af9713096f6e9b729944bb2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 20 Jul 2018 17:53:50 -0400 Subject: [PATCH 3/3] arm_test_common: Get rid of truncation warnings Explicitly cast the value to a u8 to show that this is intentional. --- src/tests/core/arm/arm_test_common.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tests/core/arm/arm_test_common.cpp b/src/tests/core/arm/arm_test_common.cpp index 2af487b6a4..539746246b 100644 --- a/src/tests/core/arm/arm_test_common.cpp +++ b/src/tests/core/arm/arm_test_common.cpp @@ -65,10 +65,13 @@ boost::optional TestEnvironment::TestMemory::IsValidAddress(VAddr addr) { } boost::optional TestEnvironment::TestMemory::Read8(VAddr addr) { - auto iter = data.find(addr); + const auto iter = data.find(addr); + if (iter == data.end()) { - return addr; // Some arbitrary data + // Some arbitrary data + return static_cast(addr); } + return iter->second; }