Commit Graph

29 Commits

Author SHA1 Message Date
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
Thiébaud Weksteen ead6e96222 Split util tests into multiple source files (#122) 2016-11-17 22:34:37 -08:00
abazhaniuk 94fe7f02f1 change setup.py build driver by default. change root directory of chipsec. move WARNING.txt to chipsec. remove PKG-INFO (#107) 2016-10-18 18:19:42 -07:00