1 /** 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <cstring> 17 #include <gtest/gtest.h> 18 #include <iomanip> 19 #include <iostream> 20 #include <sstream> 21 #include <string> 22 #include <memory> 23 24 #include "compiler_options.h" 25 #include "constants.h" 26 #include "graph_checker.h" 27 #include "graph_visitor.h" 28 #include "graph_test.h" 29 #include "inst.h" 30 #include "locations.h" 31 #include "mem/pool_manager.h" 32 33 using namespace testing::ext; 34 35 namespace panda::compiler { 36 37 class GraphCheckerTest : public testing::Test { 38 public: SetUpTestCase(void)39 static void SetUpTestCase(void) {}; TearDownTestCase(void)40 static void TearDownTestCase(void) {}; SetUp()41 void SetUp() {}; TearDown()42 void TearDown() {}; 43 44 GraphTest graphTest_; 45 }; 46 47 /** 48 * @tc.name: graph_checker_test_001 49 * @tc.desc: Verify the Check function. 50 * @tc.type: FUNC 51 * @tc.require: issueNumber 52 */ 53 HWTEST_F(GraphCheckerTest, graph_checker_test_001, TestSize.Level1) 54 { 55 std::string pfile = GRAPH_TEST_ABC_DIR "styleTryCatch.abc"; 56 const char *test_method_name = "func6"; 57 bool status = false; __anon9b0d15cf0102(Graph* graph, std::string &method_name) 58 graphTest_.TestBuildGraphFromFile(pfile, [&test_method_name, &status](Graph* graph, std::string &method_name) { 59 if (test_method_name != method_name) { 60 return; 61 } 62 status = true; 63 EXPECT_NE(graph, nullptr); 64 65 graph->InvalidateAnalysis<LoopAnalyzer>(); 66 EXPECT_TRUE(graph->RunPass<LoopAnalyzer>()); 67 GraphChecker gChecker(graph); 68 gChecker.Check(); 69 }); 70 EXPECT_TRUE(status); 71 } 72 }