1 1.2 plunky /* $NetBSD: t_bluetooth.c,v 1.2 2011/04/07 08:29:50 plunky Exp $ */ 2 1.1 plunky 3 1.1 plunky /*- 4 1.1 plunky * Copyright (c) 2011 The NetBSD Foundation, Inc. 5 1.1 plunky * All rights reserved. 6 1.1 plunky * 7 1.1 plunky * This code is derived from software contributed to The NetBSD Foundation 8 1.1 plunky * by Iain Hibbert. 9 1.1 plunky * 10 1.1 plunky * Redistribution and use in source and binary forms, with or without 11 1.1 plunky * modification, are permitted provided that the following conditions 12 1.1 plunky * are met: 13 1.1 plunky * 1. Redistributions of source code must retain the above copyright 14 1.1 plunky * notice, this list of conditions and the following disclaimer. 15 1.1 plunky * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 plunky * notice, this list of conditions and the following disclaimer in the 17 1.1 plunky * documentation and/or other materials provided with the distribution. 18 1.1 plunky * 19 1.1 plunky * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 plunky * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 plunky * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 plunky * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 plunky * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 plunky * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 plunky * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 plunky * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 plunky * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 plunky * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 plunky * POSSIBILITY OF SUCH DAMAGE. 30 1.1 plunky */ 31 1.1 plunky 32 1.1 plunky #include <atf-c.h> 33 1.1 plunky 34 1.1 plunky #include <bluetooth.h> 35 1.1 plunky #include <string.h> 36 1.1 plunky 37 1.1 plunky ATF_TC(check_bt_aton); 38 1.1 plunky 39 1.1 plunky ATF_TC_HEAD(check_bt_aton, tc) 40 1.1 plunky { 41 1.2 plunky 42 1.1 plunky atf_tc_set_md_var(tc, "descr", "Test bt_aton results"); 43 1.1 plunky } 44 1.2 plunky 45 1.1 plunky ATF_TC_BODY(check_bt_aton, tc) 46 1.1 plunky { 47 1.1 plunky bdaddr_t bdaddr; 48 1.1 plunky 49 1.1 plunky ATF_CHECK_EQ(bt_aton("0a:0b:0c:0d:0e", &bdaddr), 0); 50 1.1 plunky ATF_CHECK_EQ(bt_aton("0a:0b:0c:0d0:0e:0f", &bdaddr), 0); 51 1.1 plunky ATF_CHECK_EQ(bt_aton("0a:0b:0c:0d:0e:0f:00", &bdaddr), 0); 52 1.1 plunky ATF_CHECK_EQ(bt_aton("0a:0b:0c:0d:0e:0f\n", &bdaddr), 0); 53 1.1 plunky ATF_CHECK_EQ(bt_aton(" 0a:0b:0c:0d:0e:0f", &bdaddr), 0); 54 1.1 plunky ATF_CHECK_EQ(bt_aton("0a:0b:0x:0d:0e:0f", &bdaddr), 0); 55 1.1 plunky 56 1.1 plunky ATF_REQUIRE(bt_aton("0a:0b:0c:0d:0e:0f", &bdaddr)); 57 1.1 plunky ATF_CHECK_EQ(bdaddr.b[0], 0x0f); 58 1.1 plunky ATF_CHECK_EQ(bdaddr.b[1], 0x0e); 59 1.1 plunky ATF_CHECK_EQ(bdaddr.b[2], 0x0d); 60 1.1 plunky ATF_CHECK_EQ(bdaddr.b[3], 0x0c); 61 1.1 plunky ATF_CHECK_EQ(bdaddr.b[4], 0x0b); 62 1.1 plunky ATF_CHECK_EQ(bdaddr.b[5], 0x0a); 63 1.1 plunky } 64 1.1 plunky 65 1.1 plunky ATF_TC(check_bt_ntoa); 66 1.1 plunky 67 1.1 plunky ATF_TC_HEAD(check_bt_ntoa, tc) 68 1.1 plunky { 69 1.2 plunky 70 1.1 plunky atf_tc_set_md_var(tc, "descr", "Test bt_ntoa results"); 71 1.1 plunky } 72 1.2 plunky 73 1.1 plunky ATF_TC_BODY(check_bt_ntoa, tc) 74 1.1 plunky { 75 1.1 plunky bdaddr_t bdaddr = { { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 } }; 76 1.1 plunky 77 1.1 plunky ATF_CHECK_STREQ(bt_ntoa(&bdaddr, NULL), "55:44:33:22:11:00"); 78 1.1 plunky } 79 1.1 plunky 80 1.1 plunky ATF_TP_ADD_TCS(tp) 81 1.1 plunky { 82 1.1 plunky 83 1.1 plunky ATF_TP_ADD_TC(tp, check_bt_aton); 84 1.1 plunky ATF_TP_ADD_TC(tp, check_bt_ntoa); 85 1.1 plunky 86 1.1 plunky return atf_no_error(); 87 1.1 plunky } 88