From 3cb0976367205aff969a6eda1c3b601e40c7f24e Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Mon, 13 Jun 2022 17:03:19 -0700 Subject: [PATCH] UnitTests: Use hermes.s as part of an actual test Before, the file just existed as the source code for HermesBinary.cpp, but we can test that things assemble correctly too (compare DSPTestBinary.cpp and DSPTestText.cpp). A bit of jank is needed due to MSVC limitations (see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2026?view=msvc-170). --- Source/UnitTests/Core/CMakeLists.txt | 1 + Source/UnitTests/Core/DSP/DSPAssemblyTest.cpp | 15 ++++++--------- .../Core/DSP/{hermes.s => HermesText.cpp} | 10 ++++++++-- Source/UnitTests/Core/DSP/HermesText.h | 8 ++++++++ Source/UnitTests/UnitTests.vcxproj | 2 ++ 5 files changed, 25 insertions(+), 11 deletions(-) rename Source/UnitTests/Core/DSP/{hermes.s => HermesText.cpp} (97%) create mode 100644 Source/UnitTests/Core/DSP/HermesText.h diff --git a/Source/UnitTests/Core/CMakeLists.txt b/Source/UnitTests/Core/CMakeLists.txt index 134f7da78b..1e24489239 100644 --- a/Source/UnitTests/Core/CMakeLists.txt +++ b/Source/UnitTests/Core/CMakeLists.txt @@ -8,6 +8,7 @@ add_dolphin_test(DSPAssemblyTest DSP/DSPTestBinary.cpp DSP/DSPTestText.cpp DSP/HermesBinary.cpp + DSP/HermesText.cpp ) add_dolphin_test(ESFormatsTest IOS/ES/FormatsTest.cpp) diff --git a/Source/UnitTests/Core/DSP/DSPAssemblyTest.cpp b/Source/UnitTests/Core/DSP/DSPAssemblyTest.cpp index dd3c96e194..ecd543d168 100644 --- a/Source/UnitTests/Core/DSP/DSPAssemblyTest.cpp +++ b/Source/UnitTests/Core/DSP/DSPAssemblyTest.cpp @@ -8,6 +8,7 @@ #include "DSPTestBinary.h" #include "DSPTestText.h" #include "HermesBinary.h" +#include "HermesText.h" #include @@ -129,6 +130,11 @@ TEST(DSPAssembly, ExtendedInstructions) " ADDAXL'MV $ACC1, $AX1.L : $AX1.H, $AC1.M\n")); } +TEST(DSPAssembly, HermesText) +{ + ASSERT_TRUE(SuperTrip(s_hermes_text)); +} + TEST(DSPAssembly, HermesBinary) { ASSERT_TRUE(RoundTrip(s_hermes_bin)); @@ -143,12 +149,3 @@ TEST(DSPAssembly, DSPTestBinary) { ASSERT_TRUE(RoundTrip(s_dsp_test_bin)); } - -/* - -if (File::ReadFileToString("C:/devkitPro/examples/wii/asndlib/dsptest/dsp_test.ds", &dsp_test)) - SuperTrip(dsp_test.c_str()); - -//.File::ReadFileToString("C:/devkitPro/trunk/libogc/libasnd/dsp_mixer/dsp_mixer.s", &dsp_test); -// This is CLOSE to working. Sorry about the local path btw. This is preliminary code. -*/ diff --git a/Source/UnitTests/Core/DSP/hermes.s b/Source/UnitTests/Core/DSP/HermesText.cpp similarity index 97% rename from Source/UnitTests/Core/DSP/hermes.s rename to Source/UnitTests/Core/DSP/HermesText.cpp index d5418a578a..1b643a0c9b 100644 --- a/Source/UnitTests/Core/DSP/hermes.s +++ b/Source/UnitTests/Core/DSP/HermesText.cpp @@ -9,7 +9,9 @@ SPDX-License-Identifier: BSD-3-Clause */ +#include "HermesText.h" +const char s_hermes_text[21370] = R"( /********************************/ /** REGISTER NAMES **/ /********************************/ @@ -542,7 +544,11 @@ no_delay: ///////////////////////////////////// // end of delay time section ///////////////////////////////////// - +)" // Work around C2026 on MSVC, which allows at most 16380 single-byte characters in a single + // non-concatenated string literal (but you can concatenate multiple shorter string literals to + // produce a longer string just fine). (This comment is not part of the actual test program, + // and instead there is a single blank line at this location.) + R"( /* bucle de generacion de samples */ @@ -1077,4 +1083,4 @@ polla_loca: clr $ACC0 jmp recv_cmd - +)"; diff --git a/Source/UnitTests/Core/DSP/HermesText.h b/Source/UnitTests/Core/DSP/HermesText.h new file mode 100644 index 0000000000..99c16686e2 --- /dev/null +++ b/Source/UnitTests/Core/DSP/HermesText.h @@ -0,0 +1,8 @@ +// Copyright 2022 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +extern const char s_hermes_text[21370]; diff --git a/Source/UnitTests/UnitTests.vcxproj b/Source/UnitTests/UnitTests.vcxproj index b13cab4d0d..da461087e9 100644 --- a/Source/UnitTests/UnitTests.vcxproj +++ b/Source/UnitTests/UnitTests.vcxproj @@ -28,6 +28,7 @@ + @@ -60,6 +61,7 @@ +