tests: Cleanup decompiler test fixtures and try to improve the test output / add a readable report (#1724)

* tests: add a Jak2 `FormRegressionTest` fixture

* tests/ci: minimize test log output and produce a readable report

* improve naming of report due to underlying GitHub issue

* hopefully fix windows handling of this argument

* test...

* final test

* test linux coverage
This commit is contained in:
Tyler Wilding
2022-08-05 12:12:33 -04:00
committed by GitHub
parent 5148523917
commit 8651179aa3
16 changed files with 576 additions and 520 deletions
+83 -84
View File
@@ -5,7 +5,7 @@
using namespace decompiler;
// tests stack variables
TEST_F(FormRegressionTest, MatrixPMult) {
TEST_F(FormRegressionTestJak1, MatrixPMult) {
std::string func =
"sll r0, r0, 0\n"
" daddiu sp, sp, -112\n"
@@ -50,14 +50,14 @@ TEST_F(FormRegressionTest, MatrixPMult) {
" )\n"
" arg0\n"
" )";
test_with_stack_structures_jak1(func, type, expected,
"[\n"
" [16, \"matrix\"]\n"
" ]");
test_with_stack_structures(func, type, expected,
"[\n"
" [16, \"matrix\"]\n"
" ]");
}
// TODO- this should also work without the cast, but be uglier.
TEST_F(FormRegressionTest, VectorXQuaternionWithCast) {
TEST_F(FormRegressionTestJak1, VectorXQuaternionWithCast) {
std::string func =
"sll r0, r0, 0\n"
@@ -96,14 +96,14 @@ TEST_F(FormRegressionTest, VectorXQuaternionWithCast) {
" )\n"
" arg0\n"
" )";
test_with_stack_structures_jak1(func, type, expected,
"[\n"
" [16, \"matrix\"]\n"
" ]",
"[[10, \"v1\", \"(pointer uint128)\"]]");
test_with_stack_structures(func, type, expected,
"[\n"
" [16, \"matrix\"]\n"
" ]",
"[[10, \"v1\", \"(pointer uint128)\"]]");
}
TEST_F(FormRegressionTest, EliminateFloatDeadSet) {
TEST_F(FormRegressionTestJak1, EliminateFloatDeadSet) {
std::string func =
"sll r0, r0, 0\n"
"L32:\n"
@@ -227,10 +227,10 @@ TEST_F(FormRegressionTest, EliminateFloatDeadSet) {
" )\n"
" )\n"
" )";
test_with_stack_structures_jak1(func, type, expected, "[]");
test_with_stack_structures(func, type, expected, "[]");
}
TEST_F(FormRegressionTest, IterateProcessTree) {
TEST_F(FormRegressionTestJak1, IterateProcessTree) {
std::string func =
"sll r0, r0, 0\n"
@@ -319,10 +319,10 @@ TEST_F(FormRegressionTest, IterateProcessTree) {
" )\n"
" s4-0\n"
" )";
test_with_stack_structures_jak1(func, type, expected, "[]");
test_with_stack_structures(func, type, expected, "[]");
}
TEST_F(FormRegressionTest, InspectVifStatBitfield) {
TEST_F(FormRegressionTestJak1, InspectVifStatBitfield) {
std::string func =
"sll r0, r0, 0\n"
@@ -451,21 +451,21 @@ TEST_F(FormRegressionTest, InspectVifStatBitfield) {
" (format #t \"~T ~D~%\" (-> arg0 fqc))\n"
" arg0\n"
" )";
test_with_expr_jak1(func, type, expected, false, "",
{{"L37", "[~8x] ~A~%"},
{"L36", "~T ~D~%"},
{"L35", "~T ~D~%"},
{"L34", "~T ~D~%"},
{"L33", "~T ~D~%"},
{"L32", "~T ~D~%"},
{"L31", "~T ~D~%"},
{"L30", "~T ~D~%"},
{"L29", "~T ~D~%"},
{"L28", "~T ~D~%"},
{"L27", "~T ~D~%"}});
test_with_expr(func, type, expected, false, "",
{{"L37", "[~8x] ~A~%"},
{"L36", "~T ~D~%"},
{"L35", "~T ~D~%"},
{"L34", "~T ~D~%"},
{"L33", "~T ~D~%"},
{"L32", "~T ~D~%"},
{"L31", "~T ~D~%"},
{"L30", "~T ~D~%"},
{"L29", "~T ~D~%"},
{"L28", "~T ~D~%"},
{"L27", "~T ~D~%"}});
}
TEST_F(FormRegressionTest, InspectHandleBitfield) {
TEST_F(FormRegressionTestJak1, InspectHandleBitfield) {
std::string func =
"sll r0, r0, 0\n"
" daddiu sp, sp, -32\n"
@@ -512,12 +512,11 @@ TEST_F(FormRegressionTest, InspectHandleBitfield) {
" (format #t \"~Tpid: ~D~%\" (-> arg0 pid))\n"
" arg0\n"
" )";
test_with_expr_jak1(
func, type, expected, false, "",
{{"L79", "[~8x] ~A~%"}, {"L32", "~Tprocess: #x~X~%"}, {"L31", "~Tpid: ~D~%"}});
test_with_expr(func, type, expected, false, "",
{{"L79", "[~8x] ~A~%"}, {"L32", "~Tprocess: #x~X~%"}, {"L31", "~Tpid: ~D~%"}});
}
TEST_F(FormRegressionTest, InspectDmaTagBitfield) {
TEST_F(FormRegressionTestJak1, InspectDmaTagBitfield) {
std::string func =
"sll r0, r0, 0\n"
" daddiu sp, sp, -32\n"
@@ -599,20 +598,20 @@ TEST_F(FormRegressionTest, InspectDmaTagBitfield) {
" (format #t \"~Ta: ~D~%\" (-> arg0 spr))\n"
" arg0\n"
" )";
test_with_expr_jak1(func, type, expected, false, "",
{
{"L65", "[~8x] ~A~%"},
{"L37", "~Ta: ~D~%"},
{"L36", "~Ta: ~D~%"},
{"L35", "~Ta: ~D~%"},
{"L34", "~Ta: ~D~%"},
{"L33", "~Ta: ~D~%"},
{"L32", "~Ta: ~D~%"},
});
test_with_expr(func, type, expected, false, "",
{
{"L65", "[~8x] ~A~%"},
{"L37", "~Ta: ~D~%"},
{"L36", "~Ta: ~D~%"},
{"L35", "~Ta: ~D~%"},
{"L34", "~Ta: ~D~%"},
{"L33", "~Ta: ~D~%"},
{"L32", "~Ta: ~D~%"},
});
}
// Tests nonzero-check on bitfield
TEST_F(FormRegressionTest, DmaSyncCrash) {
TEST_F(FormRegressionTestJak1, DmaSyncCrash) {
std::string func =
"sll r0, r0, 0\n"
"L46:\n"
@@ -662,10 +661,10 @@ TEST_F(FormRegressionTest, DmaSyncCrash) {
" )\n"
" 0\n"
" )";
test_with_expr_jak1(func, type, expected);
test_with_expr(func, type, expected);
}
TEST_F(FormRegressionTest, DmaSend) {
TEST_F(FormRegressionTestJak1, DmaSend) {
std::string func =
"sll r0, r0, 0\n"
" daddiu sp, sp, -64\n"
@@ -743,10 +742,10 @@ TEST_F(FormRegressionTest, DmaSend) {
" (.sync.l)\n"
" 0\n"
" )";
test_with_expr_jak1(func, type, expected);
test_with_expr(func, type, expected);
}
TEST_F(FormRegressionTest, DmaInitialize) {
TEST_F(FormRegressionTestJak1, DmaInitialize) {
std::string func =
"sll r0, r0, 0\n"
" lui v1, 4096\n"
@@ -777,13 +776,13 @@ TEST_F(FormRegressionTest, DmaInitialize) {
" (set! (-> (the-as vif-bank #x10003c00) err me0) 1)\n"
" 0\n"
" )";
test_with_expr_jak1(func, type, expected, false, "", {},
"[[1, \"v1\", \"vif-bank\"], [8, \"v1\", \"vif-bank\"], [6, \"a0\", "
"\"vif-bank\"], [13, \"a0\", \"vif-bank\"]]");
test_with_expr(func, type, expected, false, "", {},
"[[1, \"v1\", \"vif-bank\"], [8, \"v1\", \"vif-bank\"], [6, \"a0\", "
"\"vif-bank\"], [13, \"a0\", \"vif-bank\"]]");
}
// Dynamic bitfield stuff.
TEST_F(FormRegressionTest, SetDisplayEnv) {
TEST_F(FormRegressionTestJak1, SetDisplayEnv) {
std::string func =
"sll r0, r0, 0\n"
" ori v1, r0, 65441\n"
@@ -860,10 +859,10 @@ TEST_F(FormRegressionTest, SetDisplayEnv) {
" (set! (-> arg0 bgcolor) (new 'static 'gs-bgcolor))\n"
" arg0\n"
" )";
test_with_expr_jak1(func, type, expected);
test_with_expr(func, type, expected);
}
TEST_F(FormRegressionTest, DmaBufferAddVuFunction) {
TEST_F(FormRegressionTestJak1, DmaBufferAddVuFunction) {
std::string func =
"sll r0, r0, 0\n"
" daddiu v1, a1, 16\n"
@@ -975,10 +974,10 @@ TEST_F(FormRegressionTest, DmaBufferAddVuFunction) {
" )\n"
" #f\n"
" )";
test_with_expr_jak1(func, type, expected, false, "", {}, "[[[9, 33], \"t2\", \"dma-packet\"]]");
test_with_expr(func, type, expected, false, "", {}, "[[[9, 33], \"t2\", \"dma-packet\"]]");
}
TEST_F(FormRegressionTest, DmaBucketInsertTag) {
TEST_F(FormRegressionTestJak1, DmaBucketInsertTag) {
std::string func =
"sll r0, r0, 0\n"
" dsll v1, a1, 4\n"
@@ -998,14 +997,14 @@ TEST_F(FormRegressionTest, DmaBucketInsertTag) {
" )\n"
" arg2\n"
" )";
test_with_expr_jak1(func, type, expected, false, "", {},
"[\n"
" [[2, 6], \"v1\", \"dma-bucket\"],\n"
" [3, \"a0\", \"dma-bucket\"]\n"
" ]");
test_with_expr(func, type, expected, false, "", {},
"[\n"
" [[2, 6], \"v1\", \"dma-bucket\"],\n"
" [3, \"a0\", \"dma-bucket\"]\n"
" ]");
}
TEST_F(FormRegressionTest, StupidFloatMove) {
TEST_F(FormRegressionTestJak1, StupidFloatMove) {
std::string func =
"sll r0, r0, 0\n"
" daddiu sp, sp, -48\n"
@@ -1110,11 +1109,11 @@ TEST_F(FormRegressionTest, StupidFloatMove) {
" )\n"
" 0.0\n"
" )";
test_with_expr_jak1(func, type, expected);
test_with_expr(func, type, expected);
}
// gpr->fpr not being propagated
TEST_F(FormRegressionTest, Method11FontContext) {
TEST_F(FormRegressionTestJak1, Method11FontContext) {
std::string func =
"sll r0, r0, 0\n"
" mtc1 f0, a1\n"
@@ -1129,11 +1128,11 @@ TEST_F(FormRegressionTest, Method11FontContext) {
" (set! (-> arg0 origin z) (the float arg1))\n"
" arg0\n"
" )";
test_with_expr_jak1(func, type, expected);
test_with_expr(func, type, expected);
}
// 128-bit bitfields, also type for pextuw
TEST_F(FormRegressionTest, Method4ResTag) {
TEST_F(FormRegressionTestJak1, Method4ResTag) {
std::string func =
"sll r0, r0, 0\n"
"L135:\n"
@@ -1167,10 +1166,10 @@ TEST_F(FormRegressionTest, Method4ResTag) {
" (* (-> arg0 elt-count) (-> arg0 elt-type size))\n"
" )\n"
" )";
test_with_expr_jak1(func, type, expected);
test_with_expr(func, type, expected);
}
TEST_F(FormRegressionTest, MakeSqrtTable) {
TEST_F(FormRegressionTestJak1, MakeSqrtTable) {
std::string func =
"sll r0, r0, 0\n"
"L149:\n"
@@ -1241,12 +1240,12 @@ TEST_F(FormRegressionTest, MakeSqrtTable) {
" 0\n"
" (none)\n"
" )";
test_with_expr_jak1(
test_with_expr(
func, type, expected, false, "",
{{"L190", "static int sqrt_table[256] =~%{~%"}, {"L189", "~D,~%"}, {"L188", "};~%"}});
}
TEST_F(FormRegressionTest, Method2Vec4s) {
TEST_F(FormRegressionTestJak1, Method2Vec4s) {
std::string func =
"sll r0, r0, 0\n"
" daddiu sp, sp, -32\n"
@@ -1289,10 +1288,10 @@ TEST_F(FormRegressionTest, Method2Vec4s) {
" )\n"
" arg0\n"
" )";
test_with_expr_jak1(func, type, expected, false, "", {{"L344", "#<vector ~F ~F ~F ~F @ #x~X>"}});
test_with_expr(func, type, expected, false, "", {{"L344", "#<vector ~F ~F ~F ~F @ #x~X>"}});
}
TEST_F(FormRegressionTest, SoundNameEqual) {
TEST_F(FormRegressionTestJak1, SoundNameEqual) {
std::string func =
"sll r0, r0, 0\n"
" dsubu v1, a0, a1\n"
@@ -1311,10 +1310,10 @@ TEST_F(FormRegressionTest, SoundNameEqual) {
std::string type = "(function sound-name sound-name symbol)";
std::string expected =
"(and (= (the-as uint arg0) (the-as uint arg1)) (= (-> arg0 hi) (-> arg1 hi)))";
test_with_expr_jak1(func, type, expected);
test_with_expr(func, type, expected);
}
TEST_F(FormRegressionTest, DebugMenuFuncDecode) {
TEST_F(FormRegressionTestJak1, DebugMenuFuncDecode) {
std::string func =
"sll r0, r0, 0\n"
" dsll32 v1, a0, 29\n"
@@ -1377,10 +1376,10 @@ TEST_F(FormRegressionTest, DebugMenuFuncDecode) {
" )\n"
" )\n"
" )";
test_with_expr_jak1(func, type, expected, false, "", {}, "[[13, \"a0\", \"symbol\"]]");
test_with_expr(func, type, expected, false, "", {}, "[[13, \"a0\", \"symbol\"]]");
}
TEST_F(FormRegressionTest, MatrixNewInlineProp) {
TEST_F(FormRegressionTestJak1, MatrixNewInlineProp) {
std::string func =
"sll r0, r0, 0\n"
" daddiu sp, sp, -112\n"
@@ -1432,10 +1431,10 @@ TEST_F(FormRegressionTest, MatrixNewInlineProp) {
" )\n"
" arg0\n"
" )";
test_with_stack_structures_jak1(func, type, expected, R"([[16, "matrix"]])");
test_with_stack_structures(func, type, expected, R"([[16, "matrix"]])");
}
TEST_F(FormRegressionTest, VectorNewInlineProp) {
TEST_F(FormRegressionTestJak1, VectorNewInlineProp) {
std::string func =
"sll r0, r0, 0\n"
" daddiu sp, sp, -64\n"
@@ -1492,10 +1491,10 @@ TEST_F(FormRegressionTest, VectorNewInlineProp) {
" )\n"
" arg0\n"
" )";
test_with_stack_structures_jak1(func, type, expected, R"([[16, "vector"]])");
test_with_stack_structures(func, type, expected, R"([[16, "vector"]])");
}
TEST_F(FormRegressionTest, Method23Trsqv) {
TEST_F(FormRegressionTestJak1, Method23Trsqv) {
std::string func =
"sll r0, r0, 0\n"
" daddiu sp, sp, -32\n"
@@ -1518,10 +1517,10 @@ TEST_F(FormRegressionTest, Method23Trsqv) {
std::string type = "(function trsqv vector float)";
std::string expected =
"(vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg1 (-> arg0 trans)))";
test_with_stack_structures_jak1(func, type, expected, R"([[16, "vector"]])");
test_with_stack_structures(func, type, expected, R"([[16, "vector"]])");
}
TEST_F(FormRegressionTest, VectorLineDistance) {
TEST_F(FormRegressionTestJak1, VectorLineDistance) {
std::string func =
"sll r0, r0, 0\n"
"\n"
@@ -1613,6 +1612,6 @@ TEST_F(FormRegressionTest, VectorLineDistance) {
" )\n"
" (vector-length (vector-! (new-stack-vector0) gp-1 v1-3))\n"
" )";
test_with_stack_structures_jak1(
func, type, expected, R"([[16, "vector"], [32, "vector"], [48, "vector"], [64, "vector"]])");
test_with_stack_structures(func, type, expected,
R"([[16, "vector"], [32, "vector"], [48, "vector"], [64, "vector"]])");
}