52 Commits

Author SHA1 Message Date
dscott90 32e2ba62c3 Add firmware data retrieval (#2710)
* Add firmware data retrieval
* Apply suggestions from code review
* Remove FW info native versions from linux/win helpers and added results to info module

---------

Signed-off-by: Dan Scott <dan.scott@intel.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2026-03-31 13:54:29 -07:00
William Leara b401595419 remove unused imports from cs.py
These imports are not used within this module.

Signed-off-by: William Leara <william.leara@dell.com>
2026-01-29 11:59:38 -08:00
William Leara 97028a35ff remove unused imports from test_tpm_eventlog.py
These imports are not used within this module.

Signed-off-by: William Leara <william.leara@dell.com>
2026-01-29 11:59:38 -08:00
Nathaniel Mitchell e0acb2787c Move tools.vmm.common to library.intel.vmm_common
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2026-01-29 11:28:53 -08:00
Nathaniel Mitchell 088a2ca69c Fixup spi HAL and additional unit tests
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2025-03-11 20:45:54 -07:00
Nathaniel Mitchell 4b65243d9c Fix more unit tests
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2025-03-10 09:06:35 -07:00
Nathaniel Mitchell db92baec59 Fix up unit tests part 1
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2025-03-10 09:06:35 -07:00
Nathaniel Mitchell a032f04630 Update haldata and msr hal/cmd/tests
Change haldata to use cpuid mfgstr
Update MSR hal/cmd/tests

Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2025-02-18 12:53:25 -08:00
Sara Batllori c4be346ac0 Add util to decode tests' name/id
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2025-02-18 10:36:35 -08:00
Dan Scott 9095a9bb59 Add unit tests for acpi_tables.py
Signed-off-by: Dan Scott <dan.scott@intel.com>
2024-10-30 12:54:57 -07:00
Nathaniel Mitchell ed9c6e2896 Update how ACPI Tables are found
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-04-17 15:27:21 -07:00
Dan Scott 2a412e0cc0 Enumerate modules in modules folder using '-lm' 2024-03-28 13:49:05 -07:00
Dan Scott 0e8192cfd0 Move files to library folder 2024-03-22 14:26:59 -07:00
Nathaniel Mitchell f005fba0c6 Make sure DID/VID is printed when platform is unknown
And fixes unit tests

Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-11-13 16:36:49 -08:00
Nathaniel Mitchell e3b4473bad Update assertRegexpMatch to assertRegex and base Helper to NoneHelper
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-08-21 16:36:12 -07:00
Nathaniel Mitchell 483f9d99f6 Update unittests to match config parsing update
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-07-28 09:34:00 -07:00
Nathaniel Mitchell 27ee5eeb66 Clean up helper create/start/stop/delete functions
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-07-19 16:33:59 -07:00
Nicolas Iooss f1dfa2dcdd Remove from_file from method start in base helper
Commit 99f9052438 ("Remove filehelper") removed `from_file` and
`to_file` from `OsHelper` but it remained in `BaseHelper`. Remove these
parameters too.

While at it, remove the similar parameters from the mock helper used in
tests.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-07-10 16:42:07 -07:00
Jason Zhou 7f58472655 Fix test_pch_invalid() test failing on internal builds
the test invalid pch mock helper returned fake pch id, but valid plat id,
if plat id matched xml file defined reqs_pch=true, will cause exception,
the mocked plat id corresponding xml is reqs_pch=true.

Signed-off-by: Jason Zhou <jun2.zhou@intel.com>
2023-07-10 16:41:29 -07:00
Frinzell, Aaron 41ecf2cdb1 Implement basehelper.py as an ABC
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2023-06-23 08:27:17 -07:00
Nicolas Iooss a61dbc8d2b Make mocked function read_phys_mem return bytes
In tests, `read_phys_mem` could return strings instead of bytes, which
prevents detecting issues with `chipsec_util.py gdt` and
`chipsec_util.py idt`.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-05-31 16:39:35 -07:00
Nathaniel Mitchell 745ae9084e Clean up HALs and Helpers
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-05-26 18:33:08 -07:00
Nathaniel Mitchell 0016b0c14c Clean up oshelper
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-05-26 18:32:51 -07:00
Zhou, Jun2 63b772344b Add a fake cpuid func to support invalid platform unit test
Signed-off-by: Zhou Jun, jun2.zhou@intel.com
2022-12-05 11:27:03 -08:00
Frinzell, Aaron fbde218dff Update tests for decoupling parse_arg()
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-12-05 12:16:00 -06:00
Nathaniel Mitchell 291632c0ee Apply flake8 code formatting rules against repo
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2022-07-28 09:17:10 -07:00
brentholtsclaw 0e53326a83 Create exceptions.py for chipsec exceptions
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2021-08-26 10:50:51 -07:00
Nathaniel Mitchell c8c14e21be Remove shebang from all but the entry points. Update ep to py3
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2021-08-12 08:27:33 -07:00
Nicolas Iooss a53c211f2f Generate 12-byte fake TPM event in EFIFirmwareBlob test
Currently `test_tpm_eventlog_firmware_blob` generates a TPM event with
16 bytes (`struct.pack("QQ",...)`) to check the decoding of
`EFIFirmwareBlob`. But the code expects a "native unsigned long", as
documented in `chipsec/hal/tpm_eventlog.py`:

    class EFIFirmwareBlob(TcgPcrEvent):
        # Although [4] 9.2.5 mentions UNIT64 for the length, [1] 7.7 uses
        # a UINTN. Use a native unsigned long to cover the most general case.
        _event_fmt = "@QL"

On Windows, the size of `unsigned long` is 32 bits, and the test fails:

      File "d:\a\chipsec\chipsec\chipsec\hal\tpm_eventlog.py", line 115, in __init__
        base, length = struct.unpack(self._event_fmt, self.event)
    struct.error: unpack requires a buffer of 12 bytes

Use `"QL"` in the test in order to fix this test on Windows.
2021-04-30 14:56:19 -07:00
Nicolas Iooss b4dd4ed572 Always close the temporary log file when a test fails
When running "python setup.py test" on Windows, the following failure is
reported:

    ======================================================================
    ERROR: test_platform_invalid (tests.software.test_cs.TestPlatformChipsecCs)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "d:\a\chipsec\chipsec\tests\software\cs.py", line 46, in tearDown
        os.remove(self.log_file)
    PermissionError: [WinError 32] The process cannot access the file
    because it is being used by another process:
    'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpg5_6bcaz'

This is because when `_cs.init()` (in `tests/software/cs.py`) throws an
exception, the temporary log file is not closed. Then the function
`TestChipsecUtil.tearDown` attempts to remove the temporary file with
`os.remove(self.log_file)` and it fails, as it is still used by the
logger.

Fix this by putting `_cs.init()` inside a `try`/`finally` construction
which always calls `logger.logger().close()` when an exception happens.

While at it, use `with open(...) as log` instead of `log.open()` +
`log.close()`, which is a more usual way of reading files in Python.
2021-04-30 14:54:01 -07:00
brentholtsclaw 95bd9a4f0d Fix mock_helper for cs_exceptions
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2021-03-31 15:06:00 -07:00
Pedro Barbosa 2e1b81613c Implement cpuid method in mock_helper so we don't get NotImplementedError. 2020-10-29 22:26:45 +01:00
brentholtsclaw f7fe1be074 More whitespace cleanup
E231, E201, E226

Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-07-31 13:46:13 -07:00
brentholtsclaw a00b2838e5 Cleanup trailing whitespace
W291,W293,W391

Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-07-01 15:44:21 -07:00
brentholtsclaw e1b7e7b385 Add unittest for chipset function
Will check that cpu and pch can be properly identified

Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-06-29 16:05:03 -07:00
BrentHoltsclaw ada230b839 Fix unittest errors
Updated mock_helper to use BaseHelper
Updated util harness to correctly override helper with testhelper

Signed-off-by: BrentHoltsclaw <brent.holtsclaw@intel.com>
2019-11-18 15:10:56 -08:00
BrentHoltsclaw 28747def1a Updated util_cmds starting within d to use argparse (#672)
* Updated util_cmds starting within d to use argparse

* Add get_thread_count to unittest mock_helper to fix unit_test error

Signed-off-by: BrentHoltsclaw <brent.holtsclaw@intel.com>
2019-09-04 15:18:06 -07:00
BrentHoltsclaw 0f7f48f404 Fixup unit tests based upon chipsec_util changes
Signed-off-by: BrentHoltsclaw <brent.holtsclaw@intel.com>
2019-09-03 22:27:57 -07:00
BrentHoltsclaw 2efeda4345 Merge python3-rc2 branch into master (#656) 2019-08-15 14:11:20 -07:00
BrentHoltsclaw 87a456d11b Rewrite of XML and JSON logger 2018-10-15 17:18:45 -07:00
Thiebaud Weksteen 317d051c44 Add unit test for chipsec_main 2017-10-11 13:13:21 -07:00
BrentHoltsclaw fdb5115ded Expose TPM commands and state to chipsec_utils 2017-10-11 13:12:59 -07:00
Thiebaud Weksteen b9f2a6ccd1 Renable test_reg_get_control test 2017-09-20 13:21:45 -07:00
Thiebaud Weksteen d770d651ae Add HAL and utilcmd for TPM Event Log 2017-09-20 13:21:29 -07:00
c7zero 16af0c7dfd More operation in chipsec_util reg command (#238)
* More operation in chipsec_util reg command

Added write, read_field, write_field, get_control, set_control
operations

* reg read util command updated

Returned back "chipsec_util reg read" syntax and added tests.

* Commented out test_reg_get_control

Need to implement get_MMIO_BAR_base_address or read_pci_reg for SPIBAR
in mock_helper.py
2017-07-20 13:05:51 -07:00
Thiébaud Weksteen 9240e1aa58 Add register util command (#217) 2017-05-09 22:55:32 -07:00
c7zero d024dc6169 Added command-line options support to chipsec_util (#158)
* Added command-line options support to chipsec_util

* Fixed util test
2017-03-02 02:10:14 -08:00
abazhaniuk c377a72e28 Deb package (#135)
* merge

* Add Debian packaging

* cleanup

* Removed incorrect info into Copyright.

* One more: removed incorrect info in Copyright.
2017-01-06 12:57:13 -08:00
Thiébaud Weksteen 1edfb70c2a Add MemoryMapping and map_io_space to Linux helper (#120) 2016-12-05 15:49:41 -08:00
Thiébaud Weksteen b13f85b16f Add unittest.main() to each tests (#127) 2016-11-22 18:09:59 -08:00