forked from chipsec/chipsec
-
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.
WIP: Add unit tests for igd, interrupts, io, iommu utilcmds
Signed-off-by: Sara Batllori <[email protected]>
- Loading branch information
Showing
35 changed files
with
1,676 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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,50 @@ | ||
{ | ||
"read_pci_reg": { | ||
"(0,2,0,2,2)": [ | ||
"18048" | ||
], | ||
"(0,2,0,24,4)": [ | ||
"12" | ||
], | ||
"(0,2,0,28,4)": [ | ||
"64" | ||
], | ||
"(0,2,0,20,4)": [ | ||
"96", | ||
"96", | ||
"96", | ||
"96" | ||
], | ||
"(0,2,0,16,4)": [ | ||
"4", | ||
"4", | ||
"4", | ||
"4" | ||
] | ||
}, | ||
"read_mmio_reg": { | ||
"(412325249024,4)": [ | ||
"1283457025" | ||
], | ||
"(412325249028,4)": [ | ||
"0" | ||
] | ||
}, | ||
"write_mmio_reg": { | ||
"(412325249024,4,536870913)": [ | ||
"" | ||
], | ||
"(412325249028,4,0)": [ | ||
"", | ||
"" | ||
], | ||
"(412325249024,4,1283457025)": [ | ||
"" | ||
] | ||
}, | ||
"read_phys_mem": { | ||
"(274877906944,4)": [ | ||
"\u001c\ryF" | ||
] | ||
} | ||
} |
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,52 @@ | ||
{ | ||
"read_pci_reg": { | ||
"(0,2,0,2,2)": [ | ||
"18048" | ||
], | ||
"(0,2,0,24,4)": [ | ||
"12" | ||
], | ||
"(0,2,0,28,4)": [ | ||
"64" | ||
], | ||
"(0,2,0,20,4)": [ | ||
"96", | ||
"96", | ||
"96", | ||
"96" | ||
], | ||
"(0,2,0,16,4)": [ | ||
"4", | ||
"4", | ||
"4", | ||
"4" | ||
] | ||
}, | ||
"read_mmio_reg": { | ||
"(412325249024,4)": [ | ||
"1283457025" | ||
], | ||
"(412325249028,4)": [ | ||
"0" | ||
] | ||
}, | ||
"write_mmio_reg": { | ||
"(412325249024,4,561975297)": [ | ||
"" | ||
], | ||
"(412325249028,4,2)": [ | ||
"" | ||
], | ||
"(412325249024,4,1283457025)": [ | ||
"" | ||
], | ||
"(412325249028,4,0)": [ | ||
"" | ||
] | ||
}, | ||
"write_phys_mem": { | ||
"(274877906944,4,bytearray(b'\\xde\\xad\\xbe\\xef'))": [ | ||
"" | ||
] | ||
} | ||
} |
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,46 @@ | ||
# CHIPSEC: Platform Security Assessment Framework | ||
# Copyright (c) 2024, Intel Corporation | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; Version 2. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
# | ||
# Contact information: | ||
# [email protected] | ||
# | ||
|
||
"""" | ||
To execute: python[3] -m unittest tests.utilcmd.igd_cmd.test_igd_cmd | ||
""" | ||
|
||
import unittest | ||
import os | ||
|
||
from chipsec.library.file import get_main_dir | ||
from tests.utilcmd.run_chipsec_util import setup_run_destroy_util | ||
from chipsec.testcase import ExitCode | ||
|
||
class TestIgdUtilcmd(unittest.TestCase): | ||
def test_dmaread(self) -> None: | ||
init_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "adlenumerate.json") | ||
igd_dump_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "igd_cmd", "igd_cmd_dmaread_1.json") | ||
retval = setup_run_destroy_util(init_replay_file, "igd", "dmaread 0x20000000 4", util_replay_file=igd_dump_replay_file) | ||
self.assertEqual(retval, ExitCode.OK) | ||
|
||
def test_dmawrite(self) -> None: | ||
init_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "adlenumerate.json") | ||
igd_dump_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "igd_cmd", "igd_cmd_dmawrite_1.json") | ||
retval = setup_run_destroy_util(init_replay_file, "igd", "dmawrite 0x2217F1000 0x4 deadbeef", util_replay_file=igd_dump_replay_file) | ||
self.assertEqual(retval, ExitCode.OK) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Empty file.
69 changes: 69 additions & 0 deletions
69
tests/utilcmd/interrupts_cmd/interrupts_cmd_smi_count_1.json
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,69 @@ | ||
{ | ||
"get_threads_count": { | ||
"()": [ | ||
"20" | ||
] | ||
}, | ||
"read_msr": { | ||
"(0,52)": [ | ||
"(461, 0)" | ||
], | ||
"(1,52)": [ | ||
"(461, 0)" | ||
], | ||
"(2,52)": [ | ||
"(461, 0)" | ||
], | ||
"(3,52)": [ | ||
"(461, 0)" | ||
], | ||
"(4,52)": [ | ||
"(461, 0)" | ||
], | ||
"(5,52)": [ | ||
"(461, 0)" | ||
], | ||
"(6,52)": [ | ||
"(461, 0)" | ||
], | ||
"(7,52)": [ | ||
"(461, 0)" | ||
], | ||
"(8,52)": [ | ||
"(461, 0)" | ||
], | ||
"(9,52)": [ | ||
"(461, 0)" | ||
], | ||
"(10,52)": [ | ||
"(461, 0)" | ||
], | ||
"(11,52)": [ | ||
"(461, 0)" | ||
], | ||
"(12,52)": [ | ||
"(461, 0)" | ||
], | ||
"(13,52)": [ | ||
"(461, 0)" | ||
], | ||
"(14,52)": [ | ||
"(461, 0)" | ||
], | ||
"(15,52)": [ | ||
"(461, 0)" | ||
], | ||
"(16,52)": [ | ||
"(461, 0)" | ||
], | ||
"(17,52)": [ | ||
"(461, 0)" | ||
], | ||
"(18,52)": [ | ||
"(461, 0)" | ||
], | ||
"(19,52)": [ | ||
"(461, 0)" | ||
] | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/utilcmd/interrupts_cmd/interrupts_cmd_smi_send_1.json
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,10 @@ | ||
{ | ||
"write_io_port": { | ||
"(179,0,1)": [ | ||
"True" | ||
], | ||
"(178,222,1)": [ | ||
"True" | ||
] | ||
} | ||
} |
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,46 @@ | ||
# CHIPSEC: Platform Security Assessment Framework | ||
# Copyright (c) 2024, Intel Corporation | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; Version 2. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
# | ||
# Contact information: | ||
# [email protected] | ||
# | ||
|
||
"""" | ||
To execute: python[3] -m unittest tests.utilcmd.interrupts_cmd.test_interrupts_cmd | ||
""" | ||
|
||
import unittest | ||
import os | ||
|
||
from chipsec.library.file import get_main_dir | ||
from tests.utilcmd.run_chipsec_util import setup_run_destroy_util | ||
from chipsec.testcase import ExitCode | ||
|
||
class TestInterruptsUtilcmd(unittest.TestCase): | ||
def test_count(self) -> None: | ||
init_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "adlenumerate.json") | ||
interrupts_dump_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "interrupts_cmd", "interrupts_cmd_smi_count_1.json") | ||
retval = setup_run_destroy_util(init_replay_file, "smi", "count", util_replay_file=interrupts_dump_replay_file) | ||
self.assertEqual(retval, ExitCode.OK) | ||
|
||
def test_send(self) -> None: | ||
init_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "adlenumerate.json") | ||
interrupts_dump_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "interrupts_cmd", "interrupts_cmd_smi_send_1.json") | ||
retval = setup_run_destroy_util(init_replay_file, "smi", "send 0x0 0xDE 0x0", util_replay_file=interrupts_dump_replay_file) | ||
self.assertEqual(retval, ExitCode.OK) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Empty file.
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,17 @@ | ||
{ | ||
"read_pci_reg": { | ||
"(0,31,2,32,4)": [ | ||
"4294967295", | ||
"4294967295" | ||
], | ||
"(0,31,4,80,4)": [ | ||
"1025" | ||
], | ||
"(0,31,0,72,4)": [ | ||
"0" | ||
], | ||
"(0,31,4,32,4)": [ | ||
"61345" | ||
] | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"read_io_port": { | ||
"(97,1)": [ | ||
"48" | ||
] | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"write_io_port": { | ||
"(1072,0,1)": [ | ||
"True" | ||
] | ||
} | ||
} |
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,52 @@ | ||
# CHIPSEC: Platform Security Assessment Framework | ||
# Copyright (c) 2024, Intel Corporation | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; Version 2. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
# | ||
# Contact information: | ||
# [email protected] | ||
# | ||
|
||
"""" | ||
To execute: python[3] -m unittest tests.utilcmd.io_cmd.test_io_cmd | ||
""" | ||
|
||
import unittest | ||
import os | ||
|
||
from chipsec.library.file import get_main_dir | ||
from tests.utilcmd.run_chipsec_util import setup_run_destroy_util | ||
from chipsec.testcase import ExitCode | ||
|
||
class TestIoUtilcmd(unittest.TestCase): | ||
def test_list(self) -> None: | ||
init_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "adlenumerate.json") | ||
io_dump_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "io_cmd", "io_cmd_list_1.json") | ||
retval = setup_run_destroy_util(init_replay_file, "io", "list", util_replay_file=io_dump_replay_file) | ||
self.assertEqual(retval, ExitCode.OK) | ||
|
||
def test_read(self) -> None: | ||
init_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "adlenumerate.json") | ||
io_dump_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "io_cmd", "io_cmd_read_1.json") | ||
retval = setup_run_destroy_util(init_replay_file, "io", "read 0x61 1", util_replay_file=io_dump_replay_file) | ||
self.assertEqual(retval, ExitCode.OK) | ||
|
||
def test_write(self) -> None: | ||
init_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "adlenumerate.json") | ||
io_dump_replay_file = os.path.join(get_main_dir(), "tests", "utilcmd", "io_cmd", "io_cmd_write_1.json") | ||
retval = setup_run_destroy_util(init_replay_file, "io", "write 0x430 1 0x0", util_replay_file=io_dump_replay_file) | ||
self.assertEqual(retval, ExitCode.OK) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Empty file.
Oops, something went wrong.