test_generator: Expose interface

This commit is contained in:
Merry 2022-11-27 14:08:29 +00:00 committed by Liam
parent 26cef90d81
commit 890deb17ce
2 changed files with 59 additions and 14 deletions

View file

@ -79,6 +79,23 @@ jobs:
working-directory: ${{github.workspace}} working-directory: ${{github.workspace}}
run: qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_tests -d yes run: qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_tests -d yes
- name: Test against x86_64 implementation - name: Test against x86_64 implementation (A32, thumb)
working-directory: ${{github.workspace}} working-directory: ${{github.workspace}}
run: diff <(qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_test_generator) <(./build-x64/tests/dynarmic_test_generator) run: |
diff <(qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_test_generator thumb 42 1 100000) <(./build-x64/tests/dynarmic_test_generator thumb 42 1 100000)
diff <(qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_test_generator thumb 42 10 10000) <(./build-x64/tests/dynarmic_test_generator thumb 42 10 10000)
diff <(qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_test_generator thumb 42 100 1000) <(./build-x64/tests/dynarmic_test_generator thumb 42 100 1000)
- name: Test against x86_64 implementation (A32, arm)
working-directory: ${{github.workspace}}
run: |
diff <(qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_test_generator arm 42 1 100000) <(./build-x64/tests/dynarmic_test_generator arm 42 1 100000)
diff <(qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_test_generator arm 42 10 10000) <(./build-x64/tests/dynarmic_test_generator arm 42 10 10000)
diff <(qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_test_generator arm 42 100 1000) <(./build-x64/tests/dynarmic_test_generator arm 42 100 1000)
- name: Test against x86_64 implementation (A64)
working-directory: ${{github.workspace}}
run: |
diff <(qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_test_generator a64 42 1 100000) <(./build-x64/tests/dynarmic_test_generator a64 42 1 100000)
diff <(qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_test_generator a64 42 10 10000) <(./build-x64/tests/dynarmic_test_generator a64 42 10 10000)
diff <(qemu-aarch64 -L /usr/aarch64-linux-gnu ./build-arm64/tests/dynarmic_test_generator a64 42 100 1000) <(./build-x64/tests/dynarmic_test_generator a64 42 100 1000)

View file

@ -6,7 +6,10 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <cstdio> #include <cstdio>
#include <cstdlib>
#include <functional> #include <functional>
#include <limits>
#include <optional>
#include <tuple> #include <tuple>
#include <vector> #include <vector>
@ -642,21 +645,46 @@ void TestA64(size_t num_instructions, size_t num_iterations) {
} }
} }
int main(int, char*[]) { static std::optional<size_t> str2sz(char const* s) {
detail::g_rand_int_generator.seed(42069); char* end = nullptr;
errno = 0;
TestThumb(1, 1); const long l = std::strtol(s, &end, 10);
TestArm(1, 1); if (errno == ERANGE || l > std::numeric_limits<size_t>::max() || l < 0) {
TestA64(1, 1); return std::nullopt;
}
if (*s == '\0' || *end != '\0') {
return std::nullopt;
}
return static_cast<size_t>(l);
}
TestA64(1, 10000); int main(int argc, char* argv[]) {
if (argc != 5) {
fmt::print("Usage: {} <thumb|arm|a64> <seed> <instruction_count> <iteration_count>\n", argv[0]);
}
// TestThumb(1, 100000); const auto seed = str2sz(argv[2]);
// TestArm(1, 100000); const auto instruction_count = str2sz(argv[3]);
// TestThumb(5, 100000); const auto iterator_count = str2sz(argv[4]);
// TestArm(5, 100000);
// TestThumb(1024, 10000); if (!seed || !instruction_count || !iterator_count) {
// TestArm(1024, 10000); fmt::print("invalid numeric arguments\n");
return 1;
}
detail::g_rand_int_generator.seed(*seed);
if (strcmp(argv[1], "thumb") == 0) {
TestThumb(*instruction_count, *iterator_count);
} else if (strcmp(argv[1], "arm") == 0) {
TestArm(*instruction_count, *iterator_count);
} else if (strcmp(argv[1], "a64") == 0) {
TestA64(*instruction_count, *iterator_count);
} else {
fmt::print("unrecognized instruction class\n");
return 1;
}
return 0; return 0;
} }