Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libbluetooth add tests for the following libblueto...
details: https://anonhg.NetBSD.org/src/rev/9dea807fa201
branches: trunk
changeset: 763923:9dea807fa201
user: plunky <plunky%NetBSD.org@localhost>
date: Thu Apr 07 06:21:57 2011 +0000
description:
add tests for the following libbluetooth functions
bluetooth(3)
bt_aton()
bt_ntoa()
sdp_data(3)
sdp_data_type()
sdp_data_size()
sdp_get_data()
sdp_get_attr()
sdp_get_uuid()
sdp_get_bool()
sdp_get_uint()
sdp_get_int()
sdp_get_seq()
sdp_get_alt()
sdp_get_str()
sdp_get_url()
sdp_match_uuid16()
sdp_put_data()
sdp_put_attr()
sdp_put_uuid()
sdp_put_uuid16()
sdp_put_uuid2(3)
sdp_put_uuid128()
sdp_put_bool()
sdp_put_uint()
sdp_put_uint8()
sdp_put_uint16()
sdp_put_uint2(3)
sdp_put_uint64()
sdp_put_int()
sdp_put_int8()
sdp_put_int16()
sdp_put_int2(3)
sdp_put_int64()
sdp_put_seq()
sdp_put_alt()
sdp_put_str()
sdp_put_url()
sdp_set_bool()
sdp_set_uint()
sdp_set_int()
sdp_set_seq()
sdp_set_alt()
[all pass on i386]
diffstat:
tests/lib/libbluetooth/Makefile | 17 +
tests/lib/libbluetooth/t_bluetooth.c | 87 +++
tests/lib/libbluetooth/t_sdp_data.c | 136 +++++
tests/lib/libbluetooth/t_sdp_get.c | 643 +++++++++++++++++++++++++
tests/lib/libbluetooth/t_sdp_match.c | 87 +++
tests/lib/libbluetooth/t_sdp_put.c | 873 +++++++++++++++++++++++++++++++++++
tests/lib/libbluetooth/t_sdp_set.c | 359 ++++++++++++++
7 files changed, 2202 insertions(+), 0 deletions(-)
diffs (truncated from 2230 to 300 lines):
diff -r b2bd025fe24c -r 9dea807fa201 tests/lib/libbluetooth/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libbluetooth/Makefile Thu Apr 07 06:21:57 2011 +0000
@@ -0,0 +1,17 @@
+# $NetBSD: Makefile,v 1.1 2011/04/07 06:21:57 plunky Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/lib/libbluetooth
+
+DPADD+= ${LIBBLUETOOTH}
+LDADD+= -lbluetooth
+
+TESTS_C+= t_bluetooth
+TESTS_C+= t_sdp_data
+TESTS_C+= t_sdp_get
+TESTS_C+= t_sdp_match
+TESTS_C+= t_sdp_put
+TESTS_C+= t_sdp_set
+
+.include <bsd.test.mk>
diff -r b2bd025fe24c -r 9dea807fa201 tests/lib/libbluetooth/t_bluetooth.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libbluetooth/t_bluetooth.c Thu Apr 07 06:21:57 2011 +0000
@@ -0,0 +1,87 @@
+/* $NetBSD: t_bluetooth.c,v 1.1 2011/04/07 06:21:57 plunky Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Iain Hibbert.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <atf-c.h>
+
+#include <bluetooth.h>
+#include <string.h>
+
+ATF_TC(check_bt_aton);
+
+ATF_TC_HEAD(check_bt_aton, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Test bt_aton results");
+}
+
+ATF_TC_BODY(check_bt_aton, tc)
+{
+ bdaddr_t bdaddr;
+
+ ATF_CHECK_EQ(bt_aton("0a:0b:0c:0d:0e", &bdaddr), 0);
+ ATF_CHECK_EQ(bt_aton("0a:0b:0c:0d0:0e:0f", &bdaddr), 0);
+ ATF_CHECK_EQ(bt_aton("0a:0b:0c:0d:0e:0f:00", &bdaddr), 0);
+ ATF_CHECK_EQ(bt_aton("0a:0b:0c:0d:0e:0f\n", &bdaddr), 0);
+ ATF_CHECK_EQ(bt_aton(" 0a:0b:0c:0d:0e:0f", &bdaddr), 0);
+ ATF_CHECK_EQ(bt_aton("0a:0b:0x:0d:0e:0f", &bdaddr), 0);
+
+ ATF_REQUIRE(bt_aton("0a:0b:0c:0d:0e:0f", &bdaddr));
+ ATF_CHECK_EQ(bdaddr.b[0], 0x0f);
+ ATF_CHECK_EQ(bdaddr.b[1], 0x0e);
+ ATF_CHECK_EQ(bdaddr.b[2], 0x0d);
+ ATF_CHECK_EQ(bdaddr.b[3], 0x0c);
+ ATF_CHECK_EQ(bdaddr.b[4], 0x0b);
+ ATF_CHECK_EQ(bdaddr.b[5], 0x0a);
+}
+
+ATF_TC(check_bt_ntoa);
+
+ATF_TC_HEAD(check_bt_ntoa, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Test bt_ntoa results");
+}
+
+ATF_TC_BODY(check_bt_ntoa, tc)
+{
+ bdaddr_t bdaddr = { { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 } };
+
+ ATF_CHECK_STREQ(bt_ntoa(&bdaddr, NULL), "55:44:33:22:11:00");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, check_bt_aton);
+ ATF_TP_ADD_TC(tp, check_bt_ntoa);
+
+ return atf_no_error();
+}
diff -r b2bd025fe24c -r 9dea807fa201 tests/lib/libbluetooth/t_sdp_data.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libbluetooth/t_sdp_data.c Thu Apr 07 06:21:57 2011 +0000
@@ -0,0 +1,136 @@
+/* $NetBSD: t_sdp_data.c,v 1.1 2011/04/07 06:21:57 plunky Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Iain Hibbert.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <atf-c.h>
+
+#include <sdp.h>
+
+ATF_TC(check_sdp_data_type);
+
+ATF_TC_HEAD(check_sdp_data_type, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Test sdp_data_type results");
+}
+
+ATF_TC_BODY(check_sdp_data_type, tc)
+{
+ uint8_t data[] = {
+ 0x00, // nil
+ 0x08, 0x00, // uint8 0x00
+ };
+ sdp_data_t test = { data, data + sizeof(data) };
+ sdp_data_t value;
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_NIL);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UINT8);
+
+ ATF_CHECK_EQ(test.next, test.end);
+}
+
+ATF_TC(check_sdp_data_size);
+
+ATF_TC_HEAD(check_sdp_data_size, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Test sdp_data_size results");
+}
+
+ATF_TC_BODY(check_sdp_data_size, tc)
+{
+ uint8_t data[] = {
+ 0x00, // nil
+ 0x08, 0x00, // uint8
+ 0x11, 0x00, 0x00, // int16
+ 0x1a, 0x00, 0x00, 0x00, // uuid32
+ 0x00,
+ 0x28, 0x00, // bool
+ 0x25, 0x00, // str8(0)
+ 0x25, 0x02, 0x00, 0x00, // str8(2)
+ 0x36, 0x00, 0x00, // seq16(0)
+ 0x3e, 0x00, 0x05, 0x00, // alt16(5)
+ 0x00, 0x00, 0x00, 0x00,
+ 0x37, 0x00, 0x00, 0x00, // seq32(0)
+ 0x00,
+ 0x47, 0x00, 0x00, 0x00, // url32(7)
+ 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ };
+ sdp_data_t test = { data, data + sizeof(data) };
+ sdp_data_t value;
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 1);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 2);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 3);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 5);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 2);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 2);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 4);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 3);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 8);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 5);
+
+ ATF_REQUIRE(sdp_get_data(&test, &value));
+ ATF_CHECK_EQ(sdp_data_size(&value), 12);
+
+ ATF_CHECK_EQ(test.next, test.end);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, check_sdp_data_type);
+ ATF_TP_ADD_TC(tp, check_sdp_data_size);
+
+ return atf_no_error();
+}
diff -r b2bd025fe24c -r 9dea807fa201 tests/lib/libbluetooth/t_sdp_get.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libbluetooth/t_sdp_get.c Thu Apr 07 06:21:57 2011 +0000
@@ -0,0 +1,643 @@
+/* $NetBSD: t_sdp_get.c,v 1.1 2011/04/07 06:21:57 plunky Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Iain Hibbert.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <atf-c.h>
+
+#include <limits.h>
+#include <sdp.h>
+#include <string.h>
+
+ATF_TC(check_sdp_get_data);
+
+ATF_TC_HEAD(check_sdp_get_data, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Test sdp_get_data results");
+}
Home |
Main Index |
Thread Index |
Old Index