Skip to content

Commit

Permalink
[checkbox-ce-oem] Fix all checks in ceoem (Bugfix) (#1445)
Browse files Browse the repository at this point in the history
* Reduce length of the testplan name

* fix the shell check issue

fix the shell check issue

* Fix flake8

* Fix black

* Fix flake8

* fix add_subparsers param issue in python3.5

fix the required parameter not available in Python 3.5

* fix fstring error in Python 3.5

fix fstring error in Python 3.5

---------

Co-authored-by: stanley31huang <[email protected]>
  • Loading branch information
LiaoU3 and stanley31huang authored Sep 4, 2024
1 parent 93b2e02 commit 924882a
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_performance_ctx_function() -> Optional[Callable]:
Environment Variables:
-----------
PERFORMANCE_PYTHON_MODULE_PATH
performance_module_path
The full path of a python module that you are interested in even it's
not in PYTHONPATH
PERFORMANCE_FUNCTION_NAME
Expand All @@ -63,10 +63,10 @@ def get_performance_ctx_function() -> Optional[Callable]:
# in ce-oem provider.
# It's the empty value by defaul, you have to define it as Checkbox's
# configuraion.
PERFORMANCE_PYTHON_MODULE_PATH = os.environ.get(
performance_module_path = os.environ.get(
"PERFORMANCE_PYTHON_MODULE_PATH", ""
)
if PERFORMANCE_PYTHON_MODULE_PATH == "":
if performance_module_path == "":
raise FileNotFoundError(
(
"Fail to get a performance python module"
Expand All @@ -78,14 +78,14 @@ def get_performance_ctx_function() -> Optional[Callable]:
# Get the name of context manager function which controls the performance
# mode. Default name is performance_mode. You can assign the specific name
# via environment variable
PERFORMANCE_FUNCTION_NAME = os.environ.get(
performance_function_name = os.environ.get(
"PERFORMANCE_FUNCTION_NAME", "performance_mode"
)

return get_function_from_a_module(
module_name=os.path.basename(PERFORMANCE_PYTHON_MODULE_PATH),
module_path=PERFORMANCE_PYTHON_MODULE_PATH,
function_name=PERFORMANCE_FUNCTION_NAME,
module_name=os.path.basename(performance_module_path),
module_path=performance_module_path,
function_name=performance_function_name,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def dump_firmware_test_mapping(args) -> None:
def register_arguments():
parser = argparse.ArgumentParser(description="RPMSG reload firmware test")

subparsers = parser.add_subparsers(dest="mode", required=True)
subparsers = parser.add_subparsers(dest="mode")
reload_test_parser = subparsers.add_parser("test-reload")
reload_test_parser.add_argument(
"--device",
Expand Down Expand Up @@ -260,8 +260,12 @@ def register_arguments():
required=True,
)
reload_res_test_parser.set_defaults(test_func=dump_firmware_test_mapping)
args = parser.parse_args()
if args.mode is None:
parser.print_help()
exit(1)

return parser.parse_args()
return args


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_spi_content_consistency(spi_path):

# Construct the command to run the SPI test
cmd = "spidev_test -D {} -p 'Canonical SPI Test' -v".format(spi_path)
print(f"Run command: {cmd}\n")
print("Run command: {}\n".format(cmd))

# Run the command and capture the output
spi_ret = runcmd(cmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,10 @@ def test_debug_logging_disabled(self, mock_exit):
def test_policy_resource_flag_enabled(self, mock_handler, mock_exit):
with patch("sys.argv", ["program_name", "--policy-resource"]):
main()
mock_handler.return_value.print_policies_list.assert_called_once_with()
# fmt: off
mock_handler.return_value.print_policies_list.\
assert_called_once_with()
# fmt: on

@patch("sys.exit")
@patch("cpufreq_governors.CPUScalingHandler")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ def test_validate_video_decoder_md5_checksum_golden_md5_checksum_not_found(
(),
{
"golden_sample_path": "golden_sample.mp4",
"golden_sample_md5_checksum_path": "non_exist_golden_sample.md5",
"golden_sample_md5_checksum_path": (
"non_exist_golden_sample.md5"
),
"decoder_plugin": "fake_decoder",
"color_space": "NN",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from unittest.mock import patch, MagicMock, Mock

sys.modules["systemd"] = MagicMock()

# flake8: noqa: E402
import rpmsg_load_firmware


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from unittest.mock import patch, MagicMock, Mock

sys.modules["systemd"] = MagicMock()

# flake8: noqa: E402
import rpmsg_tests


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import timedelta, datetime
import tcp_multi_connections
from tcp_multi_connections import StatusEnum
from unittest.mock import patch, Mock, MagicMock
from unittest.mock import patch, Mock


class TestTcpMulitConnections(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ category_id: com.canonical.certification::gadget
plugin: resource
environ: GADGET_INTERFACE_FILE
command:
gadget_interface_utils.py --file $GADGET_INTERFACE_FILE --action dump
gadget_interface_utils.py --file "$GADGET_INTERFACE_FILE" --action dump

unit: template
template-resource: snap_interface_resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ command:
tool=$(look_up_xtest.py)
ta_path=""
if [[ "$tool" == "x-test.xtest" ]]; then
ta_path="$(find /var/snap -wholename */lib/optee_armtz)"
ta_path="$(find /var/snap -wholename '*/lib/optee_armtz')"
else
gadget=$(awk -F"." '{ print $1}' <<< "$tool")
ta_path="/snap/$gadget/current/lib/optee_armtz/"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id: strict-confinement-full
unit: test plan
_name: Strict-confinement - Full manual + automated tests for Ubuntu Core in strict confinement environment
_name: Full manual + automated tests for Ubuntu Core in strict confinement
_description:
Combined manual and automated test plans for Ubuntu Core in strict confinement environment.
include:
Expand All @@ -12,7 +12,7 @@ nested_part:

id: strict-confinement-manual
unit: test plan
_name: Strict-confinement - Manual only QA tests for Ubuntu Core in strict confinement environment
_name: Manual only QA tests for Ubuntu Core in strict confinement
_description:
Ubuntu Core QA test plan for strict confinement environment.
This test plan contains all of the tests that require manual
Expand All @@ -25,7 +25,7 @@ exclude:

id: strict-confinement-automated
unit: test plan
_name: Strict-confinement - Automated only QA tests for Ubuntu Core in strict confinement environment
_name: Automated only QA tests for Ubuntu Core in strict confinement
_description:
Ubuntu Core QA test plan for the strict confinement environment.
This test plan contains all of the automated tests used to validate
Expand All @@ -40,7 +40,7 @@ exclude:

id: after-suspend-strict-confinement-manual
unit: test plan
_name: Strict-confinement - After suspend Manual only QA tests for Ubuntu Core in strict confinement environment
_name: After suspend Manual only QA tests for Ubuntu Core in strict confinement
_description:
Ubuntu Core QA test plan for strict confinement environment.
This test plan contains all of the tests that require manual
Expand All @@ -53,7 +53,7 @@ exclude:

id: after-suspend-strict-confinement-automated
unit: test plan
_name: Strict-confinement - After suspend Automated only QA tests for Ubuntu Core in strict confinement environment
_name: After suspend Automated only QA tests for Ubuntu Core in strict confinement
_description:
Ubuntu Core QA test plan for the strict confinement environment.
This test plan contains all of the automated tests used to validate
Expand Down

0 comments on commit 924882a

Please sign in to comment.