Skip to content

Commit 69b4953

Browse files
committed
Made some tests skippable.
1 parent 3c223af commit 69b4953

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

tests/test_generic.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,37 @@
3131
import ntpath
3232
import os
3333
import warnings
34+
import pytest
35+
36+
37+
def is_sdk_dbghelp_available():
38+
"""Check if Microsoft SDK version of dbghelp.dll is available."""
39+
try:
40+
from winappdbg import win32
41+
from winappdbg.system import System
42+
43+
with warnings.catch_warnings():
44+
warnings.simplefilter("ignore")
45+
dbghelp = System.load_dbghelp()
46+
47+
if dbghelp is None:
48+
return False
49+
50+
pathname = win32.GetModuleFileNameEx(-1, dbghelp._handle)
51+
sysroot = os.getenv("SystemRoot") or os.getenv("SYSTEMROOT")
52+
if not sysroot:
53+
return False
54+
55+
system = ntpath.join(sysroot, "System32")
56+
syswow = ntpath.join(sysroot, "SysWoW64")
57+
58+
# If it's in System32/SysWoW64, it's the system version, not SDK
59+
if pathname.lower().startswith(system.lower()) or pathname.lower().startswith(syswow.lower()):
60+
return False
61+
62+
return True
63+
except Exception:
64+
return False
3465

3566

3667
def test_module_load():
@@ -52,6 +83,10 @@ def test_db_load():
5283
from winappdbg import db # noqa
5384

5485

86+
@pytest.mark.skipif(
87+
not is_sdk_dbghelp_available(),
88+
reason="Microsoft SDK (Debugging Tools for Windows) is not installed. Only system dbghelp.dll is available."
89+
)
5590
def test_windbg_version():
5691
from winappdbg import win32
5792
from winappdbg.system import System

tests/test_miasm_integration.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,24 @@
55
"""
66

77
import sys
8+
import pytest
89

910

11+
def is_miasm_available():
12+
"""Check if Miasm is available for import."""
13+
try:
14+
import miasm.analysis.binary
15+
import miasm.analysis.machine
16+
import miasm.core.locationdb
17+
return True
18+
except ImportError:
19+
return False
20+
21+
22+
@pytest.mark.skipif(
23+
not is_miasm_available(),
24+
reason="Miasm is not installed. Install from: https://github.com/cea-sec/miasm"
25+
)
1026
def test_miasm_engine_integration():
1127
"""Test that MiasmEngine integrates properly with WinAppDbg"""
1228

0 commit comments

Comments
 (0)