forked from chipsec/chipsec
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tpm_cmd and txt_cmd unit testing
Signed-off-by: Sae86 <sara.batllori@intel.com>
- Loading branch information
Showing
11 changed files
with
150,542 additions
and
5 deletions.
There are no files selected for viewing
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
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
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,51 @@ | ||
# 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: | ||
# chipsec@intel.com | ||
# | ||
|
||
|
||
from unittest.mock import Mock | ||
|
||
import chipsec.helper.replay.replayhelper as rph | ||
from chipsec_util import ChipsecUtil, parse_args | ||
import chipsec.logger | ||
|
||
|
||
def run_chipsec_util(csu: ChipsecUtil, util_replay_file: str) -> bool: | ||
csu._cs.init(csu._platform, csu._pch, csu._helper, not csu._no_driver, csu._load_config, csu._ignore_platform) | ||
if util_replay_file: | ||
csu._helper.config_file = util_replay_file | ||
csu._helper._load() | ||
comm = csu.commands[csu._cmd](csu._cmd_args, cs=csu._cs) | ||
comm.parse_arguments() | ||
comm.set_up() | ||
comm.run() | ||
comm.tear_down() | ||
return comm.ExitCode | ||
|
||
def setup_run_destroy_util(init_replay_file: str, util_name: str, util_args: str = "", util_replay_file: str = "") -> bool: | ||
chipsec.logger._logger = Mock() | ||
arg_str = f" {util_args}" if util_args else "" | ||
cli_cmds = f"{util_name}{arg_str}".strip().split(' ') | ||
par = parse_args(cli_cmds) | ||
csu = ChipsecUtil(par, cli_cmds) | ||
replayHelper = rph.ReplayHelper(init_replay_file) | ||
csu._helper = replayHelper | ||
retval = run_chipsec_util(csu, util_replay_file) | ||
chipsec.logger._logger = chipsec.logger.Logger() | ||
return retval |
Oops, something went wrong.