mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-30 11:49:42 +02:00
testcases: Improve volshell basic testcase calling ps() on each of them
This commit is contained in:
+13
-3
@@ -80,12 +80,18 @@ def runvolshell(img, volshell, python, volshellargs=None, globalargs=None):
|
||||
def basic_volshell_test(image, volatility, python, globalargs):
|
||||
# Basic VolShell test to verify requirements and ensure VolShell runs without crashing
|
||||
|
||||
volshell_commands = [
|
||||
"print(ps())",
|
||||
"exit()",
|
||||
]
|
||||
|
||||
# FIXME: When the minimum Python version includes 3.12, replace the following with:
|
||||
# with tempfile.NamedTemporaryFile(delete_on_close=False) as fd: ...
|
||||
fd, filename = tempfile.mkstemp(suffix=".txt")
|
||||
try:
|
||||
volshell_script = "\n".join(volshell_commands)
|
||||
with os.fdopen(fd, "w") as f:
|
||||
f.write("exit()")
|
||||
f.write(volshell_script)
|
||||
|
||||
rc, out, _err = runvolshell(
|
||||
img=image,
|
||||
@@ -101,12 +107,15 @@ def basic_volshell_test(image, volatility, python, globalargs):
|
||||
assert rc == 0
|
||||
assert out.count(b"\n") >= 4
|
||||
|
||||
return out
|
||||
|
||||
|
||||
# WINDOWS
|
||||
|
||||
|
||||
def test_windows_volshell(image, volatility, python):
|
||||
basic_volshell_test(image, volatility, python, globalargs=["-w"])
|
||||
out = basic_volshell_test(image, volatility, python, globalargs=["-w"])
|
||||
assert out.count(b"<EPROCESS") > 40
|
||||
|
||||
|
||||
def test_windows_pslist(image, volatility, python):
|
||||
@@ -381,7 +390,8 @@ def test_windows_vadyarascan_yara_string(image, volatility, python):
|
||||
|
||||
|
||||
def test_linux_volshell(image, volatility, python):
|
||||
basic_volshell_test(image, volatility, python, globalargs=["-l"])
|
||||
out = basic_volshell_test(image, volatility, python, globalargs=["-l"])
|
||||
assert out.count(b"<task_struct") > 100
|
||||
|
||||
|
||||
def test_linux_pslist(image, volatility, python):
|
||||
|
||||
Reference in New Issue
Block a user