mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2024-11-27 17:00:40 +00:00
!2625 Fix Runtime Core UT Problems
Merge pull request !2625 from Principe/UT
This commit is contained in:
commit
eea247f279
@ -170,10 +170,9 @@ HWTEST_F(GraphClonerTest, graph_cloner_test_002, TestSize.Level1)
|
||||
|
||||
EXPECT_TRUE(graph->RunPass<LoopAnalyzer>());
|
||||
|
||||
GraphCloner cloner(graph, graph->GetAllocator(), graph->GetLocalAllocator());
|
||||
|
||||
ForEachNonRootLoop(graph, [&graph](Loop *loop) {
|
||||
auto graph_clone = CloneGraph(graph);
|
||||
auto graph_clone = CloneGraph(graph);
|
||||
EXPECT_TRUE(GraphComparator().Compare(graph, graph_clone));
|
||||
ForEachNonRootLoop(graph_clone, [&graph_clone](Loop *loop) {
|
||||
auto blocks = graph_clone->GetVectorBlocks();
|
||||
auto header = blocks[loop->GetHeader()->GetId()];
|
||||
auto preheader = blocks[loop->GetPreHeader()->GetId()];
|
||||
|
@ -91,6 +91,33 @@ public:
|
||||
options.SetCompilerDumpStatsCsv(option_dump_stats_csv_);
|
||||
options.SetCompilerDumpFolder(option_dump_folder_);
|
||||
}
|
||||
|
||||
// The file name matching rules are as follows
|
||||
// because the file name is generated by the PassManager::GetFileName method
|
||||
// The first is the execution_counter variable, which indicates the number of RunPass executions
|
||||
// When in debug mode, the GraphChecker(graph_).Check() method is executed, which runs RunPass several times
|
||||
// Therefore, when verifying whether the file is generated correctly
|
||||
// only the other parts of the file match except execution_counter
|
||||
// for example : when file:"2_b_c.txt" target_file:"_b_c.txt" return true
|
||||
static bool FileNameEquals(const std::string &file, const std::string &target_file)
|
||||
{
|
||||
size_t length = target_file.length();
|
||||
if (file.length() < length) {
|
||||
return false;
|
||||
}
|
||||
return file.substr(file.length() - length) == target_file;
|
||||
}
|
||||
|
||||
static bool FileExists(const std::string &path, const std::string &filename)
|
||||
{
|
||||
for (const auto &entry : std::filesystem::directory_iterator(path)) {
|
||||
std::string file = entry.path().filename().string();
|
||||
if (FileNameEquals(file, filename)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool option_enable_ir_stats_;
|
||||
bool option_print_stats_;
|
||||
@ -238,9 +265,12 @@ HWTEST_F(PassManagerTest, pass_manager_test_003, TestSize.Level1)
|
||||
graph->RunPass<ValNum>();
|
||||
graph->RunPass<Cleanup>();
|
||||
options.SetCompilerDump(false);
|
||||
|
||||
EXPECT_TRUE(std::filesystem::exists(outdir + "/846_pass_0006_L_GLOBAL_____loop1_GVN.ir"));
|
||||
EXPECT_TRUE(std::filesystem::exists(outdir + "/846_pass_0007_L_GLOBAL_____loop1_Cleanup.ir"));
|
||||
|
||||
std::string expected_gvn = "_pass_0006_L_GLOBAL_____loop1_GVN.ir";
|
||||
std::string expected_cleanup = "_pass_0007_L_GLOBAL_____loop1_Cleanup.ir";
|
||||
|
||||
EXPECT_TRUE(PassManagerTest::FileExists(outdir, expected_gvn));
|
||||
EXPECT_TRUE(PassManagerTest::FileExists(outdir, expected_cleanup));
|
||||
|
||||
status = true;
|
||||
});
|
||||
@ -271,7 +301,7 @@ HWTEST_F(PassManagerTest, pass_manager_test_004, TestSize.Level1)
|
||||
RegAlloc(graph);
|
||||
options.SetCompilerDumpLifeIntervals(false);
|
||||
|
||||
EXPECT_TRUE(std::filesystem::exists(outdir + "/854_pass_0008_L_GLOBAL_____loop1_RegAllocGraphColoring.li"));
|
||||
EXPECT_TRUE(PassManagerTest::FileExists(outdir, "_pass_0008_L_GLOBAL_____loop1_RegAllocGraphColoring.li"));
|
||||
|
||||
status = true;
|
||||
});
|
||||
@ -292,28 +322,36 @@ HWTEST_F(PassManagerTest, pass_manager_test_005, TestSize.Level1)
|
||||
bool status = false;
|
||||
options.SetCompilerDumpFolder(outdir);
|
||||
graph_test_.TestBuildGraphFromFile(pfile,
|
||||
[&test_method_name, &status, &outdir](Graph* graph, std::string &method_name) {
|
||||
[&test_method_name, &status](Graph* graph, std::string &method_name) {
|
||||
if (test_method_name != method_name) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto filename1 = graph->GetPassManager()->GetFileName("test", ".ir");
|
||||
EXPECT_EQ(filename1, outdir + "/862_pass_0005_L_GLOBAL_____loop1_test.ir");
|
||||
std::string filename1_expect = "_pass_0005_L_GLOBAL_____loop1_test.ir";
|
||||
filename1 = filename1.substr(filename1.size() - filename1_expect.size());
|
||||
EXPECT_EQ(filename1, filename1_expect);
|
||||
|
||||
GraphMode mode = graph->GetMode();
|
||||
mode.SetOsr(true);
|
||||
graph->SetMode(mode);
|
||||
auto filename2 = graph->GetPassManager()->GetFileName("test", ".ir");
|
||||
EXPECT_EQ(filename2, outdir + "/862_pass_0005_L_GLOBAL_____loop1_OSR_test.ir");
|
||||
std::string filename2_expect = "_pass_0005_L_GLOBAL_____loop1_OSR_test.ir";
|
||||
filename2 = filename2.substr(filename2.size() - filename2_expect.size());
|
||||
EXPECT_EQ(filename2, filename2_expect);
|
||||
mode.SetOsr(false);
|
||||
graph->SetMode(mode);
|
||||
|
||||
auto child_graph = graph->CreateChildGraph(graph->GetMethod());
|
||||
auto filename3 = child_graph->GetPassManager()->GetFileName("child", ".ir");
|
||||
EXPECT_EQ(filename3, outdir + "/862_pass_0005_inlined_L_GLOBAL_____loop1_child.ir");
|
||||
std::string filename3_expect = "_pass_0005_inlined_L_GLOBAL_____loop1_child.ir";
|
||||
filename3 = filename3.substr(filename3.size() - filename3_expect.size());
|
||||
EXPECT_EQ(filename3, filename3_expect);
|
||||
|
||||
auto filename4 = graph->GetPassManager()->GetFileName(nullptr, ".ir");
|
||||
EXPECT_EQ(filename4, outdir + "/862_L_GLOBAL_____loop1.ir");
|
||||
std::string filename4_expect = "_L_GLOBAL_____loop1.ir";
|
||||
filename4 = filename4.substr(filename4.size() - filename4_expect.size());
|
||||
EXPECT_EQ(filename4, filename4_expect);
|
||||
|
||||
status = true;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user