Skip to content

Commit

Permalink
Add basic characterization test
Browse files Browse the repository at this point in the history
Signed-off-by: Nathaniel Mitchell <[email protected]>
  • Loading branch information
npmitche committed Jun 14, 2024
1 parent 8ea8aad commit 14c8a40
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/characterization/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# CHIPSEC: Platform Security Assessment Framework
# Copyright (c) 2023, 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]
#
131 changes: 131 additions & 0 deletions tests/characterization/characterize.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@

################################################################
## ##
## CHIPSEC: Platform Hardware Security Assessment Framework ##
## ##
################################################################
[CHIPSEC] Version : 1.13.1
[CHIPSEC] Arguments: -m common.cpu.cpu_info -l tmp.log


WARNING: *******************************************************************
WARNING: Chipsec should only be used on test systems!
WARNING: It should not be installed/deployed on production end-user systems.
WARNING: See WARNING.txt
WARNING: *******************************************************************


[CHIPSEC] OS : Windows 10 10.0.22631 AMD64
[CHIPSEC] Python : 3.10.1 (64-bit)
[CHIPSEC] Helper : WindowsHelper (\??\C:\Users\Nathaniel\git\chipsec\chipsec\helper\windows\windows_amd64\chipsec_hlpr.sys)
[CHIPSEC] Platform: ADL-P/H 4+8
[CHIPSEC] CPUID: 906A2
[CHIPSEC] VID: 8086
[CHIPSEC] DID: 4621
[CHIPSEC] RID: 01
[CHIPSEC] PCH : Intel ADL-P (600) PCH
[CHIPSEC] VID: 8086
[CHIPSEC] DID: 5182
[CHIPSEC] RID: 01


[+] loaded chipsec.modules.common.cpu.cpu_info
[*] running loaded modules ..

[*] Running module: chipsec.modules.common.cpu.cpu_info
[x][ =======================================================================
[x][ Module: Current Processor Information:
[x][ =======================================================================
[*] Thread 0000
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0001
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0002
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0003
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0004
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0005
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0006
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0007
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0008
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0009
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0010
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0011
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0012
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0013
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0014
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[*] Thread 0015
[*] Processor: 12th Gen Intel(R) Core(TM) i5-1240P
[*] Family: 06 Model: 9A Stepping: 2
[*] Microcode: 0000030D
[*]
[#] INFORMATION: Processor information displayed

[CHIPSEC] *************************** SUMMARY ***************************
[CHIPSEC]
[CHIPSEC] Modules total 1
[CHIPSEC] Modules failed to run 0:
[CHIPSEC] Modules passed 0:
[CHIPSEC] Modules information 1:
[#] INFORMATION: chipsec.modules.common.cpu.cpu_info
[CHIPSEC] Modules failed 0:
[CHIPSEC] Modules with warnings 0:
[CHIPSEC] Modules not applicable 0:
[CHIPSEC] *****************************************************************
52 changes: 52 additions & 0 deletions tests/characterization/test_modulerefactor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

# CHIPSEC: Platform Security Assessment Framework
# Copyright (c) 2023, 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]
#

import unittest
# from unittest.mock import patch, Mock, MagicMock, call
from chipsec_main import run
from io import StringIO
from contextlib import redirect_stdout
import os
import re




class TestHalCpu(unittest.TestCase):

def test_with_module_cpuinfo(self):
with open("tests\\characterization\\characterize.log") as f:
EXPECTED_LOG_CPUINFO = f.read()

os.remove("chipsec\\logs\\characterize.log")
run("-m common.cpu.cpu_info -l characterize.log")
with open("chipsec\\logs\\characterize.log") as f:
filetext = f.read()

cleaned = re.sub(r"Time elapsed [.0-9]{5}","", filetext)
self.assertEqual(cleaned, EXPECTED_LOG_CPUINFO)


if __name__ == '__main__':
unittest.main()



0 comments on commit 14c8a40

Please sign in to comment.