Cleanup goalc tests, fix jak2 kernel bugs (#1669)

* Cleanup goalc tests, fix jak2 kernel bugs

* fix warnings on linux

* spelling is hard
This commit is contained in:
water111
2022-07-17 14:12:11 -04:00
committed by GitHub
parent 12fd8a09b1
commit e9567a6e4b
25 changed files with 1312 additions and 1020 deletions
+25 -41
View File
@@ -1,21 +1,11 @@
#include <chrono>
#include <cstdio>
#include <iostream>
#include <random>
#include <sstream>
#include <string>
#include <thread>
#include "inja.hpp"
#include "game/runtime.h"
#include "goalc/compiler/Compiler.h"
#include "goalc/listener/Listener.h"
#include "gtest/gtest.h"
#include "test/goalc/framework/test_runner.h"
#include "third-party/json.hpp"
struct VariableParam {
// TODO - Not Needed Yet
};
@@ -24,7 +14,7 @@ class VariableTests : public testing::TestWithParam<VariableParam> {
public:
static void SetUpTestSuite() {
shared_compiler = std::make_unique<SharedCompiler>(GameVersion::Jak1);
shared_compiler->runtime_thread = std::thread((GoalTest::runtime_no_kernel));
shared_compiler->runtime_thread = std::thread(GoalTest::runtime_no_kernel_jak1);
shared_compiler->runner.c = &shared_compiler->compiler;
}
@@ -51,91 +41,85 @@ class VariableTests : public testing::TestWithParam<VariableParam> {
static std::unique_ptr<SharedCompiler> shared_compiler;
std::string testCategory = "variables";
inja::Environment env{GoalTest::getTemplateDir(testCategory),
GoalTest::getGeneratedDir(testCategory)};
};
std::unique_ptr<VariableTests::SharedCompiler> VariableTests::shared_compiler;
TEST_F(VariableTests, Globals) {
shared_compiler->runner.run_static_test(env, testCategory, "defglobalconstant-1.static.gc",
{"17\n"});
shared_compiler->runner.run_static_test(env, testCategory, "defglobalconstant-2.static.gc",
{"18\n"});
shared_compiler->runner.run_static_test(testCategory, "defglobalconstant-1.static.gc", {"17\n"});
shared_compiler->runner.run_static_test(testCategory, "defglobalconstant-2.static.gc", {"18\n"});
}
TEST_F(VariableTests, Definitions) {
shared_compiler->runner.run_static_test(env, testCategory, "define.static.gc", {"17\n"});
shared_compiler->runner.run_static_test(testCategory, "define.static.gc", {"17\n"});
}
TEST_F(VariableTests, Let) {
shared_compiler->runner.run_static_test(env, testCategory, "let.static.gc", {"30\n"});
shared_compiler->runner.run_static_test(env, testCategory, "let-star.static.gc", {"30\n"});
shared_compiler->runner.run_static_test(env, testCategory, "mlet.static.gc", {"10\n"});
shared_compiler->runner.run_static_test(testCategory, "let.static.gc", {"30\n"});
shared_compiler->runner.run_static_test(testCategory, "let-star.static.gc", {"30\n"});
shared_compiler->runner.run_static_test(testCategory, "mlet.static.gc", {"10\n"});
}
TEST_F(VariableTests, StackVars) {
shared_compiler->runner.run_static_test(env, testCategory, "stack-ints.gc", {"12\n"});
shared_compiler->runner.run_static_test(env, testCategory, "stack-ints-2.gc", {"1\n"});
shared_compiler->runner.run_static_test(testCategory, "stack-ints.gc", {"12\n"});
shared_compiler->runner.run_static_test(testCategory, "stack-ints-2.gc", {"1\n"});
}
TEST_F(VariableTests, Bitfields) {
shared_compiler->runner.run_static_test(env, testCategory, "bitfield-enums.gc", {"5\n"});
shared_compiler->runner.run_static_test(env, testCategory, "integer-enums.gc", {"11\n"});
shared_compiler->runner.run_static_test(testCategory, "bitfield-enums.gc", {"5\n"});
shared_compiler->runner.run_static_test(testCategory, "integer-enums.gc", {"11\n"});
}
TEST_F(VariableTests, InlineAsm) {
shared_compiler->runner.run_static_test(env, testCategory, "inline-asm.static.gc", {"1\n"});
shared_compiler->runner.run_static_test(testCategory, "inline-asm.static.gc", {"1\n"});
}
TEST_F(VariableTests, StaticBitfieldField) {
shared_compiler->runner.run_static_test(env, testCategory, "static-bitfield-field.gc", {"22\n"});
shared_compiler->runner.run_static_test(testCategory, "static-bitfield-field.gc", {"22\n"});
}
TEST_F(VariableTests, StackArrayAlignment) {
shared_compiler->runner.run_static_test(env, testCategory, "stack-array-align.gc", {"3\n"});
shared_compiler->runner.run_static_test(testCategory, "stack-array-align.gc", {"3\n"});
}
TEST_F(VariableTests, StackStructureAlignment) {
shared_compiler->runner.run_static_test(env, testCategory, "stack-structure-align.gc",
{"1234\n"});
shared_compiler->runner.run_static_test(testCategory, "stack-structure-align.gc", {"1234\n"});
}
TEST_F(VariableTests, GetSymbol) {
shared_compiler->runner.run_static_test(env, testCategory, "get-symbol-1.static.gc",
shared_compiler->runner.run_static_test(testCategory, "get-symbol-1.static.gc",
{"1375524\n"}); // 0x14fd24 in hex
shared_compiler->runner.run_static_test(env, testCategory, "get-symbol-2.static.gc",
shared_compiler->runner.run_static_test(testCategory, "get-symbol-2.static.gc",
{"1375532\n"}); // 0x14fd2c in hex
}
TEST_F(VariableTests, Constants) {
// TODO - shared_compiler->runner.run_static_test(env, testCategory,
// TODO - shared_compiler->runner.run_static_test(testCategory,
// "string-constant-1.static.gc");
std::string expected = "\"test string!\"";
shared_compiler->runner.run_static_test(env, testCategory, "string-constant-2.static.gc",
{expected}, expected.size());
shared_compiler->runner.run_static_test(testCategory, "string-constant-2.static.gc", {expected},
expected.size());
}
TEST_F(VariableTests, Symbols) {
shared_compiler->runner.run_static_test(env, testCategory, "quote-symbol.static.gc",
{"banana\n0\n"});
shared_compiler->runner.run_static_test(testCategory, "quote-symbol.static.gc", {"banana\n0\n"});
std::string expected = "test-string";
shared_compiler->runner.run_static_test(env, testCategory, "string-symbol.static.gc", {expected},
shared_compiler->runner.run_static_test(testCategory, "string-symbol.static.gc", {expected},
expected.size());
}
TEST_F(VariableTests, Formatting) {
shared_compiler->runner.run_static_test(env, testCategory, "format-reg-order.static.gc",
shared_compiler->runner.run_static_test(testCategory, "format-reg-order.static.gc",
{"test 1 2 3 4 5 6\n0\n"});
}
TEST_F(VariableTests, DeReference) {
shared_compiler->runner.run_static_test(env, testCategory, "deref-simple.static.gc",
shared_compiler->runner.run_static_test(testCategory, "deref-simple.static.gc",
{"structure\n0\n"});
}
TEST_F(VariableTests, Pointers) {
shared_compiler->runner.run_static_test(env, testCategory, "pointers.static.gc", {"13\n"});
shared_compiler->runner.run_static_test(testCategory, "pointers.static.gc", {"13\n"});
}
// expected =