Tests: Parallelize the testing of multiple images in one binary

This commit is contained in:
Katy Coe
2020-12-21 04:58:47 +01:00
parent 66cdbad766
commit b19ef87ed2

View File

@@ -7,6 +7,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using Il2CppInspector.Cpp; using Il2CppInspector.Cpp;
using Il2CppInspector.Model; using Il2CppInspector.Model;
using Il2CppInspector.Outputs; using Il2CppInspector.Outputs;
@@ -51,11 +52,11 @@ namespace Il2CppInspector
throw new Exception("Could not find any images in the IL2CPP binary"); throw new Exception("Could not find any images in the IL2CPP binary");
// Dump each image in the binary separately // Dump each image in the binary separately
int i = 0;
foreach (var il2cpp in inspectors) { Parallel.ForEach(inspectors, il2cpp => {
var model = new TypeModel(il2cpp); var model = new TypeModel(il2cpp);
var appModel = new AppModel(model, makeDefaultBuild: false).Build(compiler: CppCompilerType.MSVC); var appModel = new AppModel(model, makeDefaultBuild: false).Build(compiler: CppCompilerType.MSVC);
var nameSuffix = i++ > 0 ? "-" + (i - 1) : ""; var nameSuffix = "-" + il2cpp.BinaryImage.Arch.ToLower();
new CSharpCodeStubs(model) { new CSharpCodeStubs(model) {
ExcludedNamespaces = Constants.DefaultExcludedNamespaces, ExcludedNamespaces = Constants.DefaultExcludedNamespaces,
@@ -74,11 +75,11 @@ namespace Il2CppInspector
python.WriteScriptToFile(testPath + $@"\test-{target.ToLower()}{nameSuffix}.py", target, python.WriteScriptToFile(testPath + $@"\test-{target.ToLower()}{nameSuffix}.py", target,
testPath + $@"\test-cpp-result{nameSuffix}\appdata\il2cpp-types.h", testPath + $@"\test-cpp-result{nameSuffix}\appdata\il2cpp-types.h",
testPath + $@"\test-result{nameSuffix}.json"); testPath + $@"\test-result{nameSuffix}.json");
} });
// Compare test results with expected results // Compare test results with expected results
for (i = 0; i < inspectors.Count; i++) { foreach (var il2cpp in inspectors) {
var suffix = (i > 0 ? "-" + i : ""); var suffix = "-" + il2cpp.BinaryImage.Arch.ToLower();
compareFiles(testPath, suffix + ".cs", $"test-result{suffix}.cs"); compareFiles(testPath, suffix + ".cs", $"test-result{suffix}.cs");
compareFiles(testPath, suffix + ".json", $"test-result{suffix}.json"); compareFiles(testPath, suffix + ".json", $"test-result{suffix}.json");