forked from realsenseai/realsense_mipi_platform_driver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fw_version.py
More file actions
executable file
·36 lines (27 loc) · 1.53 KB
/
Copy pathtest_fw_version.py
File metadata and controls
executable file
·36 lines (27 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import subprocess
import pytest
@pytest.mark.d457
@pytest.mark.parametrize("device", {'0'})
def test_fw_version(device):
try:
key = "fw_version"
result = subprocess.check_call(["v4l2-ctl", "-d"+device, "-C", key])
assert result == 0
std_output = subprocess.check_output(["v4l2-ctl", "-d"+device, "-C", key])
key += ": "
assert key in std_output.decode(), "Couldn't fetch FW version"
# Remove the 'fw version: ' string from std output
fw_version = int(std_output.decode().replace(key, ""))
fw_version_str = str(fw_version>>24 & 0xFF) + "." + str(fw_version>>16 & 0xFF) + "." + str(fw_version>>8 & 0xFF) + "." + str(fw_version & 0xFF)
print ("fw_version:", fw_version_str)
# Check if the FW version matching with 5.x.x.x
assert fw_version == (fw_version & 0x05FFFFFF), "Expected FW version is 5.x.x.x, but received {}".format(fw_version_str)
# Get DFU device name
dfu_device = subprocess.check_output(["ls", "/sys/class/d4xx-class/"]).decode()
assert "d4xx-dfu-" in dfu_device, "D4xx DFU device not found"
# Get FW version from DFU device info
dfu_device_info = subprocess.check_output(["cat", "/dev/"+dfu_device.strip()]).decode()
# Check whether the DFU info also has same FW version
assert fw_version_str in dfu_device_info, "FW versions read through v4l2-ctl utility and DFU device info doesn't match"
except Exception as e:
assert False, "Exception caught during test: {}".format(e)