- Detect errors in pn53x_get_reg();
- Add a test case to confirm an endianness problem on little-endian machines.
This commit is contained in:
parent
af291c5a16
commit
1130036bf3
4 changed files with 62 additions and 10 deletions
|
|
@ -8,13 +8,17 @@ TESTS = run-test.sh
|
|||
TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)"
|
||||
|
||||
noinst_LTLIBRARIES = \
|
||||
test_access_storm.la
|
||||
test_access_storm.la \
|
||||
test_register_endianness.la
|
||||
|
||||
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_register_endianness_la_SOURCES = test_register_endianness.c
|
||||
test_register_endianness_la_LIBADD = $(top_builddir)/libnfc/libnfc.la
|
||||
|
||||
echo-cutter:
|
||||
@echo $(CUTTER)
|
||||
|
||||
|
|
|
|||
39
test/test_register_endianness.c
Normal file
39
test/test_register_endianness.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include <cutter.h>
|
||||
|
||||
#include <nfc/nfc.h>
|
||||
|
||||
#define MAX_DEVICE_COUNT 1
|
||||
#define MAX_TARGET_COUNT 1
|
||||
|
||||
bool pn53x_get_reg(nfc_device_t* pnd, uint16_t ui16Reg, uint8_t* ui8Value);
|
||||
|
||||
void
|
||||
test_register_endianness (void)
|
||||
{
|
||||
nfc_device_desc_t devices[MAX_DEVICE_COUNT];
|
||||
size_t device_count;
|
||||
bool res;
|
||||
|
||||
nfc_list_devices (devices, MAX_DEVICE_COUNT, &device_count);
|
||||
if (!device_count)
|
||||
cut_omit ("No NFC device found");
|
||||
|
||||
nfc_device_t *device;
|
||||
|
||||
device = nfc_connect (&(devices[0]));
|
||||
cut_assert_not_null (device, cut_message ("nfc_connect"));
|
||||
|
||||
uint8_t value;
|
||||
|
||||
/* Read valid XRAM memory */
|
||||
res = pn53x_get_reg (device, 0xF0FF, &value);
|
||||
cut_assert_true (res, cut_message ("read register 0xF0FF"));
|
||||
nfc_perror (device, "get");
|
||||
|
||||
/* Read invalid SFR register */
|
||||
res = pn53x_get_reg (device, 0xFFF0, &value);
|
||||
cut_assert_false (res, cut_message ("read register 0xFFF0"));
|
||||
nfc_perror (device, "get");
|
||||
|
||||
nfc_disconnect (device);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue