aboutsummaryrefslogtreecommitdiff
path: root/unittest/test_storage.py
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2019-01-15 15:52:37 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2019-01-15 15:52:37 +0100
commit8d67c0f80aab724d67a1b6efb8af16aa71631a84 (patch)
tree4b49a7caa97f395502f16fcd790fdee48e7a688d /unittest/test_storage.py
parent1f3da5c76acb20b2183ac52373ed3b0b63e1151e (diff)
parenta20bf2b343e8e30e8b3f377da210c67027a9ecf3 (diff)
downloadlibnitrokey-8d67c0f80aab724d67a1b6efb8af16aa71631a84.tar.gz
libnitrokey-8d67c0f80aab724d67a1b6efb8af16aa71631a84.tar.bz2
Merge branch '144-python_multiline'
Add Python support for multiline declarations in NK_C_API.h Add test for reading a structure, which uses multiline declaration Add offline test for Python CI: execute offline test for Python (GCC5 build only) Fixes #144
Diffstat (limited to 'unittest/test_storage.py')
-rw-r--r--unittest/test_storage.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/unittest/test_storage.py b/unittest/test_storage.py
index 2aa8441..04b0581 100644
--- a/unittest/test_storage.py
+++ b/unittest/test_storage.py
@@ -24,7 +24,8 @@ import pytest
from conftest import skip_if_device_version_lower_than
from constants import DefaultPasswords, DeviceErrorCode, bb
-from misc import gs, wait
+from misc import gs, wait, ffi
+
pprint = pprint.PrettyPrinter(indent=4).pprint
@@ -367,3 +368,30 @@ def test_send_startup(C):
skip_if_device_version_lower_than({'S': 43})
time_seconds_from_epoch = 0 # FIXME set proper date
assert C.NK_send_startup(time_seconds_from_epoch) == DeviceErrorCode.STATUS_OK
+
+
+@pytest.mark.other
+def test_struct_multiline_prodtest(C):
+ info_st = ffi.new('struct NK_storage_ProductionTest *')
+ if info_st is None: raise Exception('Invalid value')
+ err = C.NK_get_storage_production_info(info_st)
+ assert err == 0
+ assert info_st.SD_Card_ManufacturingYear_u8 != 0
+ assert info_st.SD_Card_ManufacturingMonth_u8 != 0
+ assert info_st.SD_Card_Size_u8 != 0
+ assert info_st.FirmwareVersion_au8[0] == 0
+ assert info_st.FirmwareVersion_au8[1] >= 50
+
+ info = 'CPU:{CPU},SC:{SC},SD:{SD},' \
+ 'SCM:{SCM},SCO:{SCO},DAT:{DAT},Size:{size},Firmware:{fw} - {fwb}'.format(
+ CPU='0x{:08x}'.format(info_st.CPU_CardID_u32),
+ SC='0x{:08x}'.format(info_st.SmartCardID_u32),
+ SD='0x{:08x}'.format(info_st.SD_CardID_u32),
+ SCM='0x{:02x}'.format(info_st.SD_Card_Manufacturer_u8),
+ SCO='0x{:04x}'.format(info_st.SD_Card_OEM_u16),
+ DAT='20{}.{}'.format(info_st.SD_Card_ManufacturingYear_u8, info_st.SD_Card_ManufacturingMonth_u8),
+ size=info_st.SD_Card_Size_u8,
+ fw='{}.{}'.format(info_st.FirmwareVersion_au8[0], info_st.FirmwareVersion_au8[1]),
+ fwb=info_st.FirmwareVersionInternal_u8
+ )
+ print(info)