From b5559e912b25fe21693140419d47c1f5fba26f2b Mon Sep 17 00:00:00 2001 From: Dmitry Perchanov Date: Mon, 15 Apr 2024 17:29:10 +0200 Subject: [PATCH 1/3] unit-tests: check hwmc error codes Verify error codes returned by hwmc bad commands. This test relevant to D457 MIPI driver version. Expected: d4xx driver versions above 1.0.1.21 - pass below 1.0.1.21 - fail Tracked-by: LRS-1065 Signed-off-by: Dmitry Perchanov --- .../live/debug_protocol/test-hwmc-errors.py | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 unit-tests/live/debug_protocol/test-hwmc-errors.py diff --git a/unit-tests/live/debug_protocol/test-hwmc-errors.py b/unit-tests/live/debug_protocol/test-hwmc-errors.py new file mode 100644 index 0000000000..0b3fc5996b --- /dev/null +++ b/unit-tests/live/debug_protocol/test-hwmc-errors.py @@ -0,0 +1,109 @@ +# License: Apache 2.0. See LICENSE file in root directory. +# Copyright(c) 2022 Intel Corporation. All Rights Reserved. + +# test:device D400* + +import pyrealsense2 as rs +from rspy import devices, log, test, file, repo + + +############################################################################################# +# Help Functions +############################################################################################# + +def convert_bytes_string_to_decimal_list(command): + command_input = [] # array of uint_8t + + # Parsing the command to array of unsigned integers(size should be < 8bits) + # threw out spaces + command = command.lower() + command = command.split() + + for byte in command: + command_input.append(int('0x' + byte, 0)) + + return command_input + + +def send_hardware_monitor_command(device, command): + raw_result = rs.debug_protocol(device).send_and_receive_raw_data(command) + status = raw_result[:4] + result = raw_result[4:] + return status, result + + +############################################################################################# +# Tests +############################################################################################# + +test.start("Init") +try: + ctx = rs.context() + dev = ctx.query_devices()[0] +except: + test.unexpected_exception() +test.finish() + +############################################################################################# + +test.start("WRONGCOMMAND") +try: + hwmc_opcode_as_int = 0xee + hwmc_opcode_as_string = "ff ff ff ff" # little endian + + raw_command = rs.debug_protocol(dev).build_command(hwmc_opcode_as_int) + status, new_scenario_result = send_hardware_monitor_command(dev, raw_command) + + # expected status in case of success of "send_hardware_monitor_command" is the same as opcode + # we expect erro code instead of opcode + expected_status = convert_bytes_string_to_decimal_list(hwmc_opcode_as_string) + test.check_equal_lists(status, expected_status) + +except: + test.unexpected_exception() +test.finish() + +############################################################################################# + +test.start("GETSUBPRESETID") +try: + hwmc_opcode_as_int = 0x7d + # ERR_NoDataToReturn = -21 = 0xeb + hwmc_opcode_as_string = "eb ff ff ff" # little endian + + raw_command = rs.debug_protocol(dev).build_command(hwmc_opcode_as_int) + status, new_scenario_result = send_hardware_monitor_command(dev, raw_command) + + # expected status in case of success of "send_hardware_monitor_command" is the same as opcode + # we expect erro code instead of opcode + expected_status = convert_bytes_string_to_decimal_list(hwmc_opcode_as_string) + test.check_equal_lists(status, expected_status) + +except: + test.unexpected_exception() +test.finish() + +############################################################################################# + +test.start("SPWM") +try: + hwmc_opcode_as_int = 0x1a + # ERR_WrongParameter = -6 = 0xfa + hwmc_opcode_as_string = "fa ff ff ff" # little endian + + raw_command = rs.debug_protocol(dev).build_command(hwmc_opcode_as_int) + raw_command[9] = 2 + status, new_scenario_result = send_hardware_monitor_command(dev, raw_command) + + # expected status in case of success of "send_hardware_monitor_command" is the same as opcode + # we expect erro code instead of opcode + expected_status = convert_bytes_string_to_decimal_list(hwmc_opcode_as_string) + test.check_equal_lists(status, expected_status) + +except: + test.unexpected_exception() +test.finish() + +############################################################################################# + +test.print_results_and_exit() From 69457775858ede9a74862c035382699986b38923 Mon Sep 17 00:00:00 2001 From: Dmitry Perchanov Date: Thu, 18 Apr 2024 08:44:15 +0200 Subject: [PATCH 2/3] tests: hwmc-errors: Improve test description and syntaxes. Signed-off-by: Dmitry Perchanov --- .../live/debug_protocol/test-hwmc-errors.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/unit-tests/live/debug_protocol/test-hwmc-errors.py b/unit-tests/live/debug_protocol/test-hwmc-errors.py index 0b3fc5996b..0fa2bea628 100644 --- a/unit-tests/live/debug_protocol/test-hwmc-errors.py +++ b/unit-tests/live/debug_protocol/test-hwmc-errors.py @@ -46,16 +46,16 @@ def send_hardware_monitor_command(device, command): ############################################################################################# -test.start("WRONGCOMMAND") +test.start("WRONG COMMAND") try: hwmc_opcode_as_int = 0xee hwmc_opcode_as_string = "ff ff ff ff" # little endian raw_command = rs.debug_protocol(dev).build_command(hwmc_opcode_as_int) - status, new_scenario_result = send_hardware_monitor_command(dev, raw_command) + status, result = send_hardware_monitor_command(dev, raw_command) # expected status in case of success of "send_hardware_monitor_command" is the same as opcode - # we expect erro code instead of opcode + # we expect error code instead of opcode expected_status = convert_bytes_string_to_decimal_list(hwmc_opcode_as_string) test.check_equal_lists(status, expected_status) @@ -65,17 +65,17 @@ def send_hardware_monitor_command(device, command): ############################################################################################# -test.start("GETSUBPRESETID") +test.start("GETSUBPRESETID - No Data to Return") try: hwmc_opcode_as_int = 0x7d # ERR_NoDataToReturn = -21 = 0xeb hwmc_opcode_as_string = "eb ff ff ff" # little endian raw_command = rs.debug_protocol(dev).build_command(hwmc_opcode_as_int) - status, new_scenario_result = send_hardware_monitor_command(dev, raw_command) + status, result = send_hardware_monitor_command(dev, raw_command) # expected status in case of success of "send_hardware_monitor_command" is the same as opcode - # we expect erro code instead of opcode + # we expect error code instead of opcode expected_status = convert_bytes_string_to_decimal_list(hwmc_opcode_as_string) test.check_equal_lists(status, expected_status) @@ -85,7 +85,7 @@ def send_hardware_monitor_command(device, command): ############################################################################################# -test.start("SPWM") +test.start("Set PWM - Wrong Parameter") try: hwmc_opcode_as_int = 0x1a # ERR_WrongParameter = -6 = 0xfa @@ -93,10 +93,10 @@ def send_hardware_monitor_command(device, command): raw_command = rs.debug_protocol(dev).build_command(hwmc_opcode_as_int) raw_command[9] = 2 - status, new_scenario_result = send_hardware_monitor_command(dev, raw_command) + status, result = send_hardware_monitor_command(dev, raw_command) # expected status in case of success of "send_hardware_monitor_command" is the same as opcode - # we expect erro code instead of opcode + # we expect error code instead of opcode expected_status = convert_bytes_string_to_decimal_list(hwmc_opcode_as_string) test.check_equal_lists(status, expected_status) From 9bc304ac5d36707a2a92dd73fd46fa117aebd328 Mon Sep 17 00:00:00 2001 From: Dmitry Perchanov Date: Thu, 18 Apr 2024 10:55:26 +0200 Subject: [PATCH 3/3] unit-tests: hwmc-errors copyright date update Signed-off-by: Dmitry Perchanov --- unit-tests/live/debug_protocol/test-hwmc-errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit-tests/live/debug_protocol/test-hwmc-errors.py b/unit-tests/live/debug_protocol/test-hwmc-errors.py index 0fa2bea628..17a15e25e8 100644 --- a/unit-tests/live/debug_protocol/test-hwmc-errors.py +++ b/unit-tests/live/debug_protocol/test-hwmc-errors.py @@ -1,5 +1,5 @@ # License: Apache 2.0. See LICENSE file in root directory. -# Copyright(c) 2022 Intel Corporation. All Rights Reserved. +# Copyright(c) 2024 Intel Corporation. All Rights Reserved. # test:device D400*