From NFC Tools
Jump to: navigation, search

Current testing scheme is not extensive but a few elements are already in place:


Coding style

More detailed info in HACKING file.
Some basic coding style integrity is achieved through astyle.
You can invoke it with the proper options by calling

make style

Static analysis

More detailed info in HACKING file.


autoreconf -Wall -vis


export CFLAGS="-Wall -g -O2 -Wextra -pipe -funsigned-char -fstrict-aliasing \
  -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wunused \
  -Wuninitialized -Wpointer-arith -Wredundant-decls -Winline -Wformat \
  -Wformat-security -Wswitch-enum -Winit-self -Wmissing-include-dirs \
  -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition \
  -Wbad-function-cast -Wnested-externs -Wmissing-declarations"


scan-build ./configure
make clean
scan-build make


cppcheck --quiet \
  -I include -I libnfc -I libnfc/buses -I libnfc/chips -I libnfc/drivers \
  --check-config .
cppcheck --quiet --enable=all --std=posix --std=c99 \
  -I include -I libnfc -I libnfc/buses -I libnfc/chips -I libnfc/drivers \
  -DLOG -D__linux__ \
  --force --inconclusive .

Note that earlier versions are still reporting a number of false positive, better to work with a recent version of cppcheck.
At the moment development team is using v1.58


lintian --info --display-info --display-experimental *deb

(ongoing) flawfinder

flawfinder --quiet --dataonly --singleline --followdotdir .|sort -k 2 -r

At the moment there is still a lot of information out of flawfinder to process or reject...


Beside the full-fledged libnfc, smaller or more specialized versions have to be available for e.g. for exotic or embedded platforms.
So any combination of the following flags or situations has to be supported:

  • enable/disable logs
  • enable/disable debug
  • enable/disable conffiles
  • enable/disable envvars
  • with/without cutter
  • with/without libusb
  • with/without libpcsclite
  • with all drivers or any subset (+ dependency on libusb & libpcsclite availability of course)

Cross-platform compatibility

libnfc is supposed to work on the following platforms and therefore has therefore to be tested on those platforms as often and extensively as possible:

  • Linux
    • autotools / gcc
    • cmake / gcc
    • cmake / clang
  • FreeBSD
  • Mac OS X
  • Windows
    • cmake / mingw



At the moment a not yet public instance of Jenkins, a continuous building/testing framework, has been put in place with the goal of automating as much as possible the different configuration combinations mentioned above.
A challenge will be to extend it to more platforms (at the moment it runs under Linux).
Current coverage:

  • Warns if style gets broken and "make style" is required
  • (linux) autotools+gcc, all drivers, all combinations of enable/disable conffiles/envvars/log
  • (linux) autotools+gcc, individual drivers alone, enable conffiles/envvars/log
  • (linux) cmake+clang, default config
  • (linux) Debian package, default config
  • cppcheck
  • trigger libfreefare compilation

Hardware testing

That part is the most difficult as it cannot be fully automated.
libnfc supports a number of different readers and different tag technologies and offers a number of utils & examples to be tested.
An earlier attempt of documenting tests has been done with the manual-test-results.txt file available in sources.
It would be interesting to define a meaningful subset of combinations to test.


Some tests are also automated using cutter. They only test the p2p aspects and therefore require two readers to be plugged in the same computer and to be put physically against each other.

make check

Indirect tests on libnfc can also be done via the cutter tests of libfreefare, those ones are more related to the Mifare family tags. See HACKING file in libfreefare sources.

subset of tools & tags

An attempt inspired from manual-test-results.txt:

  • nfc-scan-device
  • nfc-list -v & 2 DESFire
  • nfc-list -v & 2 MFC or MFUL or MFULC
  • nfc-list -v & Topaz/Jewel
  • nfc-list -v & FeliCa
  • nfc-list -v & typeB (e.g. Calypso) preferably with the ASK LoGO reader
  • nfc-list -v & typeB' (e.g. Paris Navigo Pass)
  • nfc-list -v & ISO14443B-2 ST SRx
  • nfc-list -v & ISO14443B-2 ASK CTx
  • nfc-poll -v & 2 DESFire
  • nfc-poll -v & 2 MFC or MFUL or MFULC
  • nfc-poll -v & Topaz/Jewel
  • nfc-poll -v & FeliCa
  • nfc-poll -v & typeB (e.g. Calypso) preferably with the ASK LoGO reader
  • nfc-anticol & 1 DESfire
  • nfc-anticol & 1 MFC
  • nfc-anticol & 1 MFUL
  • nfc-poll (only on pn532 devices)
  • nfc-emulate-forum-tag4 (only on pn532 devices) & e.g. Nexus phone
  • nfc-emulate-forum-tag4 (only on pn532 devices); ctrl-c; nfc-list
  • nfc-emulate-tag & e.g. Omnikey Cardman 5321
  • nfc-emulate-tag; ctrl-c; nfc-list
  • nfc-read-forum-tag3 & NFC Forum Type 3 Tag
  • nfc-dep-initiator & nfc-dep-target, should be covered by "make check" cutter tests

drivers & readers

Each driver should be tested with typical readers:

  • acr122_pcsc
    • Using ACR122
    • Using Touchatag
  • acr122_usb
    • Using ACR122
    • Using Touchatag
    • with pcsc still running?
  • acr122s
    • Using ACR122S
  • arygon
    • Using ADRA-USB (! PN531 does not support all libnfc features)
    • Using ADRB-USB
  • pn532_spi
    • Using PN532 NFC Breakout Board on Raspberry-Pi
  • pn532_uart
    • Using PN532 NFC Breakout Board with FTDI cable or APDB1UA33N reader
  • pn53x_usb
    • Using SCL3711 without pcsc

Open questions

  • status of cross-compilation?
  • support of config files on Windows?
  • support of envvars on Windows?
  • support of all drivers on Windows?


Personal tools