libfreefare/test/mifare_classic_fixture.c

59 lines
1.5 KiB
C
Raw Normal View History

2010-02-19 11:43:06 +01:00
/*-
* Copyright (C) 2010, Romain Tartiere.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* $Id$
*/
2010-01-11 21:14:30 +01:00
#include <cutter.h>
#include <freefare.h>
static nfc_device_t *device = NULL;
static MifareClassicTag *tags = NULL;
MifareClassicTag tag = NULL;
void
setup ()
{
int res;
device = nfc_connect (NULL);
2010-01-22 17:06:26 +01:00
cut_assert_not_null (device, cut_message ("No device found"));
2010-01-11 21:14:30 +01:00
tags = mifare_classic_get_tags (device);
cut_assert_not_null (tags, cut_message ("mifare_classic_get_tags() failed"));
2010-01-11 21:14:30 +01:00
cut_assert_not_null (tags[0], cut_message ("No MIFARE Classic tag on NFC device"));
2010-01-11 21:14:30 +01:00
tag = tags[0];
res = mifare_classic_connect (tag);
cut_assert_equal_int (0, res, cut_message ("mifare_classic_connect() failed"));
2010-01-11 21:14:30 +01:00
}
void
teardown ()
{
if (tag)
mifare_classic_disconnect (tag);
if (tags)
mifare_classic_free_tags (tags);
if (device)
nfc_disconnect (device);
}