test/test_dep*: rename test_dep to test_dep_passive and add new 106kbps pass.
This commit is contained in:
parent
90c05c7d13
commit
cc2622c49f
2 changed files with 42 additions and 11 deletions
|
@ -9,7 +9,7 @@ TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)"
|
|||
|
||||
cutter_unit_test_libs = \
|
||||
test_access_storm.la \
|
||||
test_dep.la \
|
||||
test_dep_passive.la \
|
||||
test_register_access.la \
|
||||
test_register_endianness.la
|
||||
|
||||
|
@ -24,8 +24,8 @@ AM_LDFLAGS = -module -rpath $(libdir) -avoid-version -no-undefined
|
|||
test_access_storm_la_SOURCES = test_access_storm.c
|
||||
test_access_storm_la_LIBADD = $(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
test_dep_la_SOURCES = test_dep.c
|
||||
test_dep_la_LIBADD = $(top_builddir)/libnfc/libnfc.la
|
||||
test_dep_passive_la_SOURCES = test_dep_passive.c
|
||||
test_dep_passive_la_LIBADD = $(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
test_register_access_la_SOURCES = test_register_access.c
|
||||
test_register_access_la_LIBADD = $(top_builddir)/libnfc/libnfc.la
|
||||
|
|
|
@ -85,8 +85,6 @@ target_thread (void *arg)
|
|||
bool res = nfc_target_init (device, &nt, abtRx, &szRx);
|
||||
cut_assert_true (res, cut_message ("Can't initialize NFC device as target: %s", nfc_strerror (device)));
|
||||
|
||||
const uint8_t abtAtrRes[] = "\x11\xd4\x00\x01\xfe\x12\x34\x56\x78\x90\x12\x00\x00\x00\x00\x00\x00";
|
||||
cut_assert_equal_memory (abtAtrRes, sizeof (abtAtrRes) - 1, abtRx, szRx, cut_message ("Invalid received ATR_RES"));
|
||||
if (!res) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
// First pass
|
||||
|
@ -124,6 +122,17 @@ target_thread (void *arg)
|
|||
cut_assert_true (res, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device)));
|
||||
if (!res) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
// Fourth pass
|
||||
res = nfc_target_receive_bytes (device, abtRx, &szRx, 500);
|
||||
cut_assert_true (res, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
|
||||
|
||||
cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
|
||||
if (!res) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
res = nfc_target_send_bytes (device, abtTx, sizeof(abtTx), 500);
|
||||
cut_assert_true (res, cut_message ("Can't send bytes to initiator: %s", nfc_strerror (device)));
|
||||
if (!res) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
return (void *) thread_res;
|
||||
}
|
||||
|
||||
|
@ -146,12 +155,12 @@ initiator_thread (void *arg)
|
|||
|
||||
nfc_target nt;
|
||||
|
||||
// Passive mode / 212Kbps
|
||||
printf ("=========== INITIATOR %s (Passive mode / 212Kbps) =========\n", nfc_device_name (device));
|
||||
res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_212, NULL, &nt, 5000);
|
||||
// Passive mode / 106Kbps
|
||||
printf ("=========== INITIATOR %s (Passive mode / 106Kbps) =========\n", nfc_device_name (device));
|
||||
res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_106, NULL, &nt, 5000);
|
||||
cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device)));
|
||||
cut_assert_equal_int (NMT_DEP, nt.nm.nmt, cut_message ("Invalid target modulation"));
|
||||
cut_assert_equal_int (NBR_212, nt.nm.nbr, cut_message ("Invalid target baud rate"));
|
||||
cut_assert_equal_int (NBR_106, nt.nm.nbr, cut_message ("Invalid target baud rate"));
|
||||
cut_assert_equal_memory ("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message ("Invalid target NFCID3"));
|
||||
cut_assert_equal_int (NDM_PASSIVE, nt.nti.ndi.ndm, cut_message ("Invalid target DEP mode"));
|
||||
cut_assert_equal_memory ("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message ("Invalid target general bytes"));
|
||||
|
@ -172,7 +181,7 @@ initiator_thread (void *arg)
|
|||
if (!res) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
// Passive mode / 212Kbps (second pass)
|
||||
printf ("=========== INITIATOR %s (Passive mode / 212Kbps, second pass) =========\n", nfc_device_name (device));
|
||||
printf ("=========== INITIATOR %s (Passive mode / 212Kbps) =========\n", nfc_device_name (device));
|
||||
res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_212, NULL, &nt, 1000);
|
||||
cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device)));
|
||||
cut_assert_equal_int (NMT_DEP, nt.nm.nmt, cut_message ("Invalid target modulation"));
|
||||
|
@ -193,7 +202,29 @@ initiator_thread (void *arg)
|
|||
cut_assert_true (res, cut_message ("Can't deselect target: %s", nfc_strerror (device)));
|
||||
if (!res) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
// Passive mode / 424Kbps
|
||||
// Passive mode / 212Kbps
|
||||
printf ("=========== INITIATOR %s (Passive mode / 212Kbps, second pass) =========\n", nfc_device_name (device));
|
||||
res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_212, NULL, &nt, 1000);
|
||||
cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device)));
|
||||
cut_assert_equal_int (NMT_DEP, nt.nm.nmt, cut_message ("Invalid target modulation"));
|
||||
cut_assert_equal_int (NBR_212, nt.nm.nbr, cut_message ("Invalid target baud rate"));
|
||||
cut_assert_equal_memory ("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message ("Invalid target NFCID3"));
|
||||
cut_assert_equal_int (NDM_PASSIVE, nt.nti.ndi.ndm, cut_message ("Invalid target DEP mode"));
|
||||
cut_assert_equal_memory ("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message ("Invalid target general bytes"));
|
||||
if (!res) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
szRx = sizeof (abtRx);
|
||||
res = nfc_initiator_transceive_bytes (device, abtTx, sizeof (abtTx), abtRx, &szRx, 5000);
|
||||
cut_assert_true (res, cut_message ("Can't transceive bytes to target: %s", nfc_strerror (device)));
|
||||
|
||||
cut_assert_equal_memory (abtAttRx, sizeof (abtAttRx), abtRx, szRx, cut_message ("Invalid received data"));
|
||||
if (!res) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
res = nfc_initiator_deselect_target (device);
|
||||
cut_assert_true (res, cut_message ("Can't deselect target: %s", nfc_strerror (device)));
|
||||
if (!res) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
// Passive mode / 424Kbps
|
||||
printf ("=========== INITIATOR %s (Passive mode / 424Kbps) =========\n", nfc_device_name (device));
|
||||
res = nfc_initiator_select_dep_target (device, NDM_PASSIVE, NBR_424, NULL, &nt, 1000);
|
||||
cut_assert_true (res, cut_message ("Can't select any DEP target: %s", nfc_strerror (device)));
|
Loading…
Reference in a new issue