• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 <cstdlib>
17 #include <gtest/gtest.h>
18 #include <iostream>
19 #include <string>
20 #include <vector>
21 #include "abc2program_driver.h"
22 #include "abc2program_test_utils.h"
23 #include "common/abc_file_utils.h"
24 #include "dump_utils.h"
25 #include "modifiers.h"
26 
27 using namespace testing::ext;
28 
29 namespace panda::abc2program {
30 const std::string COMMON_SYNTAX_ABC_TEST_FILE_NAME = GRAPH_TEST_ABC_DIR "CommonSyntax.abc";
31 const std::string COMMON_SYNTAX_DUMP_RESULT_FILE_NAME = GRAPH_TEST_ABC_DIR "CommonSyntax.txt";
32 const std::string COMMON_SYNTAX_DUMP_EXPECTED_FILE_NAME =
33     GRAPH_TEST_ABC_DUMP_DIR "release-line-number/CommonSyntaxExpected.txt";
34 
35 const std::string INVALID_OPCODE_ABC_TEST_FILE_NAME = GRAPH_TEST_ABC_DIR "InvalidOpcode.abc";
36 const std::string INVALID_OPCODE_DUMP_RESULT_FILE_NAME = GRAPH_TEST_ABC_DIR "InvalidOpcode.txt";
37 const std::string INVALID_OPCODE_DUMP_EXPECTED_FILE_NAME =
38     GRAPH_TEST_ABC_DUMP_DIR "release-line-number/InvalidOpcodeExpected.txt";
39 
40 const std::string TS_NEW_FEATRUE_SYNTAX_ABC_TEST_FILE_NAME = GRAPH_TEST_ABC_DIR "TsNewFeatrueSyntax.abc";
41 const std::string TS_NEW_FEATRUE_SYNTAX_DUMP_RESULT_FILE_NAME = GRAPH_TEST_ABC_DIR "TsNewFeatrueSyntax.txt";
42 const std::string TS_NEW_FEATRUE_SYNTAX_DUMP_EXPECTED_FILE_NAME =
43     GRAPH_TEST_ABC_DUMP_DIR "release-line-number/TsNewFeatrueSyntaxExpected.txt";
44 
45 class Abc2ProgramLineNumberTest : public testing::Test {
46 public:
SetUpTestCase(void)47     static void SetUpTestCase(void) {}
TearDownTestCase(void)48     static void TearDownTestCase(void) {}
SetUp()49     void SetUp() {}
50 
TearDown()51     void TearDown() {}
52 
53     Abc2ProgramDriver driver_;
54     const pandasm::Program *prog_ = nullptr;
55 };
56 
57 /**
58  * @tc.name: abc2program_ts_release_number_test_dump
59  * @tc.desc: check dump result in release mode.
60  * @tc.type: FUNC
61  * @tc.require: IADG92
62  */
63 HWTEST_F(Abc2ProgramLineNumberTest, abc2program_release_line_number_common_syntax_test, TestSize.Level1)
64 {
65     driver_.Compile(COMMON_SYNTAX_ABC_TEST_FILE_NAME);
66     driver_.Dump(COMMON_SYNTAX_DUMP_RESULT_FILE_NAME);
67     EXPECT_TRUE(Abc2ProgramTestUtils::ValidateDumpResult(COMMON_SYNTAX_DUMP_RESULT_FILE_NAME,
68                                                          COMMON_SYNTAX_DUMP_EXPECTED_FILE_NAME));
69     // Abc2ProgramTestUtils::RemoveDumpResultFile(COMMON_SYNTAX_DUMP_RESULT_FILE_NAME);
70 }
71 
72 HWTEST_F(Abc2ProgramLineNumberTest, abc2program_release_line_number_invalid_opcode_test, TestSize.Level1)
73 {
74     driver_.Compile(INVALID_OPCODE_ABC_TEST_FILE_NAME);
75     driver_.Dump(INVALID_OPCODE_DUMP_RESULT_FILE_NAME);
76     EXPECT_TRUE(Abc2ProgramTestUtils::ValidateDumpResult(INVALID_OPCODE_DUMP_RESULT_FILE_NAME,
77                                                          INVALID_OPCODE_DUMP_EXPECTED_FILE_NAME));
78     Abc2ProgramTestUtils::RemoveDumpResultFile(INVALID_OPCODE_DUMP_RESULT_FILE_NAME);
79 }
80 
81 HWTEST_F(Abc2ProgramLineNumberTest, abc2program_release_line_number_ts_new_featrue_test, TestSize.Level1)
82 {
83     driver_.Compile(TS_NEW_FEATRUE_SYNTAX_ABC_TEST_FILE_NAME);
84     driver_.Dump(TS_NEW_FEATRUE_SYNTAX_DUMP_RESULT_FILE_NAME);
85     EXPECT_TRUE(Abc2ProgramTestUtils::ValidateDumpResult(TS_NEW_FEATRUE_SYNTAX_DUMP_RESULT_FILE_NAME,
86                                                          TS_NEW_FEATRUE_SYNTAX_DUMP_EXPECTED_FILE_NAME));
87     Abc2ProgramTestUtils::RemoveDumpResultFile(TS_NEW_FEATRUE_SYNTAX_DUMP_RESULT_FILE_NAME);
88 }
89 }; // panda::abc2program