• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 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 <iostream>
17#include <string>
18
19#include <gtest/gtest.h>
20#include "disassembler.h"
21
22using namespace panda::disasm;
23
24#cmakedefine DISASM_BIN_DIR "@DISASM_BIN_DIR@/"
25
26TEST(metadata_test, test1)
27{
28    Disassembler d {};
29
30    std::stringstream ss {};
31    d.Disassemble(std::string(DISASM_BIN_DIR) + "meta.bc");
32    d.Serialize(ss, false);
33
34    std::string prog = ss.str();
35
36    EXPECT_TRUE(prog.find(".function u1 GGG() <native, static>") != std::string::npos);
37    EXPECT_TRUE(prog.find(".function u1 FFF() <noimpl, static>") != std::string::npos);
38    EXPECT_TRUE(prog.find(".function u1 A._cctor_(u1 a0) <cctor, static> {\n}") != std::string::npos);
39    EXPECT_TRUE(prog.find(".function u1 A.EEE(A a0, u1 a1) {\n") != std::string::npos);
40    EXPECT_TRUE(prog.find("\tcall.short DDD:(u1), v0") != std::string::npos);
41    EXPECT_TRUE(prog.find(".function u1 A._ctor_(u1 a0) <ctor, static> {\n}") != std::string::npos);
42    EXPECT_TRUE(prog.find(".function u1 DDD(u1 a0) <external, static>") != std::string::npos);
43    EXPECT_TRUE(prog.find("initobj.short A._ctor_:(u1), v0") != std::string::npos);
44    EXPECT_TRUE(prog.find("initobj.short A._cctor_:(u1), v1") != std::string::npos);
45
46    EXPECT_TRUE(prog.find(".record A {\n}") != std::string::npos);
47    EXPECT_TRUE(prog.find(".record B <external>") != std::string::npos);
48}
49
50#undef DISASM_BIN_DIR
51