forked from osandov/drgn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable prog.type to work with classes
Also added end to end CPP tests This is a prerequisite to osandov#83 Signed-off-by: mykolal <nickolay.lysenko@gmail.com>
- Loading branch information
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"_Complex", | ||
"char", | ||
"const", | ||
"class", | ||
"double", | ||
"enum", | ||
"float", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import os | ||
import os.path | ||
import subprocess | ||
import tempfile | ||
import unittest | ||
|
||
from drgn import Program, MissingDebugInfoError | ||
from tests import TestCase | ||
|
||
|
||
class TestE2ECPP(TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
with tempfile.NamedTemporaryFile() as core_dump_file: | ||
try: | ||
subprocess.check_call( | ||
[ | ||
"zstd", | ||
"--quiet", | ||
"--decompress", | ||
"--stdout", | ||
"tests/sample.cpp.coredump.zst", | ||
], | ||
stdout=core_dump_file, | ||
) | ||
except FileNotFoundError: | ||
raise unittest.SkipTest("zstd not found") | ||
cls.prog = Program() | ||
cls.prog.set_core_dump(core_dump_file.name) | ||
try: | ||
cls.prog.load_default_debug_info() | ||
except MissingDebugInfoError: | ||
pass | ||
|
||
def test_struct_e2e(self): | ||
self.assertSequenceEqual( | ||
"struct S {\n" | ||
"\tint def;\n" | ||
"\tint pub;\n" | ||
"\tint pri;\n" | ||
"\tint prt;\n" | ||
"}", | ||
self.prog.type("struct S").__str__() | ||
) | ||
|
||
def test_class_e2e(self): | ||
self.assertSequenceEqual( | ||
"class A {\n" | ||
"\tint def;\n" | ||
"\tint pub;\n" | ||
"\tint pri;\n" | ||
"\tint prt;\n" | ||
"}", | ||
self.prog.type("class A").__str__() | ||
) |