mirror of
https://github.com/hakril/PythonForWindows
synced 2026-06-08 14:31:45 +00:00
Added/fixed some test
This commit is contained in:
@@ -12,7 +12,7 @@ import windows.generated_def as gdef
|
||||
import windows.native_exec.simple_x86 as x86
|
||||
import windows.native_exec.simple_x64 as x64
|
||||
|
||||
from pfwtest import *
|
||||
from .pfwtest import *
|
||||
|
||||
@check_for_gc_garbage
|
||||
class TestCurrentProcessWithCheckGarbage(object):
|
||||
@@ -330,7 +330,7 @@ class TestProcessWithCheckGarbage(object):
|
||||
assert len(dlls) == 1
|
||||
injecteddll = dlls[0]
|
||||
# Check that the DLL is the one we asked to load
|
||||
assert injecteddll.fullname == targetname
|
||||
assert injecteddll.fullname.lower() == targetname.lower()
|
||||
|
||||
# UNICODE_PATH_NAME = u'\u4e2d\u56fd\u94f6\u884c\u7f51\u94f6\u52a9\u624b'
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import windows.generated_def as gdef
|
||||
|
||||
|
||||
def test_services_process():
|
||||
services_with_process = [s for s in windows.system.services if s.ServiceStatusProcess.dwProcessId]
|
||||
services_with_process = [s for s in windows.system.services if s.status.dwProcessId]
|
||||
service = services_with_process[0]
|
||||
proc = service.process
|
||||
assert proc.pid == service.ServiceStatusProcess.dwProcessId
|
||||
assert proc.pid == service.status.dwProcessId
|
||||
|
||||
|
||||
def test_service_appinfo():
|
||||
|
||||
@@ -15,7 +15,7 @@ if capstone:
|
||||
@pytest.fixture
|
||||
def need_capstone():
|
||||
if capstone is None:
|
||||
raise pytest.Skip("Capstone is not installed")
|
||||
raise pytest.skip("Capstone is not installed")
|
||||
return True
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("need_capstone")
|
||||
|
||||
@@ -9,6 +9,8 @@ import windows.native_exec.simple_x86 as x86
|
||||
from windows.native_exec.simple_x86 import *
|
||||
del Test # Prevent pytest warning
|
||||
|
||||
VERBOSE = False
|
||||
|
||||
if capstone:
|
||||
disassembleur = capstone.Cs(capstone.CS_ARCH_X86, capstone.CS_MODE_32)
|
||||
disassembleur.detail = True
|
||||
@@ -16,7 +18,7 @@ if capstone:
|
||||
@pytest.fixture
|
||||
def need_capstone():
|
||||
if capstone is None:
|
||||
raise pytest.Skip("Capstone is not installed")
|
||||
raise pytest.skip("Capstone is not installed")
|
||||
return True
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("need_capstone")
|
||||
@@ -47,6 +49,9 @@ class CheckInstr(object):
|
||||
if len(res) != len(capres.bytes):
|
||||
raise AssertionError("Not all bytes have been used by the disassembler")
|
||||
|
||||
if VERBOSE:
|
||||
print(" * [CODE] {0}".format(repr(res)))
|
||||
print(" * [DISAS] {0} {1}".format(capres.mnemonic, capres.op_str))
|
||||
|
||||
if self.expected_result is not None:
|
||||
if "{0} {1}".format(capres.mnemonic, capres.op_str) == self.expected_result:
|
||||
@@ -129,6 +134,17 @@ def test_assembler():
|
||||
CheckInstr(Mov)('AX', mem('fs:[0x30]'))
|
||||
CheckInstr(Mov)('AX', mem('fs:[EAX + 0x30]'))
|
||||
CheckInstr(Mov)('AX', mem('fs:[EAX + ECX * 4+0x30]'))
|
||||
# Segment selector
|
||||
CheckInstr(Mov)('SS', 'ECX')
|
||||
CheckInstr(Mov)('ECX', 'SS')
|
||||
CheckInstr(Mov)('EDX', 'es')
|
||||
CheckInstr(Mov)('EDX', 'cs')
|
||||
CheckInstr(Mov)('EDX', 'ds')
|
||||
CheckInstr(Mov)('EDX', 'fs')
|
||||
CheckInstr(Mov)('fs', 'eax')
|
||||
CheckInstr(Mov)('fs', 'eax')
|
||||
|
||||
|
||||
CheckInstr(Add)('EAX', 8)
|
||||
CheckInstr(Add)('EAX', 0xffffffff)
|
||||
CheckInstr(Add)("ECX", mem("[EAX + 0xff]"))
|
||||
|
||||
+20
-2
@@ -3,7 +3,7 @@ import pytest
|
||||
import windows
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from pfwtest import *
|
||||
from .pfwtest import *
|
||||
|
||||
pytestmark = pytest.mark.usefixtures('check_for_gc_garbage')
|
||||
|
||||
@@ -15,4 +15,22 @@ def test_createfileA_fail():
|
||||
|
||||
def test_lstrcmpa():
|
||||
assert windows.winproxy.lstrcmpA("LOL", "NO-LOL")
|
||||
assert not windows.winproxy.lstrcmpA("LOL", "LOL")
|
||||
assert not windows.winproxy.lstrcmpA("LOL", "LOL")
|
||||
|
||||
def test_getsystemmetrics():
|
||||
"""Test nothing is raised when GetSystemMetrics() returns 0"""
|
||||
# Using a suit of value that may return 0
|
||||
windows.winproxy.GetSystemMetrics(gdef.SM_DIGITIZER)
|
||||
windows.winproxy.GetSystemMetrics(gdef.SM_CLEANBOOT)
|
||||
windows.winproxy.GetSystemMetrics(gdef.SM_MOUSEHORIZONTALWHEELPRESENT)
|
||||
windows.winproxy.GetSystemMetrics(gdef.SM_SERVERR2)
|
||||
windows.winproxy.GetSystemMetrics(gdef.SM_SLOWMACHINE)
|
||||
windows.winproxy.GetSystemMetrics(gdef.SM_SWAPBUTTON)
|
||||
windows.winproxy.GetSystemMetrics(gdef.SM_TABLETPC)
|
||||
|
||||
|
||||
def test_resolve():
|
||||
ntdll = windows.current_process.peb.modules[1]
|
||||
assert ntdll.name == "ntdll.dll"
|
||||
assert ntdll.pe.exports["NtCreateFile"] == windows.winproxy.resolve(windows.winproxy.NtCreateFile)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user