Merge pull request #13 from Oichkatzelesfrettschen/eirikr/remove-netbsd-files-from-repository
This commit is contained in:
commit
01b7e3ef82
|
|
@ -1,19 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.5 2012/11/30 01:41:50 pgoyette Exp $
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/ipf
|
||||
|
||||
# t_bpf is omitted from the test list since we don't support it on NetBSD
|
||||
|
||||
.for name in t_filter_exec t_filter_parse t_logging t_nat_exec \
|
||||
t_nat_ipf_exec t_nat_parse t_pools
|
||||
TESTS_SH+= ${name}
|
||||
TESTS_SH_SRC_${name}= h_common.sh ${name}.sh
|
||||
.endfor
|
||||
|
||||
SUBDIR= regress input expected
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.7 2014/06/30 17:02:55 darrenr Exp $
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/ipf
|
||||
ATFFILE= no
|
||||
|
||||
FILESDIR= ${TESTSDIR}/expected
|
||||
FILES=\
|
||||
bpf-f1 \
|
||||
bpf1 \
|
||||
f1 \
|
||||
f10 \
|
||||
f11 \
|
||||
f12 \
|
||||
f13 \
|
||||
f14 \
|
||||
f15 \
|
||||
f16 \
|
||||
f17 \
|
||||
f18 \
|
||||
f19 \
|
||||
f2 \
|
||||
f20 \
|
||||
f21 \
|
||||
f22 \
|
||||
f24 \
|
||||
f25 \
|
||||
f26 \
|
||||
f27 \
|
||||
f28 \
|
||||
f29 \
|
||||
f3 \
|
||||
f30 \
|
||||
f4 \
|
||||
f5 \
|
||||
f6 \
|
||||
f7 \
|
||||
f8 \
|
||||
f9 \
|
||||
i1 \
|
||||
i10 \
|
||||
i11 \
|
||||
i12 \
|
||||
i13 \
|
||||
i14 \
|
||||
i15 \
|
||||
i16 \
|
||||
i17 \
|
||||
i18 \
|
||||
i19.dist \
|
||||
i2 \
|
||||
i20 \
|
||||
i21 \
|
||||
i22 \
|
||||
i23 \
|
||||
i3 \
|
||||
i4 \
|
||||
i5 \
|
||||
i6 \
|
||||
i7 \
|
||||
i8 \
|
||||
i9 \
|
||||
in1 \
|
||||
in1_6 \
|
||||
in100 \
|
||||
in100_6 \
|
||||
in101 \
|
||||
in101_6 \
|
||||
in102 \
|
||||
in102_6 \
|
||||
in2 \
|
||||
in2_6 \
|
||||
in3 \
|
||||
in3_6 \
|
||||
in4 \
|
||||
in4_6 \
|
||||
in5 \
|
||||
in5_6 \
|
||||
in6 \
|
||||
in6_6 \
|
||||
in7 \
|
||||
in8_6 \
|
||||
ip1 \
|
||||
ip2 \
|
||||
ip3 \
|
||||
ipv6.1 \
|
||||
ipv6.2 \
|
||||
ipv6.3 \
|
||||
ipv6.4 \
|
||||
ipv6.5 \
|
||||
ipv6.6 \
|
||||
l1 \
|
||||
l1.b \
|
||||
n1 \
|
||||
n10 \
|
||||
n100 \
|
||||
n101 \
|
||||
n102 \
|
||||
n103 \
|
||||
n104 \
|
||||
n105 \
|
||||
n106 \
|
||||
n11 \
|
||||
n11_6 \
|
||||
n12 \
|
||||
n12_6 \
|
||||
n13 \
|
||||
n13_6 \
|
||||
n14 \
|
||||
n14_6 \
|
||||
n15 \
|
||||
n15_6 \
|
||||
n16 \
|
||||
n17 \
|
||||
n18 \
|
||||
n1_6 \
|
||||
n2 \
|
||||
n200 \
|
||||
n2_6 \
|
||||
n3 \
|
||||
n4 \
|
||||
n4_6 \
|
||||
n5 \
|
||||
n5_6 \
|
||||
n6 \
|
||||
n6_6 \
|
||||
n7 \
|
||||
n7_6 \
|
||||
n8 \
|
||||
n8_6 \
|
||||
n9 \
|
||||
n9_6 \
|
||||
ni1 \
|
||||
ni10 \
|
||||
ni11 \
|
||||
ni12 \
|
||||
ni13 \
|
||||
ni14 \
|
||||
ni15 \
|
||||
ni16 \
|
||||
ni17 \
|
||||
ni18 \
|
||||
ni19 \
|
||||
ni2 \
|
||||
ni20 \
|
||||
ni21 \
|
||||
ni23 \
|
||||
ni3 \
|
||||
ni4 \
|
||||
ni5 \
|
||||
ni6 \
|
||||
ni7 \
|
||||
ni8 \
|
||||
ni9 \
|
||||
p1 \
|
||||
p10 \
|
||||
p11 \
|
||||
p12 \
|
||||
p13 \
|
||||
p2 \
|
||||
p3 \
|
||||
p4 \
|
||||
p5 \
|
||||
p6 \
|
||||
p7 \
|
||||
p9
|
||||
|
||||
.include <bsd.test.mk>
|
||||
.include <bsd.files.mk>
|
||||
.include <bsd.prog.mk>
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
# $NetBSD: h_common.sh,v 1.8 2013/05/16 07:20:29 martin Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# (C)opyright 1993-1996 by Darren Reed.
|
||||
#
|
||||
# See the IPFILTER.LICENCE file for details on licencing.
|
||||
#
|
||||
|
||||
h_copydata()
|
||||
{
|
||||
test -f $(atf_get_srcdir)/input/$1 && \
|
||||
cp $(atf_get_srcdir)/input/$1 in
|
||||
test -f $(atf_get_srcdir)/regress/$1 && \
|
||||
cp $(atf_get_srcdir)/regress/$1 reg
|
||||
test -f $(atf_get_srcdir)/expected/$1 && \
|
||||
cp $(atf_get_srcdir)/expected/$1 exp
|
||||
}
|
||||
|
||||
test_case()
|
||||
{
|
||||
local name="${1}"; shift
|
||||
local check_function="${1}"; shift
|
||||
|
||||
atf_test_case "${name}"
|
||||
eval "${name}_body() { \
|
||||
${check_function} '${name}' " "${@}" "; \
|
||||
}"
|
||||
}
|
||||
|
||||
broken_test_case()
|
||||
{
|
||||
local name="${1}"; shift
|
||||
local check_function="${1}"; shift
|
||||
|
||||
atf_test_case "${name}"
|
||||
eval "${name}_body() { \
|
||||
atf_skip 'This test case is probably broken'; \
|
||||
${check_function} '${name}' " "${@}" "; \
|
||||
}"
|
||||
}
|
||||
|
||||
failing_test_case()
|
||||
{
|
||||
local name="${1}"; shift
|
||||
local check_function="${1}"; shift
|
||||
local reason="${1}"; shift
|
||||
|
||||
atf_test_case "${name}"
|
||||
eval "${name}_body() { \
|
||||
atf_expect_fail '${reason}'; \
|
||||
${check_function} '${name}' " "${@}" "; \
|
||||
}"
|
||||
}
|
||||
|
||||
failing_test_case_be()
|
||||
{
|
||||
# this test fails on some architectures - not fully analyzed, assume
|
||||
# an endianess bug
|
||||
local name="${1}"; shift
|
||||
local check_function="${1}"; shift
|
||||
local reason="${1}"; shift
|
||||
|
||||
atf_test_case "${name}"
|
||||
|
||||
if [ `sysctl -n hw.byteorder` = 4321 ]; then
|
||||
eval "${name}_body() { \
|
||||
atf_expect_fail '${reason}'; \
|
||||
${check_function} '${name}' " "${@}" "; \
|
||||
}"
|
||||
else
|
||||
eval "${name}_body() { \
|
||||
${check_function} '${name}' " "${@}" "; \
|
||||
}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.7 2014/07/12 14:37:49 darrenr Exp $
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/ipf
|
||||
ATFFILE= no
|
||||
|
||||
FILESDIR= ${TESTSDIR}/input
|
||||
FILES=\
|
||||
f1 \
|
||||
f10 \
|
||||
f11 \
|
||||
f12 \
|
||||
f13 \
|
||||
f14 \
|
||||
f15 \
|
||||
f16 \
|
||||
f17 \
|
||||
f18 \
|
||||
f19 \
|
||||
f2 \
|
||||
f20 \
|
||||
f21 \
|
||||
f22 \
|
||||
f24 \
|
||||
f25 \
|
||||
f26 \
|
||||
f27 \
|
||||
f28 \
|
||||
f29 \
|
||||
f3 \
|
||||
f30 \
|
||||
f4 \
|
||||
f5 \
|
||||
f6 \
|
||||
f7 \
|
||||
f8 \
|
||||
f9 \
|
||||
ip2.data \
|
||||
ipv6.1 \
|
||||
ipv6.2 \
|
||||
ipv6.3 \
|
||||
ipv6.4 \
|
||||
ipv6.5 \
|
||||
ipv6.6 \
|
||||
l1 \
|
||||
n1 \
|
||||
n10 \
|
||||
n100 \
|
||||
n101 \
|
||||
n102 \
|
||||
n103 \
|
||||
n104 \
|
||||
n105 \
|
||||
n106 \
|
||||
n10_6 \
|
||||
n11 \
|
||||
n11_6 \
|
||||
n12 \
|
||||
n12_6 \
|
||||
n13 \
|
||||
n13_6 \
|
||||
n14 \
|
||||
n14_6 \
|
||||
n15 \
|
||||
n15_6 \
|
||||
n16 \
|
||||
n17 \
|
||||
n18 \
|
||||
n1_6 \
|
||||
n2 \
|
||||
n200 \
|
||||
n2_6 \
|
||||
n3 \
|
||||
n4 \
|
||||
n4_6 \
|
||||
n5 \
|
||||
n5_6 \
|
||||
n6 \
|
||||
n6_6 \
|
||||
n7 \
|
||||
n7_6 \
|
||||
n8 \
|
||||
n8_6 \
|
||||
n9 \
|
||||
n9_6 \
|
||||
ni1 \
|
||||
ni10 \
|
||||
ni11 \
|
||||
ni12 \
|
||||
ni13 \
|
||||
ni14 \
|
||||
ni15 \
|
||||
ni16 \
|
||||
ni17 \
|
||||
ni18 \
|
||||
ni19 \
|
||||
ni2 \
|
||||
ni20 \
|
||||
ni21 \
|
||||
ni23 \
|
||||
ni3 \
|
||||
ni4 \
|
||||
ni5 \
|
||||
ni6 \
|
||||
ni7 \
|
||||
ni8 \
|
||||
ni9 \
|
||||
p1 \
|
||||
p10 \
|
||||
p11 \
|
||||
p12 \
|
||||
p13 \
|
||||
p2 \
|
||||
p3 \
|
||||
p4 \
|
||||
p5 \
|
||||
p6 \
|
||||
p7 \
|
||||
p9
|
||||
|
||||
.include <bsd.test.mk>
|
||||
.include <bsd.files.mk>
|
||||
.include <bsd.prog.mk>
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.8 2014/07/12 14:37:49 darrenr Exp $
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/ipf
|
||||
ATFFILE= no
|
||||
|
||||
FILESDIR= ${TESTSDIR}/regress
|
||||
FILES=\
|
||||
bpf-f1 \
|
||||
bpf1 \
|
||||
f1 \
|
||||
f10 \
|
||||
f11 \
|
||||
f12 \
|
||||
f13 \
|
||||
f14 \
|
||||
f15 \
|
||||
f16 \
|
||||
f17 \
|
||||
f18 \
|
||||
f19 \
|
||||
f2 \
|
||||
f20 \
|
||||
f21 \
|
||||
f22 \
|
||||
f24 \
|
||||
f25 \
|
||||
f26 \
|
||||
f27 \
|
||||
f28.ipf \
|
||||
f28.pool \
|
||||
f29.ipf \
|
||||
f29.pool \
|
||||
f3 \
|
||||
f30 \
|
||||
f4 \
|
||||
f5 \
|
||||
f6 \
|
||||
f7 \
|
||||
f8 \
|
||||
f9 \
|
||||
i1 \
|
||||
i10 \
|
||||
i11 \
|
||||
i12 \
|
||||
i13 \
|
||||
i14 \
|
||||
i15 \
|
||||
i16 \
|
||||
i17 \
|
||||
i18 \
|
||||
i19 \
|
||||
i2 \
|
||||
i20 \
|
||||
i21 \
|
||||
i22 \
|
||||
i23 \
|
||||
i3 \
|
||||
i4 \
|
||||
i5 \
|
||||
i6 \
|
||||
i7 \
|
||||
i8 \
|
||||
i9 \
|
||||
in1 \
|
||||
in1_6 \
|
||||
in100 \
|
||||
in100_6 \
|
||||
in101 \
|
||||
in101_6 \
|
||||
in102 \
|
||||
in102_6 \
|
||||
in2 \
|
||||
in2_6 \
|
||||
in3 \
|
||||
in3_6 \
|
||||
in4 \
|
||||
in4_6 \
|
||||
in5 \
|
||||
in5_6 \
|
||||
in6 \
|
||||
in6_6 \
|
||||
in7 \
|
||||
in8_6 \
|
||||
ip1 \
|
||||
ip2 \
|
||||
ip3 \
|
||||
ipv6.1 \
|
||||
ipv6.2 \
|
||||
ipv6.3 \
|
||||
ipv6.4 \
|
||||
ipv6.5 \
|
||||
ipv6.6 \
|
||||
l1 \
|
||||
n1 \
|
||||
n10 \
|
||||
n100 \
|
||||
n101 \
|
||||
n102 \
|
||||
n103 \
|
||||
n104 \
|
||||
n105 \
|
||||
n106 \
|
||||
n10_6 \
|
||||
n11 \
|
||||
n11_6 \
|
||||
n12 \
|
||||
n12_6 \
|
||||
n13 \
|
||||
n13_6 \
|
||||
n14 \
|
||||
n14_6 \
|
||||
n15 \
|
||||
n15_6 \
|
||||
n16 \
|
||||
n16_6 \
|
||||
n17 \
|
||||
n18 \
|
||||
n1_6 \
|
||||
n2 \
|
||||
n200 \
|
||||
n2_6 \
|
||||
n3 \
|
||||
n4 \
|
||||
n4_6 \
|
||||
n5 \
|
||||
n5_6 \
|
||||
n6 \
|
||||
n6_6 \
|
||||
n7 \
|
||||
n7_6 \
|
||||
n8 \
|
||||
n8_6 \
|
||||
n9 \
|
||||
n9_6 \
|
||||
ni1.ipf \
|
||||
ni1.nat \
|
||||
ni10.ipf \
|
||||
ni10.nat \
|
||||
ni11.ipf \
|
||||
ni11.nat \
|
||||
ni12.ipf \
|
||||
ni12.nat \
|
||||
ni13.ipf \
|
||||
ni13.nat \
|
||||
ni14.ipf \
|
||||
ni14.nat \
|
||||
ni15.ipf \
|
||||
ni15.nat \
|
||||
ni16.ipf \
|
||||
ni16.nat \
|
||||
ni17.ipf \
|
||||
ni17.nat \
|
||||
ni18.ipf \
|
||||
ni18.nat \
|
||||
ni19.ipf \
|
||||
ni19.nat \
|
||||
ni2.ipf \
|
||||
ni2.nat \
|
||||
ni20.ipf \
|
||||
ni20.nat \
|
||||
ni21.ipf \
|
||||
ni21.nat \
|
||||
ni23.ipf \
|
||||
ni23.nat \
|
||||
ni3.ipf \
|
||||
ni3.nat \
|
||||
ni4.ipf \
|
||||
ni4.nat \
|
||||
ni5.ipf \
|
||||
ni5.nat \
|
||||
ni6.ipf \
|
||||
ni6.nat \
|
||||
ni7.ipf \
|
||||
ni7.nat \
|
||||
ni8.ipf \
|
||||
ni8.nat \
|
||||
ni9.ipf \
|
||||
ni9.nat \
|
||||
p1.ipf \
|
||||
p1.pool \
|
||||
p10.nat \
|
||||
p10.pool \
|
||||
p11.nat \
|
||||
p11.pool \
|
||||
p12.nat \
|
||||
p12.pool \
|
||||
p13.ipf \
|
||||
p13.pool \
|
||||
p2.ipf \
|
||||
p3.ipf \
|
||||
p3.pool \
|
||||
p4.nat \
|
||||
p4.pool \
|
||||
p5.ipf \
|
||||
p5.pool \
|
||||
p6.ipf \
|
||||
p6.pool \
|
||||
p6.whois \
|
||||
p7.nat \
|
||||
p7.pool \
|
||||
p9.nat \
|
||||
p9.pool
|
||||
|
||||
.include <bsd.test.mk>
|
||||
.include <bsd.files.mk>
|
||||
.include <bsd.prog.mk>
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
# $NetBSD: t_bpf.sh,v 1.3 2012/11/29 16:05:34 pgoyette Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# (C)opyright 1993-1996 by Darren Reed.
|
||||
#
|
||||
# See the IPFILTER.LICENCE file for details on licencing.
|
||||
#
|
||||
|
||||
itest()
|
||||
{
|
||||
h_copydata $1
|
||||
|
||||
case $3 in
|
||||
ipf)
|
||||
atf_check -o file:exp -e ignore ipf -Rnvf reg
|
||||
;;
|
||||
ipftest)
|
||||
atf_check -o file:exp ipftest -D -r reg -i /dev/null
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
bpftest()
|
||||
{
|
||||
h_copydata $(echo ${1} | tr _ -)
|
||||
cp "$(atf_get_srcdir)/input/$(echo ${1} | sed s,bpf_,,)" in
|
||||
|
||||
{ while read rule; do
|
||||
atf_check -o save:save -x "echo '$rule' | ipftest -Rbr - -i in"
|
||||
cat save >>out
|
||||
echo "--------" >>out
|
||||
done; } <reg
|
||||
|
||||
diff -u exp out || atf_fail "results differ"
|
||||
}
|
||||
|
||||
broken_test_case bpf1 itest text ipf
|
||||
broken_test_case bpf_f1 bpftest text text
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case bpf1
|
||||
atf_add_test_case bpf_f1
|
||||
}
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
# $NetBSD: t_filter_exec.sh,v 1.8 2013/03/17 03:00:05 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# (C)opyright 1993-1996 by Darren Reed.
|
||||
#
|
||||
# See the IPFILTER.LICENCE file for details on licencing.
|
||||
#
|
||||
|
||||
dotest()
|
||||
{
|
||||
h_copydata $1
|
||||
infmt=$2
|
||||
outfmt=$3
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
args=$@
|
||||
|
||||
if [ $outfmt = hex ] ; then
|
||||
output=-x
|
||||
else
|
||||
output=
|
||||
fi
|
||||
|
||||
{ while read rule; do
|
||||
atf_check -x "echo \"$rule\" | ipftest -F \
|
||||
$infmt $output -Rbr - -i in $args >>out"
|
||||
echo "--------" >>out
|
||||
done; } <reg
|
||||
|
||||
diff -u exp out || atf_fail "results differ"
|
||||
}
|
||||
|
||||
mtest()
|
||||
{
|
||||
h_copydata $1
|
||||
infmt=$2
|
||||
outfmt=$3
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
args=$@
|
||||
|
||||
if [ $outfmt = hex ] ; then
|
||||
output=-x
|
||||
else
|
||||
output=
|
||||
fi
|
||||
|
||||
|
||||
atf_check -o save:out ipftest -F $infmt $output -Rbr reg -i in $args
|
||||
echo "--------" >>out
|
||||
|
||||
diff -u exp out || atf_fail "results differ"
|
||||
}
|
||||
|
||||
dotest6()
|
||||
{
|
||||
h_copydata $(echo ${1} | tr _ .)
|
||||
infmt=$2
|
||||
outfmt=$3
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
args=$@
|
||||
|
||||
if [ $outfmt = hex ] ; then
|
||||
output=-x
|
||||
else
|
||||
output=
|
||||
fi
|
||||
|
||||
|
||||
ipftest -6 -r /dev/null -i /dev/null >/dev/null 2>&1 \
|
||||
|| atf_skip "skipping IPv6 tests"
|
||||
|
||||
{ while read rule; do
|
||||
atf_check -o save:save -x "echo \"$rule\" | \
|
||||
ipftest -F $infmt $output -6br - -i in $args"
|
||||
cat save >>out
|
||||
echo "--------" >>out
|
||||
done; } <reg
|
||||
|
||||
diff -u exp out || atf_fail "results differ"
|
||||
}
|
||||
|
||||
test_case f1 dotest text text
|
||||
test_case f2 dotest text text
|
||||
test_case f3 dotest text text
|
||||
test_case f4 dotest text text
|
||||
test_case f5 dotest text text
|
||||
test_case f6 dotest text text
|
||||
test_case f7 dotest text text
|
||||
test_case f8 dotest text text
|
||||
test_case f9 dotest text text
|
||||
test_case f10 dotest text text
|
||||
test_case f11 dotest text text -D
|
||||
test_case f12 dotest hex hex
|
||||
test_case f13 dotest hex hex
|
||||
test_case f14 dotest text text
|
||||
test_case f15 mtest text text
|
||||
test_case f16 mtest text text
|
||||
test_case f17 mtest hex hex
|
||||
test_case f18 mtest text text -D
|
||||
test_case f19 dotest text text -T state_max=3
|
||||
test_case f20 mtest text text
|
||||
test_case f24 mtest hex text
|
||||
test_case f25 mtest hex text -D
|
||||
failing_test_case f26 dotest "Known to be broken" text text
|
||||
failing_test_case f27 dotest "Known to be broken" hex text
|
||||
test_case f30 dotest text text
|
||||
test_case ipv6_1 dotest6 hex hex
|
||||
test_case ipv6_2 dotest6 hex hex
|
||||
test_case ipv6_3 dotest6 hex hex
|
||||
test_case ipv6_5 dotest6 hex hex
|
||||
test_case ipv6_6 dotest6 hex text
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case f1
|
||||
atf_add_test_case f2
|
||||
atf_add_test_case f3
|
||||
atf_add_test_case f4
|
||||
atf_add_test_case f5
|
||||
atf_add_test_case f6
|
||||
atf_add_test_case f7
|
||||
atf_add_test_case f8
|
||||
atf_add_test_case f9
|
||||
atf_add_test_case f10
|
||||
atf_add_test_case f11
|
||||
atf_add_test_case f12
|
||||
atf_add_test_case f13
|
||||
atf_add_test_case f14
|
||||
atf_add_test_case f15
|
||||
atf_add_test_case f16
|
||||
atf_add_test_case f17
|
||||
atf_add_test_case f18
|
||||
atf_add_test_case f19
|
||||
atf_add_test_case f20
|
||||
atf_add_test_case f24
|
||||
atf_add_test_case f25
|
||||
atf_add_test_case f26
|
||||
atf_add_test_case f27
|
||||
atf_add_test_case f30
|
||||
atf_add_test_case ipv6_1
|
||||
atf_add_test_case ipv6_2
|
||||
atf_add_test_case ipv6_3
|
||||
atf_add_test_case ipv6_5
|
||||
atf_add_test_case ipv6_6
|
||||
|
||||
}
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
# $NetBSD: t_filter_parse.sh,v 1.12 2014/12/06 19:31:25 dholland Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# (C)opyright 1993-1996 by Darren Reed.
|
||||
#
|
||||
# See the IPFILTER.LICENCE file for details on licencing.
|
||||
#
|
||||
|
||||
itest()
|
||||
{
|
||||
h_copydata $1
|
||||
|
||||
case $3 in
|
||||
ipf)
|
||||
atf_check -o file:exp -e ignore ipf -Rnvf reg
|
||||
;;
|
||||
ipftest)
|
||||
atf_check -o file:exp ipftest -D -r reg -i /dev/null
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
itest_i19()
|
||||
{
|
||||
cp "$(atf_get_srcdir)/expected/i19.dist" .
|
||||
|
||||
if [ "`grep LOG_SECURITY /usr/include/sys/syslog.h 2>&1`" = "" ] ; then
|
||||
if [ "`grep LOG_AUDIT /usr/include/sys/syslog.h 2>&1`" = "" ] ; then
|
||||
sed -e 's/security/!!!/g' i19.dist > i19.p1;
|
||||
else
|
||||
sed -e 's/security/audit/g' i19.dist > i19.p1;
|
||||
fi
|
||||
else
|
||||
cp i19.dist i19.p1;
|
||||
fi
|
||||
if [ "`grep LOG_AUTHPRIV /usr/include/sys/syslog.h 2>&1`" = "" ] ; then
|
||||
sed -e 's/authpriv/!!!/g' i19.p1 > i19.p2;
|
||||
else
|
||||
cp i19.p1 i19.p2;
|
||||
fi
|
||||
if [ "`grep LOG_LOGALERT /usr/include/sys/syslog.h 2>&1`" = "" ] ; then
|
||||
sed -e 's/logalert/!!!/g' i19.p2 > i19.p1;
|
||||
else
|
||||
cp i19.p2 i19.p1;
|
||||
fi
|
||||
if [ "`grep LOG_FTP /usr/include/sys/syslog.h 2>&1`" = "" ] ; then
|
||||
sed -e 's/ftp/!!!/g' i19.p1 > i19.p2;
|
||||
else
|
||||
cp i19.p1 i19.p2;
|
||||
fi
|
||||
if [ "`egrep 'LOG_CRON.*15' /usr/include/sys/syslog.h 2>&1`" != "" ] ; then
|
||||
sed -e 's/cron/cron2/g' i19.p2 > i19;
|
||||
else
|
||||
cp i19.p2 i19;
|
||||
fi
|
||||
/bin/rm i19.p?
|
||||
|
||||
mv i19 exp
|
||||
itest "$@"
|
||||
}
|
||||
|
||||
test_case i1 itest text ipf
|
||||
test_case i2 itest text ipf
|
||||
test_case i3 itest text ipf
|
||||
test_case i4 itest text ipf
|
||||
test_case i5 itest text ipf
|
||||
test_case i6 itest text ipf
|
||||
test_case i7 itest text ipf
|
||||
test_case i8 itest text ipf
|
||||
test_case i9 itest text ipf
|
||||
test_case i10 itest text ipf
|
||||
test_case i11 itest text ipf
|
||||
test_case i12 itest text ipf
|
||||
test_case i13 itest text ipf
|
||||
test_case i14 itest text ipf
|
||||
test_case i15 itest text ipf
|
||||
test_case i16 itest text ipf
|
||||
failing_test_case i17 itest "Known to be broken" text ipftest
|
||||
test_case i18 itest text ipf
|
||||
test_case i19 itest_i19 text ipf
|
||||
test_case i20 itest text ipf
|
||||
test_case i21 itest text ipf
|
||||
test_case i22 itest text ipf
|
||||
test_case i23 itest text ipf
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case i1
|
||||
atf_add_test_case i2
|
||||
atf_add_test_case i3
|
||||
atf_add_test_case i4
|
||||
atf_add_test_case i5
|
||||
atf_add_test_case i6
|
||||
atf_add_test_case i7
|
||||
atf_add_test_case i8
|
||||
atf_add_test_case i9
|
||||
atf_add_test_case i10
|
||||
atf_add_test_case i11
|
||||
atf_add_test_case i12
|
||||
atf_add_test_case i13
|
||||
atf_add_test_case i14
|
||||
atf_add_test_case i15
|
||||
atf_add_test_case i16
|
||||
atf_add_test_case i17
|
||||
atf_add_test_case i18
|
||||
atf_add_test_case i19
|
||||
atf_add_test_case i20
|
||||
atf_add_test_case i21
|
||||
atf_add_test_case i22
|
||||
atf_add_test_case i23
|
||||
}
|
||||
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
# $NetBSD: t_logging.sh,v 1.2 2010/10/19 16:36:36 jmmv Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# (C)opyright 1993-1996 by Darren Reed.
|
||||
#
|
||||
# See the IPFILTER.LICENCE file for details on licencing.
|
||||
#
|
||||
|
||||
logtest()
|
||||
{
|
||||
h_copydata $1
|
||||
cp $(atf_get_srcdir)/expected/$1.b exp.b
|
||||
|
||||
case `uname -s` in
|
||||
OSF1)
|
||||
GMT=:
|
||||
;;
|
||||
*)
|
||||
GMT=GMT
|
||||
;;
|
||||
esac
|
||||
|
||||
{ while read rule; do
|
||||
echo $rule >>out
|
||||
atf_check -o ignore -x \
|
||||
"echo $rule | ipftest -br - -F $2 -i in -l logout"
|
||||
|
||||
atf_check -o save:save -x "TZ=$GMT ipmon -P /dev/null -f logout"
|
||||
cat save >>out
|
||||
echo "--------" >>out
|
||||
|
||||
atf_check -o save:save -x "TZ=$GMT ipmon -P /dev/null -bf logout"
|
||||
cat save >>out.b
|
||||
echo "--------" >>out.b
|
||||
done; } <reg
|
||||
|
||||
atf_check -o ignore ipftest -br reg -F $2 -i in -l logout
|
||||
|
||||
atf_check -o save:save -x "TZ=$GMT ipmon -P /dev/null -f logout"
|
||||
cat save >>out
|
||||
echo "--------" >>out
|
||||
|
||||
atf_check -o save:save -x "TZ=$GMT ipmon -P /dev/null -bf logout"
|
||||
cat save >>out.b
|
||||
echo "--------" >>out.b
|
||||
|
||||
diff -u exp out || atf_fail "results differ"
|
||||
diff -u exp.b out.b || atf_fail "results differ"
|
||||
}
|
||||
|
||||
test_case l1 logtest hex hex
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case l1
|
||||
}
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
# $NetBSD: t_nat_exec.sh,v 1.21 2014/12/01 19:46:29 martin Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# (C)opyright 1993-1996 by Darren Reed.
|
||||
#
|
||||
# See the IPFILTER.LICENCE file for details on licencing.
|
||||
#
|
||||
|
||||
nattest()
|
||||
{
|
||||
h_copydata $1
|
||||
infmt=$2
|
||||
outfmt=$3
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
args=$@
|
||||
|
||||
if [ $outfmt = hex ] ; then
|
||||
format="-xF $infmt"
|
||||
else
|
||||
format="-F $infmt"
|
||||
fi
|
||||
|
||||
format="$format"
|
||||
|
||||
test -f in && test -f reg || atf_fail "Test input file missing"
|
||||
|
||||
{ while read rule; do
|
||||
atf_check -o save:save -x \
|
||||
"echo \"$rule\" | ipftest $format -RDbN - -i in $args"
|
||||
cat save >>out
|
||||
echo "-------------------------------" >>out
|
||||
done; } <reg
|
||||
|
||||
diff -u exp out || atf_fail "results differ"
|
||||
}
|
||||
|
||||
test_case n1 nattest text text
|
||||
test_case n2 nattest text text
|
||||
test_case n3 nattest text text
|
||||
test_case n4 nattest text text
|
||||
test_case n5 nattest text text
|
||||
test_case n6 nattest text text
|
||||
test_case n7 nattest text text
|
||||
test_case n8 nattest hex hex -T update_ipid=0
|
||||
test_case n9 nattest hex hex -T update_ipid=0
|
||||
test_case n10 nattest hex hex -T update_ipid=0
|
||||
test_case n11 nattest text text
|
||||
failing_test_case n12 nattest "Known to be broken" hex hex -T update_ipid=0 -v
|
||||
test_case n13 nattest text text
|
||||
test_case n14 nattest text text
|
||||
test_case n15 nattest text text -T update_ipid=0
|
||||
test_case n16 nattest hex hex -D
|
||||
test_case n17 nattest hex hex -D
|
||||
test_case n100 nattest text text
|
||||
test_case n101 nattest text text
|
||||
test_case n102 nattest text text
|
||||
test_case n103 nattest text text
|
||||
test_case n104 nattest hex hex -T update_ipid=0
|
||||
test_case n105 nattest hex hex -T update_ipid=0
|
||||
test_case n106 nattest hex hex -T update_ipid=0
|
||||
test_case n200 nattest hex hex -T update_ipid=0
|
||||
test_case n1_6 nattest text text -6
|
||||
test_case n2_6 nattest text text -6
|
||||
#test_case n3_6 nattest text text -6
|
||||
test_case n4_6 nattest text text -6
|
||||
test_case n5_6 nattest text text -6
|
||||
test_case n6_6 nattest text text -6
|
||||
test_case n7_6 nattest text text -6
|
||||
failing_test_case_be n8_6 nattest "See PR kern/47665" hex hex -6
|
||||
failing_test_case_be n9_6 nattest "See PR kern/47665" hex hex -6
|
||||
test_case n11_6 nattest text text -6
|
||||
test_case n12_6 nattest hex hex -6
|
||||
test_case n15_6 nattest text text -6
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case n1
|
||||
atf_add_test_case n2
|
||||
atf_add_test_case n3
|
||||
atf_add_test_case n4
|
||||
atf_add_test_case n5
|
||||
atf_add_test_case n6
|
||||
atf_add_test_case n7
|
||||
atf_add_test_case n8
|
||||
atf_add_test_case n9
|
||||
atf_add_test_case n10
|
||||
atf_add_test_case n11
|
||||
atf_add_test_case n12
|
||||
atf_add_test_case n13
|
||||
atf_add_test_case n14
|
||||
atf_add_test_case n16
|
||||
atf_add_test_case n17
|
||||
atf_add_test_case n100
|
||||
atf_add_test_case n101
|
||||
atf_add_test_case n102
|
||||
atf_add_test_case n103
|
||||
atf_add_test_case n104
|
||||
atf_add_test_case n105
|
||||
atf_add_test_case n106
|
||||
atf_add_test_case n200
|
||||
|
||||
atf_add_test_case n1_6
|
||||
atf_add_test_case n2_6
|
||||
# atf_add_test_case n3_6
|
||||
atf_add_test_case n4_6
|
||||
atf_add_test_case n5_6
|
||||
atf_add_test_case n6_6
|
||||
atf_add_test_case n7_6
|
||||
atf_add_test_case n8_6
|
||||
atf_add_test_case n9_6
|
||||
atf_add_test_case n11_6
|
||||
atf_add_test_case n12_6
|
||||
atf_add_test_case n15_6
|
||||
}
|
||||
|
|
@ -1,120 +0,0 @@
|
|||
# $NetBSD: t_nat_ipf_exec.sh,v 1.7 2012/07/07 23:29:44 pgoyette Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# (C)opyright 1993-1996 by Darren Reed.
|
||||
#
|
||||
# See the IPFILTER.LICENCE file for details on licencing.
|
||||
#
|
||||
|
||||
natipftest()
|
||||
{
|
||||
h_copydata $1
|
||||
cp $(atf_get_srcdir)/regress/$1.nat nat
|
||||
cp $(atf_get_srcdir)/regress/$1.ipf ipf
|
||||
many=$2
|
||||
infmt=$3
|
||||
outfmt=$4
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
shift
|
||||
args=$@
|
||||
|
||||
if [ $outfmt = hex ] ; then
|
||||
format="-xF $infmt"
|
||||
else
|
||||
format="-F $infmt"
|
||||
fi
|
||||
|
||||
case $many in
|
||||
single)
|
||||
{ while read rule; do
|
||||
atf_check -o save:save -x "echo \"$rule\" | \
|
||||
ipftest -R $format -b -r ipf -N - -i in $args"
|
||||
cat save >>out
|
||||
echo "-------------------------------" >>out
|
||||
done; } <nat
|
||||
;;
|
||||
multi)
|
||||
atf_check -o save:out ipftest -R $args \
|
||||
$format -b -r ipf -N nat -i in
|
||||
echo "-------------------------------" >>out
|
||||
;;
|
||||
esac
|
||||
|
||||
diff -u exp out || atf_fail "results differ"
|
||||
}
|
||||
|
||||
test_case ni1 natipftest multi hex hex -T update_ipid=1
|
||||
test_case ni2 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni3 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni4 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni5 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni6 natipftest multi hex text -T update_ipid=1 -D
|
||||
test_case ni7 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni8 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni9 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni10 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni11 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni12 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni13 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni14 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni15 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni16 natipftest single hex hex -T update_ipid=1
|
||||
test_case ni17 natipftest multi text text
|
||||
test_case ni18 natipftest multi text text
|
||||
test_case ni19 natipftest single hex hex -T update_ipid=0
|
||||
test_case ni20 natipftest single hex hex -T update_ipid=0 -D
|
||||
test_case ni21 natipftest multi text text
|
||||
test_case ni23 natipftest multi text text -D
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case ni1
|
||||
atf_add_test_case ni2
|
||||
atf_add_test_case ni3
|
||||
atf_add_test_case ni4
|
||||
atf_add_test_case ni5
|
||||
atf_add_test_case ni6
|
||||
atf_add_test_case ni7
|
||||
atf_add_test_case ni8
|
||||
atf_add_test_case ni9
|
||||
atf_add_test_case ni10
|
||||
atf_add_test_case ni11
|
||||
atf_add_test_case ni12
|
||||
atf_add_test_case ni13
|
||||
atf_add_test_case ni14
|
||||
atf_add_test_case ni15
|
||||
atf_add_test_case ni16
|
||||
atf_add_test_case ni17
|
||||
atf_add_test_case ni18
|
||||
atf_add_test_case ni19
|
||||
atf_add_test_case ni20
|
||||
atf_add_test_case ni21
|
||||
atf_add_test_case ni23
|
||||
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
# $NetBSD: t_nat_parse.sh,v 1.8 2014/06/29 09:26:32 darrenr Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# (C)opyright 1993-1996 by Darren Reed.
|
||||
#
|
||||
# See the IPFILTER.LICENCE file for details on licencing.
|
||||
#
|
||||
|
||||
intest()
|
||||
{
|
||||
h_copydata $1
|
||||
|
||||
atf_check -o file:exp -e ignore ipnat -Rnvf reg
|
||||
}
|
||||
|
||||
test_case in1 intest text text
|
||||
test_case in2 intest text text
|
||||
test_case in3 intest text text
|
||||
test_case in4 intest text text
|
||||
test_case in5 intest text text
|
||||
test_case in6 intest text text
|
||||
test_case in7 intest text text
|
||||
test_case in100 intest text text
|
||||
test_case in101 intest text text
|
||||
test_case in102 intest text text
|
||||
test_case in1_6 intest text text
|
||||
test_case in2_6 intest text text
|
||||
test_case in3_6 intest text text
|
||||
test_case in4_6 intest text text
|
||||
test_case in5_6 intest text text
|
||||
test_case in6_6 intest text text
|
||||
test_case in8_6 intest text text
|
||||
test_case in100_6 intest text text
|
||||
test_case in101_6 intest text text
|
||||
test_case in102_6 intest text text
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case in1
|
||||
atf_add_test_case in2
|
||||
atf_add_test_case in3
|
||||
atf_add_test_case in4
|
||||
atf_add_test_case in5
|
||||
atf_add_test_case in6
|
||||
atf_add_test_case in7
|
||||
atf_add_test_case in100
|
||||
atf_add_test_case in101
|
||||
atf_add_test_case in102
|
||||
atf_add_test_case in1_6
|
||||
atf_add_test_case in2_6
|
||||
atf_add_test_case in3_6
|
||||
atf_add_test_case in4_6
|
||||
atf_add_test_case in5_6
|
||||
atf_add_test_case in6_6
|
||||
atf_add_test_case in8_6
|
||||
atf_add_test_case in100_6
|
||||
atf_add_test_case in101_6
|
||||
atf_add_test_case in102_6
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
# $NetBSD: t_pools.sh,v 1.8 2012/12/03 23:39:30 pgoyette Exp $
|
||||
#
|
||||
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# (C)opyright 1993-1996 by Darren Reed.
|
||||
#
|
||||
# See the IPFILTER.LICENCE file for details on licencing.
|
||||
#
|
||||
|
||||
iptest()
|
||||
{
|
||||
h_copydata $1
|
||||
mkdir input
|
||||
cp $(atf_get_srcdir)/input/ip2.data input/
|
||||
|
||||
atf_check -o file:exp -e ignore ippool -f reg -nRv
|
||||
}
|
||||
|
||||
ptest()
|
||||
{
|
||||
h_copydata $1
|
||||
cp $(atf_get_srcdir)/regress/$1.pool pool 2>/dev/null
|
||||
if [ -f $(atf_get_srcdir)/regress/$1.nat ] ; then
|
||||
cp $(atf_get_srcdir)/regress/$1.nat nat
|
||||
else
|
||||
cp $(atf_get_srcdir)/regress/$1.ipf ipf
|
||||
fi
|
||||
|
||||
if [ -f pool ] ; then
|
||||
if [ -f nat ] ; then
|
||||
atf_check -o save:out ipftest -RD -b -P pool -N nat -i in
|
||||
else
|
||||
atf_check -o save:out ipftest -RD -b -P pool -r ipf -i in
|
||||
fi
|
||||
else
|
||||
atf_check -o save:out ipftest -RD -b -r ipf -i in
|
||||
fi
|
||||
|
||||
echo "-------------------------------" >>out
|
||||
|
||||
}
|
||||
|
||||
test_case f28 ptest text text
|
||||
test_case f29 ptest text text
|
||||
test_case p1 ptest text text
|
||||
test_case p2 ptest text text
|
||||
test_case p3 ptest text text
|
||||
test_case p4 ptest text text
|
||||
test_case p5 ptest text text
|
||||
test_case p6 ptest text text
|
||||
test_case p7 ptest text text
|
||||
test_case p9 ptest text text
|
||||
test_case p10 ptest text text
|
||||
test_case p11 ptest text text
|
||||
test_case p12 ptest text text
|
||||
test_case p13 ptest text text
|
||||
test_case ip1 iptest text text
|
||||
test_case ip2 iptest text text
|
||||
test_case ip3 iptest text text
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case f28
|
||||
atf_add_test_case f29
|
||||
atf_add_test_case p1
|
||||
atf_add_test_case p2
|
||||
atf_add_test_case p3
|
||||
atf_add_test_case p4
|
||||
atf_add_test_case p5
|
||||
atf_add_test_case p6
|
||||
atf_add_test_case p7
|
||||
atf_add_test_case p9
|
||||
atf_add_test_case p10
|
||||
atf_add_test_case p11
|
||||
atf_add_test_case p12
|
||||
atf_add_test_case p13
|
||||
atf_add_test_case ip1
|
||||
atf_add_test_case ip2
|
||||
atf_add_test_case ip3
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.24 2015/06/22 00:05:23 matt Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
#__MINIX:
|
||||
# libbluetooth
|
||||
# libobjc libposix libppath libpthread
|
||||
# librt libtre semaphore
|
||||
TESTS_SUBDIRS= csu libc libcrypt libcurses libevent libexecinfo \
|
||||
libm libprop \
|
||||
libutil
|
||||
|
||||
.if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE)
|
||||
TESTS_SUBDIRS+= librumpclient librumphijack
|
||||
.endif
|
||||
|
||||
.if ${MKCRYPTO} != "no"
|
||||
TESTS_SUBDIRS+= libdes
|
||||
.endif
|
||||
|
||||
.if ${MKKYUA} != "no"
|
||||
# These tests come from external/bsd/lutok/tests/lib/liblutok. Ensure they
|
||||
# get registered in the Atffile only when installed.
|
||||
ATFFILE_EXTRA_TPS= liblutok
|
||||
.endif
|
||||
|
||||
.if (${MKSKEY} != "no")
|
||||
TESTS_SUBDIRS+= libskey
|
||||
.endif
|
||||
|
||||
.if ${MKSLJIT} != "no"
|
||||
TESTS_SUBDIRS+= libsljit
|
||||
TESTS_SUBDIRS+= libbpfjit
|
||||
.endif
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.4 2011/01/02 09:33:45 skrll Exp $
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.if defined(__MINIX)
|
||||
USE_BITCODE:= no # LSC: can't use bitcode for this.
|
||||
.endif # defined(__MINIX)
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/csu
|
||||
TESTS_SH= t_crt0
|
||||
TESTS_SUBDIRS=
|
||||
SUBDIR+= dso
|
||||
|
||||
.include "Makefile.check_stack"
|
||||
|
||||
CPPFLAGS+= ${CPPFLAGS_CHECK_STACK}
|
||||
|
||||
BINDIR= ${TESTSDIR}
|
||||
PROG_CXX= h_initfini1 h_initfini2 h_initfini3
|
||||
SRCS.h_initfini1= h_initfini1.cxx h_initfini_common.cxx \
|
||||
${SRCS_CHECK_STACK}
|
||||
SRCS.h_initfini2= h_initfini1.cxx h_initfini_common.cxx \
|
||||
${SRCS_CHECK_STACK}
|
||||
LDADD.h_initfini2+= -static
|
||||
SRCS.h_initfini3= h_initfini3.cxx h_initfini_common.cxx \
|
||||
${SRCS_CHECK_STACK}
|
||||
LDADD.h_initfini3+= -Wl,-rpath,${TESTSDIR}
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
# $NetBSD: Makefile.check_stack,v 1.2 2013/12/11 17:31:55 matt Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.if exists(${.PARSEDIR}/arch/${MACHINE_ARCH})
|
||||
CSU_ARCHDIR= ${.PARSEDIR}/arch/${MACHINE_ARCH}
|
||||
.PATH: ${CSU_ARCHDIR}
|
||||
.elif exists(${.PARSEDIR}/arch/${MACHINE_CPU})
|
||||
CSU_ARCHDIR= ${.PARSEDIR}/arch/${MACHINE_CPU}
|
||||
.PATH: ${CSU_ARCHDIR}
|
||||
.endif
|
||||
.if exists(${CSU_ARCHDIR}/h_initfini_align.S)
|
||||
SRCS_CHECK_STACK= h_initfini_align.S
|
||||
CPPFLAGS_CHECK_STACK+= -DCHECK_STACK_ALIGNMENT
|
||||
.endif
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:55 matt Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:55 matt Exp $")
|
||||
|
||||
/*
|
||||
* LINTSTUB: bool check_stack_alignment(void);
|
||||
*/
|
||||
|
||||
LEAF_NOPROFILE(check_stack_alignment, 0)
|
||||
ldiq v0, 0
|
||||
and sp, 7, t0
|
||||
cmoveq t0, 1, v0
|
||||
ret
|
||||
END(check_stack_alignment)
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $")
|
||||
|
||||
/*
|
||||
* LINTSTUB: bool check_stack_alignment(void);
|
||||
*/
|
||||
|
||||
ARM_ENTRY(check_stack_alignment)
|
||||
#ifdef __ARM_EABI__
|
||||
tst sp, #7
|
||||
#else
|
||||
tst sp, #3
|
||||
#endif
|
||||
movne r0, #0
|
||||
moveq r0, #1
|
||||
RET
|
||||
END(check_stack_alignment)
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.1 2013/11/15 11:48:30 skrll Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/11/15 11:48:30 skrll Exp $")
|
||||
|
||||
LEAF_ENTRY(check_stack_alignment)
|
||||
extru %sp,31,6,%ret0
|
||||
comiclr,<> 0, %ret0, %ret0
|
||||
ldi 1,%ret0
|
||||
bv,n %r0(%r2)
|
||||
EXIT(check_stack_alignment)
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.2 2010/12/12 18:21:21 joerg Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.2 2010/12/12 18:21:21 joerg Exp $")
|
||||
|
||||
_ENTRY(check_stack_alignment)
|
||||
movl %esp, %eax
|
||||
andl $3, %eax
|
||||
setz %al
|
||||
movzbl %al, %eax
|
||||
ret
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.2 2014/03/16 09:27:04 cherry Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.2 2014/03/16 09:27:04 cherry Exp $")
|
||||
|
||||
ENTRY(check_stack_alignment, 0)
|
||||
.prologue
|
||||
.regstk 0, 2, 0, 0
|
||||
|
||||
alloc loc0 = ar.pfs, 0, 2, 0, 0
|
||||
|
||||
.body
|
||||
mov ret0 = 1
|
||||
;;
|
||||
|
||||
/* ar.bsp has an 8-byte alignment requirement */
|
||||
mov loc1 = ar.bsp
|
||||
;;
|
||||
|
||||
and loc1 = 7, loc1
|
||||
;;
|
||||
|
||||
cmp.eq p1, p0 = 0, loc1
|
||||
(p0) mov ret0 = 0
|
||||
;;
|
||||
|
||||
/* sp has a 16-byte alignment requirement */
|
||||
(p1) mov loc1 = sp
|
||||
;;
|
||||
(p1) and loc1 = 15, loc1
|
||||
;;
|
||||
|
||||
(p1) cmp.eq p1, p0 = 0, loc1
|
||||
(p0) mov ret0 = 0
|
||||
|
||||
br.ret.sptk.few rp
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $")
|
||||
|
||||
/*
|
||||
* LINTSTUB: bool check_stack_alignment(void);
|
||||
*/
|
||||
|
||||
LEAF_NOPROFILE(check_stack_alignment)
|
||||
#ifdef __mips_o32
|
||||
andi v1,sp,3
|
||||
#else
|
||||
andi v1,sp,7
|
||||
#endif
|
||||
sltiu v0,v1,1
|
||||
jr ra
|
||||
END(check_stack_alignment)
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $")
|
||||
|
||||
/*
|
||||
* LINTSTUB: bool check_stack_alignment(void);
|
||||
*/
|
||||
|
||||
_ENTRY(check_stack_alignment)
|
||||
li %r3,0
|
||||
andis. %r0,%r1,15
|
||||
bnelr %cr0
|
||||
li %r3,1
|
||||
blr
|
||||
END(check_stack_alignment)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.1 2013/12/12 11:22:26 martin Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/12 11:22:26 martin Exp $")
|
||||
|
||||
_ENTRY(check_stack_alignment)
|
||||
and %sp, 7, %o1
|
||||
retl
|
||||
not %o1, %o0
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.1 2013/11/15 20:00:20 martin Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/11/15 20:00:20 martin Exp $")
|
||||
|
||||
_ENTRY(check_stack_alignment)
|
||||
add %sp, BIAS, %o1
|
||||
and %o1, 15, %o2
|
||||
retl
|
||||
not %o2, %o0
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.1 2013/12/11 17:31:56 matt Exp $")
|
||||
|
||||
/*
|
||||
* LINTSTUB: bool check_stack_alignment(void);
|
||||
*/
|
||||
|
||||
_ENTRY(check_stack_alignment, 0)
|
||||
clrl %r0
|
||||
bitl $3,%sp
|
||||
bneq 1f
|
||||
incl %r0
|
||||
1: ret
|
||||
END(check_stack_alignment)
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
/* $NetBSD: h_initfini_align.S,v 1.2 2010/12/12 18:21:21 joerg Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: h_initfini_align.S,v 1.2 2010/12/12 18:21:21 joerg Exp $")
|
||||
|
||||
_ENTRY(check_stack_alignment)
|
||||
movl %esp, %eax
|
||||
andl $15, %eax
|
||||
subl $8, %eax
|
||||
sete %al
|
||||
movzbl %al, %eax
|
||||
ret
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.4 2010/11/30 18:38:53 joerg Exp $
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.include "${.PARSEDIR}/../Makefile.check_stack"
|
||||
|
||||
LIB= h_initfini3_dso
|
||||
SRCS= h_initfini3_dso.cxx ${SRCS_CHECK_STACK}
|
||||
CPPFLAGS+= ${CPPFLAGS_CHECK_STACK}
|
||||
|
||||
LIBDIR= ${TESTSBASE}/lib/csu
|
||||
SHLIBDIR= ${TESTSBASE}/lib/csu
|
||||
SHLIB_MAJOR= 1
|
||||
|
||||
LIBISMODULE= yes
|
||||
LIBISCXX= yes
|
||||
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
# $NetBSD: t_crt0.sh,v 1.4 2011/12/11 14:57:07 joerg Exp $
|
||||
#
|
||||
# Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
atf_test_case initfini1
|
||||
initfini1_head()
|
||||
{
|
||||
atf_set "descr" "Checks support for init/fini sections"
|
||||
}
|
||||
initfini1_body()
|
||||
{
|
||||
cat >expout <<EOF
|
||||
constructor executed
|
||||
main executed
|
||||
destructor executed
|
||||
EOF
|
||||
|
||||
atf_check -o file:expout "$(atf_get_srcdir)/h_initfini1"
|
||||
}
|
||||
|
||||
atf_test_case initfini2
|
||||
initfini2_head()
|
||||
{
|
||||
atf_set "descr" "Checks support for init/fini sections in static binaries"
|
||||
}
|
||||
initfini2_body()
|
||||
{
|
||||
cat >expout <<EOF
|
||||
constructor executed
|
||||
main executed
|
||||
destructor executed
|
||||
EOF
|
||||
|
||||
atf_check -o file:expout "$(atf_get_srcdir)/h_initfini2"
|
||||
}
|
||||
|
||||
atf_test_case initfini3
|
||||
initfini3_head()
|
||||
{
|
||||
atf_set "descr" "Checks support for init/fini sections in dlopen"
|
||||
}
|
||||
initfini3_body()
|
||||
{
|
||||
cat >expout <<EOF
|
||||
constructor executed
|
||||
main started
|
||||
constructor2 executed
|
||||
main after dlopen
|
||||
destructor2 executed
|
||||
main terminated
|
||||
destructor executed
|
||||
EOF
|
||||
|
||||
atf_check -o file:expout "$(atf_get_srcdir)/h_initfini3"
|
||||
}
|
||||
|
||||
atf_test_case initfini4
|
||||
initfini4_head()
|
||||
{
|
||||
atf_set "descr" "Checks support for init/fini sections in LD_PRELOAD"
|
||||
}
|
||||
initfini4_body()
|
||||
{
|
||||
cat >expout <<EOF
|
||||
constructor2 executed
|
||||
constructor executed
|
||||
main executed
|
||||
destructor executed
|
||||
destructor2 executed
|
||||
EOF
|
||||
|
||||
atf_check -o file:expout -x "env LD_PRELOAD=$(atf_get_srcdir)/h_initfini3_dso.so $(atf_get_srcdir)/h_initfini1"
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case initfini1
|
||||
atf_add_test_case initfini2
|
||||
atf_add_test_case initfini3
|
||||
atf_add_test_case initfini4
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
# $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>
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
/* $NetBSD: t_bluetooth.c,v 1.2 2011/04/07 08:29:50 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();
|
||||
}
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
/* $NetBSD: t_sdp_data.c,v 1.2 2011/04/07 08:29:50 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();
|
||||
}
|
||||
|
|
@ -1,643 +0,0 @@
|
|||
/* $NetBSD: t_sdp_get.c,v 1.2 2011/04/07 08:29:50 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");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_get_data, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x09, 0x00, 0x00, // uint16 0x0000
|
||||
0x35, 0x05, // seq8(5)
|
||||
0x19, 0x00, 0x00, // uuid16 0x0000
|
||||
0x08, 0x00, // uint8 0x00
|
||||
0x36, 0x00, 0x01, // seq16(1)
|
||||
0x19, // uint16 /* invalid */
|
||||
0x25, 0x04, 0x54, 0x45, // str8(4) "TEST"
|
||||
0x53, 0x54,
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t value, seq;
|
||||
|
||||
/*
|
||||
* sdp_get_data constructs a new sdp_data_t containing
|
||||
* the next data element, advancing test if successful
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_data(&test, &value));
|
||||
ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UINT16);
|
||||
ATF_CHECK_EQ(sdp_data_size(&value), 3);
|
||||
|
||||
ATF_REQUIRE(sdp_get_data(&test, &value));
|
||||
ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_SEQ8);
|
||||
ATF_CHECK_EQ(sdp_data_size(&value), 7);
|
||||
|
||||
ATF_REQUIRE(sdp_get_data(&test, &value));
|
||||
ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_SEQ16);
|
||||
ATF_CHECK_EQ(sdp_data_size(&value), 4);
|
||||
ATF_REQUIRE_EQ(sdp_get_seq(&value, &seq), true);
|
||||
ATF_REQUIRE_EQ(sdp_get_data(&seq, &value), false); /* invalid */
|
||||
|
||||
ATF_REQUIRE(sdp_get_data(&test, &value));
|
||||
ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_STR8);
|
||||
ATF_CHECK_EQ(sdp_data_size(&value), 6);
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_get_attr);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_get_attr, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_get_attr results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_get_attr, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x09, 0x00, 0x00, // uint16 0x0000
|
||||
0x35, 0x05, // seq8(5)
|
||||
0x19, 0x00, 0x00, // uuid16 0x0000
|
||||
0x08, 0x00, // uint8 0x00
|
||||
0x08, 0x00, // uint8 0x00
|
||||
0x09, 0x00, 0x01, // uint16 0x0001
|
||||
0x19, 0x12, 0x34, // uuid16 0x1234
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t value;
|
||||
uint16_t attr;
|
||||
|
||||
/*
|
||||
* sdp_get_attr expects a UINT16 followed by any data item
|
||||
* and advances test if successful
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_attr(&test, &attr, &value));
|
||||
ATF_CHECK_EQ(attr, 0x0000);
|
||||
ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_SEQ8);
|
||||
ATF_CHECK_EQ(sdp_data_size(&value), 7);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_attr(&test, &attr, &value), false);
|
||||
ATF_REQUIRE(sdp_get_data(&test, &value));
|
||||
ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UINT8);
|
||||
ATF_CHECK_EQ(sdp_data_size(&value), 2);
|
||||
|
||||
ATF_REQUIRE(sdp_get_attr(&test, &attr, &value));
|
||||
ATF_CHECK_EQ(attr, 0x0001);
|
||||
ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_UUID16);
|
||||
ATF_CHECK_EQ(sdp_data_size(&value), 3);
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_get_uuid);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_get_uuid, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_get_uuid results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_get_uuid, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x19, 0x12, 0x34, // uuid16 0x1234
|
||||
0x1a, 0x11, 0x22, 0x33, // uuid32 0x11223344
|
||||
0x44,
|
||||
0x00, // nil
|
||||
0x1c, // uuid128 0x00112233-4444--5555-6666-778899aabbcc
|
||||
0x00, 0x11, 0x22, 0x33,
|
||||
0x44, 0x44, 0x55, 0x55,
|
||||
0x66, 0x66, 0x77, 0x88,
|
||||
0x99, 0xaa, 0xbb, 0xcc,
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
uuid_t u16 = {
|
||||
0x00001234,
|
||||
0x0000,
|
||||
0x1000,
|
||||
0x80,
|
||||
0x00,
|
||||
{ 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb }
|
||||
};
|
||||
uuid_t u32 = {
|
||||
0x11223344,
|
||||
0x0000,
|
||||
0x1000,
|
||||
0x80,
|
||||
0x00,
|
||||
{ 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb }
|
||||
};
|
||||
uuid_t u128 = {
|
||||
0x00112233,
|
||||
0x4444,
|
||||
0x5555,
|
||||
0x66,
|
||||
0x66,
|
||||
{ 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc }
|
||||
};
|
||||
sdp_data_t nil;
|
||||
uuid_t value;
|
||||
|
||||
/*
|
||||
* sdp_get_uuid expects any UUID type returns the full uuid
|
||||
* advancing test if successful
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_uuid(&test, &value));
|
||||
ATF_CHECK(uuid_equal(&value, &u16, NULL));
|
||||
|
||||
ATF_REQUIRE(sdp_get_uuid(&test, &value));
|
||||
ATF_CHECK(uuid_equal(&value, &u32, NULL));
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_uuid(&test, &value), false); /* not uuid */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
|
||||
|
||||
ATF_REQUIRE(sdp_get_uuid(&test, &value));
|
||||
ATF_CHECK(uuid_equal(&value, &u128, NULL));
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_get_bool);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_get_bool, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_get_bool results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_get_bool, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x28, 0x00, // bool false
|
||||
0x00, // nil
|
||||
0x28, 0x01, // bool true
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t nil;
|
||||
bool value;
|
||||
|
||||
/*
|
||||
* sdp_get_bool expects a BOOL type
|
||||
* advancing test if successful
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_bool(&test, &value));
|
||||
ATF_CHECK_EQ(value, false);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_bool(&test, &value), false); /* not bool */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
|
||||
|
||||
ATF_REQUIRE(sdp_get_bool(&test, &value));
|
||||
ATF_CHECK_EQ(value, true);
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_get_uint);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_get_uint, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_get_uint results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_get_uint, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x08, 0x00, // uint8 0x00
|
||||
0x08, 0xff, // uint8 0xff
|
||||
0x09, 0x01, 0x02, // uint16 0x0102
|
||||
0x09, 0xff, 0xff, // uint16 0xffff
|
||||
0x00, // nil
|
||||
0x0a, 0x01, 0x02, 0x03, // uint32 0x01020304
|
||||
0x04,
|
||||
0x0a, 0xff, 0xff, 0xff, // uint32 0xffffffff
|
||||
0xff,
|
||||
0x0b, 0x01, 0x02, 0x03, // uint64 0x0102030405060708
|
||||
0x04, 0x05, 0x06, 0x07,
|
||||
0x08,
|
||||
0x0b, 0xff, 0xff, 0xff, // uint64 0xffffffffffffffff
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
0xff,
|
||||
0x0c, 0x00, 0x00, 0x00, // uint128 0x00000000000000000000000000000000
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x0c, 0x00, 0x00, 0x00, // uint128 0x00000000000000010000000000000000
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x0c, 0x00, 0x00, 0x00, // uint128 0x0000000000000000ffffffffffffffff
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
0xff,
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t nil;
|
||||
uintmax_t value;
|
||||
|
||||
/*
|
||||
* sdp_get_uint expects any UINT type, advancing test if successful
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_uint(&test, &value));
|
||||
ATF_CHECK_EQ(value, 0x00);
|
||||
|
||||
ATF_REQUIRE(sdp_get_uint(&test, &value));
|
||||
ATF_CHECK_EQ(value, UINT8_MAX);
|
||||
|
||||
ATF_REQUIRE(sdp_get_uint(&test, &value));
|
||||
ATF_CHECK_EQ(value, 0x0102);
|
||||
|
||||
ATF_REQUIRE(sdp_get_uint(&test, &value));
|
||||
ATF_CHECK_EQ(value, UINT16_MAX);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_uint(&test, &value), false); /* not uint */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
|
||||
|
||||
ATF_REQUIRE(sdp_get_uint(&test, &value));
|
||||
ATF_CHECK_EQ(value, 0x01020304);
|
||||
|
||||
ATF_REQUIRE(sdp_get_uint(&test, &value));
|
||||
ATF_CHECK_EQ(value, UINT32_MAX);
|
||||
|
||||
ATF_REQUIRE(sdp_get_uint(&test, &value));
|
||||
ATF_CHECK_EQ(value, 0x0102030405060708);
|
||||
|
||||
ATF_REQUIRE(sdp_get_uint(&test, &value));
|
||||
ATF_CHECK_EQ(value, UINT64_MAX);
|
||||
|
||||
/*
|
||||
* expected failure is that we cannot decode UINT128 values larger than UINT64
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_uint(&test, &value));
|
||||
ATF_CHECK_EQ(value, 0x00000000000000000000000000000000);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_uint(&test, &value), false); /* overflow */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_UINT128);
|
||||
|
||||
ATF_REQUIRE(sdp_get_uint(&test, &value));
|
||||
ATF_CHECK_EQ(value, UINT64_MAX);
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_get_int);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_get_int, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_get_int results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_get_int, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x10, 0x00, // int8 0x00
|
||||
0x10, 0x7f, // int8 0x7f
|
||||
0x10, 0x80, // int8 0x80
|
||||
0x11, 0x01, 0x02, // int16 0x0102
|
||||
0x11, 0x7f, 0xff, // int16 0x7fff
|
||||
0x11, 0x80, 0x00, // int16 0x8000
|
||||
0x00, // nil
|
||||
0x12, 0x01, 0x02, 0x03, // int32 0x01020304
|
||||
0x04,
|
||||
0x12, 0x7f, 0xff, 0xff, // int32 0x7fffffff
|
||||
0xff,
|
||||
0x12, 0x80, 0x00, 0x00, // int32 0x80000000
|
||||
0x00,
|
||||
0x13, 0x01, 0x02, 0x03, // int64 0x0102030405060708
|
||||
0x04, 0x05, 0x06, 0x07,
|
||||
0x08,
|
||||
0x13, 0x7f, 0xff, 0xff, // int64 0x7fffffffffffffff
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
0xff,
|
||||
0x13, 0x80, 0x00, 0x00, // int64 0x8000000000000000
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x14, 0x00, 0x00, 0x00, // int128 0x00000000000000000000000000000000
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x14, 0x00, 0x00, 0x00, // int128 0x00000000000000007fffffffffffffff
|
||||
0x00, 0x00, 0x00, 0x00, // (INT64_MAX)
|
||||
0x00, 0x7f, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
0xff,
|
||||
0x14, 0x00, 0x00, 0x00, // int128 0x00000000000000008000000000000000
|
||||
0x00, 0x00, 0x00, 0x00, // (INT64_MAX + 1)
|
||||
0x00, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x14, 0xff, 0xff, 0xff, // int128 0xffffffffffffffff8000000000000000
|
||||
0xff, 0xff, 0xff, 0xff, // (INT64_MIN)
|
||||
0xff, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x14, 0xff, 0xff, 0xff, // int128 0xffffffffffffffff7fffffffffffffff
|
||||
0xff, 0xff, 0xff, 0xff, // (INT64_MIN - 1)
|
||||
0xff, 0x7f, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
0xff,
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t nil;
|
||||
intmax_t value;
|
||||
|
||||
/*
|
||||
* sdp_get_int expects any INT type, advancing test if successful
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, 0);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, INT8_MAX);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, INT8_MIN);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, 0x0102);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, INT16_MAX);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, INT16_MIN);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_int(&test, &value), false); /* not int */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, 0x01020304);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, INT32_MAX);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, INT32_MIN);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, 0x0102030405060708);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, INT64_MAX);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, INT64_MIN);
|
||||
|
||||
/*
|
||||
* expected failure is that we cannot decode INT128 values larger than INT64
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, 0);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, INT64_MAX);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_int(&test, &value), false); /* overflow */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_INT128);
|
||||
|
||||
ATF_REQUIRE(sdp_get_int(&test, &value));
|
||||
ATF_CHECK_EQ(value, INT64_MIN);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_int(&test, &value), false); /* underflow */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_INT128);
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_get_seq);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_get_seq, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_get_seq results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_get_seq, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x35, 0x00, // seq8(0)
|
||||
0x00, // nil
|
||||
0x36, 0x00, 0x00, // seq16(0)
|
||||
0x37, 0x00, 0x00, 0x00, // seq32(0)
|
||||
0x00,
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t value;
|
||||
|
||||
/*
|
||||
* sdp_get_seq expects a SEQ type
|
||||
* advancing test if successful
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_seq(&test, &value));
|
||||
ATF_CHECK_EQ(value.next, value.end);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_seq(&test, &value), false); /* not seq */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &value)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_NIL);
|
||||
|
||||
ATF_REQUIRE(sdp_get_seq(&test, &value));
|
||||
ATF_CHECK_EQ(value.next, value.end);
|
||||
|
||||
ATF_REQUIRE(sdp_get_seq(&test, &value));
|
||||
ATF_CHECK_EQ(value.next, value.end);
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_get_alt);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_get_alt, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_get_alt results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_get_alt, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x3d, 0x00, // alt8(0)
|
||||
0x00, // nil
|
||||
0x3e, 0x00, 0x00, // alt16(0)
|
||||
0x3f, 0x00, 0x00, 0x00, // alt32(0)
|
||||
0x00,
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t value;
|
||||
|
||||
/*
|
||||
* sdp_get_alt expects a ALT type
|
||||
* advancing test if successful
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_alt(&test, &value));
|
||||
ATF_CHECK_EQ(value.next, value.end);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_alt(&test, &value), false); /* not alt */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &value)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&value), SDP_DATA_NIL);
|
||||
|
||||
ATF_REQUIRE(sdp_get_alt(&test, &value));
|
||||
ATF_CHECK_EQ(value.next, value.end);
|
||||
|
||||
ATF_REQUIRE(sdp_get_alt(&test, &value));
|
||||
ATF_CHECK_EQ(value.next, value.end);
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_get_str);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_get_str, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_get_str results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_get_str, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x25, 0x04, 0x53, 0x54, // str8(4) "STR8"
|
||||
0x52, 0x38,
|
||||
0x00, // nil
|
||||
0x26, 0x00, 0x05, 0x53, // str16(5) "STR16"
|
||||
0x54, 0x52, 0x31, 0x36,
|
||||
0x27, 0x00, 0x00, 0x00, // str32(5) "STR32"
|
||||
0x05, 0x53, 0x54, 0x52,
|
||||
0x33, 0x32,
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t nil;
|
||||
char *str;
|
||||
size_t len;
|
||||
|
||||
/*
|
||||
* sdp_get_str expects a STR type
|
||||
* advancing test if successful
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_str(&test, &str, &len));
|
||||
ATF_CHECK(len == 4 && strncmp(str, "STR8", 4) == 0);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_str(&test, &str, &len), false); /* not str */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
|
||||
|
||||
ATF_REQUIRE(sdp_get_str(&test, &str, &len));
|
||||
ATF_CHECK(len == 5 && strncmp(str, "STR16", 5) == 0);
|
||||
|
||||
ATF_REQUIRE(sdp_get_str(&test, &str, &len));
|
||||
ATF_CHECK(len == 5 && strncmp(str, "STR32", 5) == 0);
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_get_url);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_get_url, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_get_url results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_get_url, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x45, 0x04, 0x55, 0x52, // url8(4) "URL8"
|
||||
0x4c, 0x38,
|
||||
0x00, // nil
|
||||
0x46, 0x00, 0x05, 0x55, // url16(5) "URL16"
|
||||
0x52, 0x4c, 0x31, 0x36,
|
||||
0x47, 0x00, 0x00, 0x00, // url32(5) "URL32"
|
||||
0x05, 0x55, 0x52, 0x4c,
|
||||
0x33, 0x32,
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t nil;
|
||||
char *url;
|
||||
size_t len;
|
||||
|
||||
/*
|
||||
* sdp_get_url expects a URL type
|
||||
* advancing test if successful
|
||||
*/
|
||||
ATF_REQUIRE(sdp_get_url(&test, &url, &len));
|
||||
ATF_CHECK(len == 4 && strncmp(url, "URL8", 4) == 0);
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_get_url(&test, &url, &len), false); /* not url */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
|
||||
|
||||
ATF_REQUIRE(sdp_get_url(&test, &url, &len));
|
||||
ATF_CHECK(len == 5 && strncmp(url, "URL16", 5) == 0);
|
||||
|
||||
ATF_REQUIRE(sdp_get_url(&test, &url, &len));
|
||||
ATF_CHECK(len == 5 && strncmp(url, "URL32", 5) == 0);
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
ATF_TP_ADD_TC(tp, check_sdp_get_data);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_get_attr);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_get_uuid);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_get_bool);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_get_uint);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_get_int);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_get_seq);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_get_alt);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_get_str);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_get_url);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
/* $NetBSD: t_sdp_match.c,v 1.2 2011/04/07 08:29:50 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_match_uuid16);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_match_uuid16, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_match_uuid16 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_match_uuid16, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x19, 0x11, 0x11, // uuid16 0x1111
|
||||
0x00, // nil
|
||||
0x19, 0x12, 0x34, // uuid16 0x1234
|
||||
0x1a, 0x00, 0x00, 0x34, // uuid32 0x00003456
|
||||
0x56,
|
||||
0x1c, 0x00, 0x00, 0x43, // uuid128 00004321-0000-1000-8000-00805f9b34fb
|
||||
0x21, 0x00, 0x00, 0x10,
|
||||
0x00, 0x80, 0x00, 0x00,
|
||||
0x80, 0x5f, 0x9b, 0x34,
|
||||
0xfb,
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t nil;
|
||||
|
||||
/*
|
||||
* sdp_match_uuid16 advances if the UUID matches the 16-bit short alias given
|
||||
*/
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_match_uuid16(&test, 0x1100), false); /* mismatch */
|
||||
ATF_REQUIRE(sdp_match_uuid16(&test, 0x1111));
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_match_uuid16(&test, 0x1234), false); /* not uuid */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &nil)); /* (skip) */
|
||||
ATF_CHECK_EQ(sdp_data_type(&nil), SDP_DATA_NIL);
|
||||
ATF_REQUIRE(sdp_match_uuid16(&test, 0x1234));
|
||||
|
||||
ATF_REQUIRE(sdp_match_uuid16(&test, 0x3456));
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_match_uuid16(&test, 0x1234), false); /* mismatch */
|
||||
ATF_REQUIRE(sdp_match_uuid16(&test, 0x4321));
|
||||
|
||||
ATF_CHECK_EQ(test.next, test.end);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
ATF_TP_ADD_TC(tp, check_sdp_match_uuid16);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
@ -1,875 +0,0 @@
|
|||
/* $NetBSD: t_sdp_put.c,v 1.3 2011/04/16 07:32:27 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_put_data);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_data, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_data results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_data, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
uint8_t data[] = {
|
||||
0x35, 0x05, // seq8(5)
|
||||
0x08, 0x00, // uint8 0x00
|
||||
0x09, 0x12, 0x34, // uint16 0x1234
|
||||
};
|
||||
sdp_data_t value = { data, data + sizeof(data) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_data(&test, &value));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x35, 0x05, // seq8(5)
|
||||
0x08, 0x00, // uint8 0x00
|
||||
0x09, 0x12, 0x34, // uint16 0x1234
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_attr);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_attr, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_attr results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_attr, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
uint8_t data[] = {
|
||||
0x00, // nil
|
||||
0x19, 0x33, 0x44, // uuid16 0x3344
|
||||
};
|
||||
sdp_data_t value = { data, data + sizeof(data) };
|
||||
|
||||
ATF_REQUIRE_EQ(sdp_put_attr(&test, 0xabcd, &value), false);
|
||||
value.next += 1; // skip "nil"
|
||||
ATF_REQUIRE(sdp_put_attr(&test, 0x1337, &value));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x09, 0x13, 0x37, // uint16 0x1337
|
||||
0x19, 0x33, 0x44, // uuid16 0x3344
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_uuid);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_uuid, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_uuid results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_uuid, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
const uuid_t u16 = {
|
||||
0x00001234,
|
||||
0x0000,
|
||||
0x1000,
|
||||
0x80,
|
||||
0x00,
|
||||
{ 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb }
|
||||
};
|
||||
const uuid_t u32 = {
|
||||
0x12345678,
|
||||
0x0000,
|
||||
0x1000,
|
||||
0x80,
|
||||
0x00,
|
||||
{ 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb }
|
||||
};
|
||||
const uuid_t u128 = {
|
||||
0x00112233,
|
||||
0x4444,
|
||||
0x5555,
|
||||
0x66,
|
||||
0x77,
|
||||
{ 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd }
|
||||
};
|
||||
|
||||
ATF_REQUIRE(sdp_put_uuid(&test, &u16));
|
||||
ATF_REQUIRE(sdp_put_uuid(&test, &u32));
|
||||
ATF_REQUIRE(sdp_put_uuid(&test, &u128));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x19, 0x12, 0x34, // uuid16 0x1234
|
||||
0x1a, 0x12, 0x34, 0x56, // uuid32 0x12345678
|
||||
0x78,
|
||||
0x1c, 0x00, 0x11, 0x22, // uuid128 00112233-4444-5555-6677-8899aabbccdd
|
||||
0x33, 0x44, 0x44, 0x55,
|
||||
0x55, 0x66, 0x77, 0x88,
|
||||
0x99, 0xaa, 0xbb, 0xcc,
|
||||
0xdd,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_uuid16);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_uuid16, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_uuid16 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_uuid16, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_uuid16(&test, 0x4567));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x19, 0x45, 0x67, // uuid16 0x4567
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_uuid32);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_uuid32, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_uuid32 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_uuid32, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_uuid32(&test, 0xabcdef00));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x1a, 0xab, 0xcd, 0xef, // uuid32 0xabcdef00
|
||||
0x00,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_uuid128);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_uuid128, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_uuid128 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_uuid128, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
uuid_t value = {
|
||||
0x00000100,
|
||||
0x0000,
|
||||
0x1000,
|
||||
0x80,
|
||||
0x00,
|
||||
{ 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb }
|
||||
};
|
||||
|
||||
ATF_REQUIRE(sdp_put_uuid128(&test, &value));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x1c, 0x00, 0x00, 0x01, // uuid128 0000100-0000-1000-8000-00805f9b34fb
|
||||
0x00, 0x00, 0x00, 0x10, // (L2CAP protocol)
|
||||
0x00, 0x80, 0x00, 0x00,
|
||||
0x80, 0x5f, 0x9b, 0x34,
|
||||
0xfb,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_bool);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_bool, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_bool results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_bool, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_bool(&test, true));
|
||||
ATF_REQUIRE(sdp_put_bool(&test, false));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x28, 0x01, // bool true
|
||||
0x28, 0x00, // bool false
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_uint);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_uint, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_uint results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_uint, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_uint(&test, (uintmax_t)0));
|
||||
ATF_REQUIRE(sdp_put_uint(&test, (uintmax_t)UINT8_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint(&test, (uintmax_t)UINT8_MAX + 1));
|
||||
ATF_REQUIRE(sdp_put_uint(&test, (uintmax_t)UINT16_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint(&test, (uintmax_t)UINT16_MAX + 1));
|
||||
ATF_REQUIRE(sdp_put_uint(&test, (uintmax_t)UINT32_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint(&test, (uintmax_t)UINT32_MAX + 1));
|
||||
ATF_REQUIRE(sdp_put_uint(&test, (uintmax_t)UINT64_MAX));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x08, 0x00, // uint8 0x00
|
||||
0x08, 0xff, // uint8 0xff
|
||||
0x09, 0x01, 0x00, // uint16 0x0100
|
||||
0x09, 0xff, 0xff, // uint16 0xffff
|
||||
0x0a, 0x00, 0x01, 0x00, // uint32 0x00010000
|
||||
0x00,
|
||||
0x0a, 0xff, 0xff, 0xff, // uint32 0xffffffff
|
||||
0xff,
|
||||
0x0b, 0x00, 0x00, 0x00, // uint64 0x0000000100000000
|
||||
0x01, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x0b, 0xff, 0xff, 0xff, // uint64 0xffffffffffffffff
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
0xff,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_uint8);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_uint8, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_uint8 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_uint8, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_uint8(&test, (uint8_t)0));
|
||||
ATF_REQUIRE(sdp_put_uint8(&test, (uint8_t)UINT8_MAX));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x08, 0x00, // uint8 0x00
|
||||
0x08, 0xff, // uint8 0xff
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_uint16);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_uint16, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_uint16 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_uint16, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_uint16(&test, (uint16_t)0));
|
||||
ATF_REQUIRE(sdp_put_uint16(&test, (uint16_t)UINT8_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint16(&test, (uint16_t)UINT16_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint16(&test, (uint16_t)0xabcd));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x09, 0x00, 0x00, // uint16 0x0000
|
||||
0x09, 0x00, 0xff, // uint16 0x00ff
|
||||
0x09, 0xff, 0xff, // uint16 0xffff
|
||||
0x09, 0xab, 0xcd, // uint16 0xabcd
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_uint32);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_uint32, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_uint32 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_uint32, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_uint32(&test, (uint32_t)0));
|
||||
ATF_REQUIRE(sdp_put_uint32(&test, (uint32_t)UINT8_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint32(&test, (uint32_t)UINT16_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint32(&test, (uint32_t)UINT32_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint32(&test, (uint32_t)0xdeadbeef));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x0a, 0x00, 0x00, 0x00, // uint32 0x00000000
|
||||
0x00,
|
||||
0x0a, 0x00, 0x00, 0x00, // uint32 0x000000ff
|
||||
0xff,
|
||||
0x0a, 0x00, 0x00, 0xff, // uint32 0x0000ffff
|
||||
0xff,
|
||||
0x0a, 0xff, 0xff, 0xff, // uint32 0xffffffff
|
||||
0xff,
|
||||
0x0a, 0xde, 0xad, 0xbe, // uint32 0xdeadbeef
|
||||
0xef,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_uint64);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_uint64, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_uint64 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_uint64, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_uint64(&test, (uint64_t)0));
|
||||
ATF_REQUIRE(sdp_put_uint64(&test, (uint64_t)UINT8_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint64(&test, (uint64_t)UINT16_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint64(&test, (uint64_t)UINT32_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint64(&test, (uint64_t)UINT64_MAX));
|
||||
ATF_REQUIRE(sdp_put_uint64(&test, (uint64_t)0xc0ffeecafec0ffee));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x0b, 0x00, 0x00, 0x00, // uint64 0x0000000000000000
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x0b, 0x00, 0x00, 0x00, // uint64 0x00000000000000ff
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0xff,
|
||||
0x0b, 0x00, 0x00, 0x00, // uint64 0x000000000000ffff
|
||||
0x00, 0x00, 0x00, 0xff,
|
||||
0xff,
|
||||
0x0b, 0x00, 0x00, 0x00, // uint64 0x00000000ffffffff
|
||||
0x00, 0xff, 0xff, 0xff,
|
||||
0xff,
|
||||
0x0b, 0xff, 0xff, 0xff, // uint64 0xffffffffffffffff
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
0xff,
|
||||
0x0b, 0xc0, 0xff, 0xee, // uint64 0xc0ffeecafec0ffee
|
||||
0xca, 0xfe, 0xc0, 0xff,
|
||||
0xee,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_int);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_int, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_int results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_int, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)0));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT8_MIN));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT8_MAX));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT8_MIN - 1));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT8_MAX + 1));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT16_MIN));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT16_MAX));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT16_MIN - 1));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT16_MAX + 1));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT32_MIN));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT32_MAX));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT32_MIN - 1));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT32_MAX + 1));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT64_MIN));
|
||||
ATF_REQUIRE(sdp_put_int(&test, (intmax_t)INT64_MAX));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x10, 0x00, // int8 0
|
||||
0x10, 0x80, // int8 -128
|
||||
0x10, 0x7f, // int8 127
|
||||
0x11, 0xff, 0x7f, // int16 -129
|
||||
0x11, 0x00, 0x80, // int16 128
|
||||
0x11, 0x80, 0x00, // int16 -32768
|
||||
0x11, 0x7f, 0xff, // int16 32767
|
||||
0x12, 0xff, 0xff, 0x7f, // int32 -32769
|
||||
0xff,
|
||||
0x12, 0x00, 0x00, 0x80, // int32 32768
|
||||
0x00,
|
||||
0x12, 0x80, 0x00, 0x00, // int32 -2147483648
|
||||
0x00,
|
||||
0x12, 0x7f, 0xff, 0xff, // int32 2147483647
|
||||
0xff,
|
||||
0x13, 0xff, 0xff, 0xff, // int64 -2147483649
|
||||
0xff, 0x7f, 0xff, 0xff,
|
||||
0xff,
|
||||
0x13, 0x00, 0x00, 0x00, // int64 2147483648
|
||||
0x00, 0x80, 0x00, 0x00,
|
||||
0x00,
|
||||
0x13, 0x80, 0x00, 0x00, // int64 -9223372036854775808
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x13, 0x7f, 0xff, 0xff, // int64 9223372036854775807
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
0xff,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_int8);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_int8, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_int8 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_int8, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_int8(&test, (int8_t)0));
|
||||
ATF_REQUIRE(sdp_put_int8(&test, (int8_t)INT8_MIN));
|
||||
ATF_REQUIRE(sdp_put_int8(&test, (int8_t)INT8_MAX));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x10, 0x00, // int8 0
|
||||
0x10, 0x80, // int8 -128
|
||||
0x10, 0x7f, // int8 127
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_int16);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_int16, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_int16 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_int16, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_int16(&test, (int16_t)0));
|
||||
ATF_REQUIRE(sdp_put_int16(&test, (int16_t)INT8_MIN));
|
||||
ATF_REQUIRE(sdp_put_int16(&test, (int16_t)INT8_MAX));
|
||||
ATF_REQUIRE(sdp_put_int16(&test, (int16_t)INT16_MIN));
|
||||
ATF_REQUIRE(sdp_put_int16(&test, (int16_t)INT16_MAX));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x11, 0x00, 0x00, // int16 0
|
||||
0x11, 0xff, 0x80, // int16 -128
|
||||
0x11, 0x00, 0x7f, // int16 127
|
||||
0x11, 0x80, 0x00, // int16 -32768
|
||||
0x11, 0x7f, 0xff, // int16 32767
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_int32);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_int32, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_int32 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_int32, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_int32(&test, (int32_t)0));
|
||||
ATF_REQUIRE(sdp_put_int32(&test, (int32_t)INT8_MIN));
|
||||
ATF_REQUIRE(sdp_put_int32(&test, (int32_t)INT8_MAX));
|
||||
ATF_REQUIRE(sdp_put_int32(&test, (int32_t)INT16_MIN));
|
||||
ATF_REQUIRE(sdp_put_int32(&test, (int32_t)INT16_MAX));
|
||||
ATF_REQUIRE(sdp_put_int32(&test, (int32_t)INT32_MIN));
|
||||
ATF_REQUIRE(sdp_put_int32(&test, (int32_t)INT32_MAX));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x12, 0x00, 0x00, 0x00, // int32 0
|
||||
0x00,
|
||||
0x12, 0xff, 0xff, 0xff, // int32 -128
|
||||
0x80,
|
||||
0x12, 0x00, 0x00, 0x00, // int32 127
|
||||
0x7f,
|
||||
0x12, 0xff, 0xff, 0x80, // int32 -32768
|
||||
0x00,
|
||||
0x12, 0x00, 0x00, 0x7f, // int32 32767
|
||||
0xff,
|
||||
0x12, 0x80, 0x00, 0x00, // int32 -2147483648
|
||||
0x00,
|
||||
0x12, 0x7f, 0xff, 0xff, // int32 2147483647
|
||||
0xff,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_int64);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_int64, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_int64 results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_int64, tc)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_int64(&test, (int64_t)0));
|
||||
ATF_REQUIRE(sdp_put_int64(&test, (int64_t)INT8_MIN));
|
||||
ATF_REQUIRE(sdp_put_int64(&test, (int64_t)INT8_MAX));
|
||||
ATF_REQUIRE(sdp_put_int64(&test, (int64_t)INT16_MIN));
|
||||
ATF_REQUIRE(sdp_put_int64(&test, (int64_t)INT16_MAX));
|
||||
ATF_REQUIRE(sdp_put_int64(&test, (int64_t)INT32_MIN));
|
||||
ATF_REQUIRE(sdp_put_int64(&test, (int64_t)INT32_MAX));
|
||||
ATF_REQUIRE(sdp_put_int64(&test, (int64_t)INT64_MIN));
|
||||
ATF_REQUIRE(sdp_put_int64(&test, (int64_t)INT64_MAX));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x13, 0x00, 0x00, 0x00, // int64 0
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x13, 0xff, 0xff, 0xff, // int64 -128
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
0x80,
|
||||
0x13, 0x00, 0x00, 0x00, // int64 127
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x7f,
|
||||
0x13, 0xff, 0xff, 0xff, // int64 -32768
|
||||
0xff, 0xff, 0xff, 0x80,
|
||||
0x00,
|
||||
0x13, 0x00, 0x00, 0x00, // int64 32767
|
||||
0x00, 0x00, 0x00, 0x7f,
|
||||
0xff,
|
||||
0x13, 0xff, 0xff, 0xff, // int64 -2147483648
|
||||
0xff, 0x80, 0x00, 0x00,
|
||||
0x00,
|
||||
0x13, 0x00, 0x00, 0x00, // int64 2147483647
|
||||
0x00, 0x7f, 0xff, 0xff,
|
||||
0xff,
|
||||
0x13, 0x80, 0x00, 0x00, // int64 -9223372036854775808
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x13, 0x7f, 0xff, 0xff, // int64 9223372036854775807
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
0xff,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_seq);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_seq, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_seq results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_seq, tc)
|
||||
{
|
||||
uint8_t buf[512];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_seq(&test, (ssize_t)0));
|
||||
ATF_REQUIRE(sdp_put_seq(&test, (ssize_t)UINT8_MAX));
|
||||
ATF_REQUIRE(sdp_put_seq(&test, (ssize_t)UINT8_MAX + 1));
|
||||
ATF_REQUIRE(sdp_put_seq(&test, (ssize_t)-1));
|
||||
ATF_CHECK_EQ(sdp_put_seq(&test, (ssize_t)UINT16_MAX), false); /* no room */
|
||||
ATF_CHECK_EQ(sdp_put_seq(&test, (ssize_t)SSIZE_MAX), false); /* no room */
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
/* (not a valid element list) */
|
||||
const uint8_t expect[] = {
|
||||
0x35, 0x00, // seq8(0)
|
||||
0x35, 0xff, // seq8(255)
|
||||
0x36, 0x01, 0x00, // seq16(256)
|
||||
0x36, 0x01, 0xf6, // seq16(502) <- sizeof(buf) - 7 - 3
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_alt);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_alt, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_alt results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_alt, tc)
|
||||
{
|
||||
uint8_t buf[512];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
ATF_REQUIRE(sdp_put_alt(&test, (ssize_t)0));
|
||||
ATF_REQUIRE(sdp_put_alt(&test, (ssize_t)UINT8_MAX));
|
||||
ATF_REQUIRE(sdp_put_alt(&test, (ssize_t)UINT8_MAX + 1));
|
||||
ATF_REQUIRE(sdp_put_alt(&test, (ssize_t)-1));
|
||||
ATF_CHECK_EQ(sdp_put_alt(&test, (ssize_t)UINT16_MAX), false); /* no room */
|
||||
ATF_CHECK_EQ(sdp_put_alt(&test, (ssize_t)SSIZE_MAX), false); /* no room */
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
/* (not a valid element list) */
|
||||
const uint8_t expect[] = {
|
||||
0x3d, 0x00, // alt8(0)
|
||||
0x3d, 0xff, // alt8(255)
|
||||
0x3e, 0x01, 0x00, // alt16(256)
|
||||
0x3e, 0x01, 0xf6, // alt16(502) <- sizeof(buf) - 7 - 3
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_str);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_str, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_str results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_str, tc)
|
||||
{
|
||||
uint8_t buf[512];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
/*
|
||||
* this does not test str16 or str32, but that is
|
||||
* handled by the same code as sdp_put_seq above..
|
||||
*/
|
||||
|
||||
ATF_REQUIRE(sdp_put_str(&test, "Hello World!", 5));
|
||||
ATF_REQUIRE(sdp_put_str(&test, "Hello\0World", 11));
|
||||
ATF_REQUIRE(sdp_put_str(&test, "Hello World!", -1));
|
||||
ATF_REQUIRE(sdp_put_str(&test, "Hello\0World", -1));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x25, 0x05, 0x48, 0x65, // str8 "Hello"
|
||||
0x6c, 0x6c, 0x6f,
|
||||
0x25, 0x0b, 0x48, 0x65, // str8 "Hello\0World"
|
||||
0x6c, 0x6c, 0x6f, 0x00,
|
||||
0x57, 0x6f, 0x72, 0x6c,
|
||||
0x64,
|
||||
0x25, 0x0c, 0x48, 0x65, // str8 "Hello World!"
|
||||
0x6c, 0x6c, 0x6f, 0x20,
|
||||
0x57, 0x6f, 0x72, 0x6c,
|
||||
0x64, 0x21,
|
||||
0x25, 0x05, 0x48, 0x65, // str8 "Hello"
|
||||
0x6c, 0x6c, 0x6f,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_put_url);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_put_url, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_put_url results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_put_url, tc)
|
||||
{
|
||||
uint8_t buf[512];
|
||||
sdp_data_t test = { buf, buf + sizeof(buf) };
|
||||
|
||||
/*
|
||||
* this does not test url16 or url32, but that is
|
||||
* handled by the same code as sdp_put_seq above..
|
||||
*/
|
||||
|
||||
ATF_REQUIRE(sdp_put_url(&test, "http://www.netbsd.org/", 21));
|
||||
ATF_REQUIRE(sdp_put_url(&test, "http://www.netbsd.org/", -1));
|
||||
test.end = test.next;
|
||||
test.next = buf;
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x45, 0x15, 0x68, 0x74, // url8 "http://www.netbsd.org"
|
||||
0x74, 0x70, 0x3a, 0x2f,
|
||||
0x2f, 0x77, 0x77, 0x77,
|
||||
0x2e, 0x6e, 0x65, 0x74,
|
||||
0x62, 0x73, 0x64, 0x2e,
|
||||
0x6f, 0x72, 0x67,
|
||||
0x45, 0x16, 0x68, 0x74, // url8 "http://www.netbsd.org/"
|
||||
0x74, 0x70, 0x3a, 0x2f,
|
||||
0x2f, 0x77, 0x77, 0x77,
|
||||
0x2e, 0x6e, 0x65, 0x74,
|
||||
0x62, 0x73, 0x64, 0x2e,
|
||||
0x6f, 0x72, 0x67, 0x2f,
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(test.end - test.next, sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, test.next, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_data);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_attr);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_uuid);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_uuid16);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_uuid32);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_uuid128);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_bool);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_uint);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_uint8);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_uint16);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_uint32);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_uint64);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_int);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_int8);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_int16);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_int32);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_int64);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_seq);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_alt);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_str);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_put_url);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
@ -1,359 +0,0 @@
|
|||
/* $NetBSD: t_sdp_set.c,v 1.2 2011/04/07 08:29:50 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_set_bool);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_set_bool, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_set_bool results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_set_bool, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x28, 0x00, // bool false
|
||||
0x00, // nil
|
||||
0x28, // bool <invalid>
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t discard;
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_BOOL);
|
||||
ATF_REQUIRE(sdp_set_bool(&test, true));
|
||||
ATF_CHECK_EQ(test.next[1], 0x01);
|
||||
ATF_REQUIRE(sdp_set_bool(&test, false));
|
||||
ATF_CHECK_EQ(test.next[1], 0x00);
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_NIL);
|
||||
ATF_CHECK_EQ(sdp_set_bool(&test, true), false); /* not bool */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_BOOL);
|
||||
ATF_CHECK_EQ(sdp_set_bool(&test, true), false); /* no value */
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_set_uint);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_set_uint, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_set_uint results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_set_uint, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x08, 0x00, // uint8 0x00
|
||||
0x00, // nil
|
||||
0x09, 0x00, 0x00, // uint16 0x0000
|
||||
0x0a, 0x00, 0x00, 0x00, // uint32 0x00000000
|
||||
0x00,
|
||||
0x0b, 0x00, 0x00, 0x00, // uint64 0x0000000000000000
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x0c, 0x00, 0x44, 0x00, // uint128 0x00440044004400440044004400440044
|
||||
0x44, 0x00, 0x44, 0x00,
|
||||
0x44, 0x00, 0x44, 0x00,
|
||||
0x44, 0x00, 0x44, 0x00,
|
||||
0x00,
|
||||
0x09, 0x00, // uint16 <invalid>
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t discard;
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_UINT8);
|
||||
ATF_REQUIRE(sdp_set_uint(&test, 0x44));
|
||||
ATF_CHECK_EQ(sdp_set_uint(&test, UINT8_MAX + 1), false); /* too big */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_NIL);
|
||||
ATF_CHECK_EQ(sdp_set_uint(&test, 0x00), false); /* not uint */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_UINT16);
|
||||
ATF_REQUIRE(sdp_set_uint(&test, 0xabcd));
|
||||
ATF_CHECK_EQ(sdp_set_uint(&test, UINT16_MAX + 1), false); /* too big */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_UINT32);
|
||||
ATF_REQUIRE(sdp_set_uint(&test, 0xdeadbeef));
|
||||
ATF_CHECK_EQ(sdp_set_uint(&test, (uintmax_t)UINT32_MAX + 1), false); /* too big */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_UINT64);
|
||||
ATF_REQUIRE(sdp_set_uint(&test, 0xc0ffeecafec0ffee));
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_UINT128);
|
||||
ATF_REQUIRE(sdp_set_uint(&test, 0xabcdef0123456789));
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_UINT16);
|
||||
ATF_CHECK_EQ(sdp_set_uint(&test, 0x3344), false); /* no value */
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x08, 0x44, // uint8 0x44
|
||||
0x00, // nil
|
||||
0x09, 0xab, 0xcd, // uint16 0xabcd
|
||||
0x0a, 0xde, 0xad, 0xbe, // uint32 0xdeadbeef
|
||||
0xef,
|
||||
0x0b, 0xc0, 0xff, 0xee, // uint64 0xc0ffeecafec0ffee
|
||||
0xca, 0xfe, 0xc0, 0xff,
|
||||
0xee,
|
||||
0x0c, 0x00, 0x00, 0x00, // uint128 0x0000000000000000abcdef0123456789
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xab, 0xcd, 0xef,
|
||||
0x01, 0x23, 0x45, 0x67,
|
||||
0x89,
|
||||
0x09, 0x00, // uint16 <invalid>
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(sizeof(data), sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, data, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_set_int);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_set_int, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_set_int results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_set_int, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x10, 0x00, // int8 0
|
||||
0x00, // nil
|
||||
0x11, 0x00, 0x00, // int16 0
|
||||
0x12, 0x00, 0x00, 0x00, // int32 0
|
||||
0x00,
|
||||
0x13, 0x00, 0x00, 0x00, // int64 0
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00,
|
||||
0x14, 0x00, 0x44, 0x00, // int128 0x00440044004400440044004400440044
|
||||
0x44, 0x00, 0x44, 0x00,
|
||||
0x44, 0x00, 0x44, 0x00,
|
||||
0x44, 0x00, 0x44, 0x00,
|
||||
0x00,
|
||||
0x11, 0x00, // int16 <invalid>
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t discard;
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_INT8);
|
||||
ATF_REQUIRE(sdp_set_int(&test, -1));
|
||||
ATF_CHECK_EQ(sdp_set_int(&test, INT8_MAX + 1), false); /* too big */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_NIL);
|
||||
ATF_CHECK_EQ(sdp_set_int(&test, 33), false); /* not int */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_INT16);
|
||||
ATF_REQUIRE(sdp_set_int(&test, 789));
|
||||
ATF_CHECK_EQ(sdp_set_int(&test, INT16_MIN - 1), false); /* too big */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_INT32);
|
||||
ATF_REQUIRE(sdp_set_int(&test, -4567));
|
||||
ATF_CHECK_EQ(sdp_set_int(&test, (intmax_t)INT32_MAX + 1), false); /* too big */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_INT64);
|
||||
ATF_REQUIRE(sdp_set_int(&test, -3483738234));
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_INT128);
|
||||
ATF_REQUIRE(sdp_set_int(&test, 3423489463464));
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_INT16);
|
||||
ATF_CHECK_EQ(sdp_set_int(&test, 1234), false); /* no value */
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x10, 0xff, // int8 -1
|
||||
0x00, // nil
|
||||
0x11, 0x03, 0x15, // int16 789
|
||||
0x12, 0xff, 0xff, 0xee, // int32 -4567
|
||||
0x29,
|
||||
0x13, 0xff, 0xff, 0xff, // int64 -3483738234
|
||||
0xff, 0x30, 0x5a, 0x5f,
|
||||
0x86,
|
||||
0x14, 0x00, 0x00, 0x00, // int128 3423489463464
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x03,
|
||||
0x1d, 0x17, 0xdf, 0x94,
|
||||
0xa8,
|
||||
0x11, 0x00, // int16 <invalid>
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(sizeof(data), sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, data, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_set_seq);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_set_seq, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_set_seq results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_set_seq, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x35, 0x03, // seq8(3)
|
||||
0x11, 0xff, 0xff, // int16 -1
|
||||
0x36, 0x01, 0x00, // seq16(256)
|
||||
0x09, 0xff, 0xff, // uint16 0xffff
|
||||
0x37, 0x01, 0x02, 0x03, // seq32(16909060)
|
||||
0x04,
|
||||
0x36, 0x00, // seq16(<invalid>)
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t discard;
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_SEQ8);
|
||||
ATF_REQUIRE(sdp_set_seq(&test, 0));
|
||||
ATF_CHECK_EQ(sdp_set_seq(&test, UINT8_MAX), false); /* data too big */
|
||||
ATF_CHECK_EQ(sdp_set_seq(&test, UINT16_MAX), false); /* size too big */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_INT16);
|
||||
ATF_CHECK_EQ(sdp_set_seq(&test, 33), false); /* not seq */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_SEQ16);
|
||||
ATF_REQUIRE(sdp_set_seq(&test, 3));
|
||||
ATF_CHECK_EQ(sdp_set_seq(&test, SSIZE_MAX), false); /* size too big */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_SEQ32);
|
||||
ATF_REQUIRE(sdp_set_seq(&test, 0));
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_SEQ16);
|
||||
ATF_CHECK_EQ(sdp_set_seq(&test, 22), false); /* no size */
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x35, 0x00, // seq8(0)
|
||||
0x11, 0xff, 0xff, // int16 -1
|
||||
0x36, 0x00, 0x03, // seq16(3)
|
||||
0x09, 0xff, 0xff, // uint16 0xffff
|
||||
0x37, 0x00, 0x00, 0x00, // seq32(0)
|
||||
0x00,
|
||||
0x36, 0x00, // seq16(<invalid>)
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(sizeof(data), sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, data, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
ATF_TC(check_sdp_set_alt);
|
||||
|
||||
ATF_TC_HEAD(check_sdp_set_alt, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "Test sdp_set_alt results");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(check_sdp_set_alt, tc)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
0x3d, 0x06, // alt8(6)
|
||||
0x11, 0xff, 0xff, // int16 -1
|
||||
0x3e, 0xff, 0xff, // alt16(65535)
|
||||
0x3f, 0x01, 0x02, 0x03, // alt32(16909060)
|
||||
0x04,
|
||||
0x0a, 0x00, 0x00, 0x00, // uint32 0x00000003
|
||||
0x03,
|
||||
0x3e, 0x00, // alt16(<invalid>)
|
||||
};
|
||||
sdp_data_t test = { data, data + sizeof(data) };
|
||||
sdp_data_t discard;
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_ALT8);
|
||||
ATF_REQUIRE(sdp_set_alt(&test, 0));
|
||||
ATF_CHECK_EQ(sdp_set_alt(&test, UINT8_MAX), false); /* data too big */
|
||||
ATF_CHECK_EQ(sdp_set_alt(&test, UINT16_MAX), false); /* size too big */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_INT16);
|
||||
ATF_CHECK_EQ(sdp_set_alt(&test, 27), false); /* not alt */
|
||||
ATF_REQUIRE(sdp_get_data(&test, &discard));
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_ALT16);
|
||||
ATF_REQUIRE(sdp_set_alt(&test, 10));
|
||||
ATF_CHECK_EQ(sdp_set_alt(&test, SSIZE_MAX), false); /* size too big */
|
||||
ATF_REQUIRE(sdp_get_alt(&test, &discard));
|
||||
ATF_CHECK_EQ(sdp_data_type(&discard), SDP_DATA_ALT32);
|
||||
ATF_CHECK(sdp_set_alt(&discard, -1)); /* end of alt16 */
|
||||
ATF_CHECK_EQ(sdp_set_alt(&discard, 6), false); /* data too big */
|
||||
|
||||
ATF_CHECK_EQ(sdp_data_type(&test), SDP_DATA_ALT16);
|
||||
ATF_CHECK_EQ(sdp_set_alt(&test, 22), false); /* no size */
|
||||
|
||||
const uint8_t expect[] = {
|
||||
0x3d, 0x00, // alt8(0)
|
||||
0x11, 0xff, 0xff, // int16 -1
|
||||
0x3e, 0x00, 0x0a, // alt16(10)
|
||||
0x3f, 0x00, 0x00, 0x00, // alt32(5)
|
||||
0x05,
|
||||
0x0a, 0x00, 0x00, 0x00, // uint32 0x00000003
|
||||
0x03,
|
||||
0x3e, 0x00, // alt16(<invalid>)
|
||||
};
|
||||
|
||||
ATF_REQUIRE_EQ(sizeof(data), sizeof(expect));
|
||||
ATF_CHECK(memcmp(expect, data, sizeof(expect)) == 0);
|
||||
}
|
||||
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
ATF_TP_ADD_TC(tp, check_sdp_set_bool);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_set_uint);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_set_int);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_set_seq);
|
||||
ATF_TP_ADD_TC(tp, check_sdp_set_alt);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.5 2014/06/25 19:13:27 alnsn Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include <../../../external/bsd/sljit/Makefile.inc>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/libbpfjit
|
||||
|
||||
TESTS_C+= t_bpfjit
|
||||
TESTS_C+= t_extmem
|
||||
TESTS_C+= t_cop
|
||||
|
||||
# XXX this variable doesn't belong to here
|
||||
LIBBPFJITDIR!= cd ${NETBSDSRCDIR}/lib/libbpfjit && ${PRINTOBJDIR}
|
||||
|
||||
LDADD+= -L${LIBBPFJITDIR} -lbpfjit
|
||||
DPADD+= ${LIBBPFJITDIR}/libbpfjit.a
|
||||
|
||||
LDADD+= -L${LIBSLJITDIR} -lsljit
|
||||
DPADD+= ${LIBSLJITDIR}/libsljit.a
|
||||
|
||||
LDADD+= ${LIBPCAP}
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.1 2011/12/27 00:47:23 christos Exp $
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/libcrypt
|
||||
|
||||
LDADD+= -lcrypt
|
||||
DPADD+= ${LIBCRYPT}
|
||||
WARNS?= 4
|
||||
|
||||
TESTS_C= t_crypt
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
/* $NetBSD: t_crypt.c,v 1.3 2011/12/28 22:07:40 christos Exp $ */
|
||||
|
||||
/*
|
||||
* This version is derived from the original implementation of FreeSec
|
||||
* (release 1.1) by David Burren. I've reviewed the changes made in
|
||||
* OpenBSD (as of 2.7) and modified the original code in a similar way
|
||||
* where applicable. I've also made it reentrant and made a number of
|
||||
* other changes.
|
||||
* - Solar Designer <solar at openwall.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* FreeSec: libcrypt for NetBSD
|
||||
*
|
||||
* Copyright (c) 1994 David Burren
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. Neither the name of the author nor the names of other contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $Owl: Owl/packages/glibc/crypt_freesec.c,v 1.6 2010/02/20 14:45:06 solar Exp $
|
||||
* Id: crypt.c,v 1.15 1994/09/13 04:58:49 davidb Exp
|
||||
*
|
||||
* This is an original implementation of the DES and the crypt(3) interfaces
|
||||
* by David Burren <davidb at werj.com.au>.
|
||||
*
|
||||
* An excellent reference on the underlying algorithm (and related
|
||||
* algorithms) is:
|
||||
*
|
||||
* B. Schneier, Applied Cryptography: protocols, algorithms,
|
||||
* and source code in C, John Wiley & Sons, 1994.
|
||||
*
|
||||
* Note that in that book's description of DES the lookups for the initial,
|
||||
* pbox, and final permutations are inverted (this has been brought to the
|
||||
* attention of the author). A list of errata for this book has been
|
||||
* posted to the sci.crypt newsgroup by the author and is available for FTP.
|
||||
*
|
||||
* ARCHITECTURE ASSUMPTIONS:
|
||||
* This code used to have some nasty ones, but these have been removed
|
||||
* by now. The code requires a 32-bit integer type, though.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: t_crypt.c,v 1.3 2011/12/28 22:07:40 christos Exp $");
|
||||
|
||||
#include <atf-c.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static const struct {
|
||||
const char *hash;
|
||||
const char *pw;
|
||||
} tests[] = {
|
||||
/* "new"-style */
|
||||
/* 0 */ { "_J9..CCCCXBrJUJV154M", "U*U*U*U*" },
|
||||
/* 1 */ { "_J9..CCCCXUhOBTXzaiE", "U*U***U" },
|
||||
/* 2 */ { "_J9..CCCC4gQ.mB/PffM", "U*U***U*" },
|
||||
/* 3 */ { "_J9..XXXXvlzQGqpPPdk", "*U*U*U*U" },
|
||||
/* 4 */ { "_J9..XXXXsqM/YSSP..Y", "*U*U*U*U*" },
|
||||
/* 5 */ { "_J9..XXXXVL7qJCnku0I", "*U*U*U*U*U*U*U*U" },
|
||||
/* 6 */ { "_J9..XXXXAj8cFbP5scI", "*U*U*U*U*U*U*U*U*" },
|
||||
/* 7 */ { "_J9..SDizh.vll5VED9g", "ab1234567" },
|
||||
/* 8 */ { "_J9..SDizRjWQ/zePPHc", "cr1234567" },
|
||||
/* 9 */ { "_J9..SDizxmRI1GjnQuE", "zxyDPWgydbQjgq" },
|
||||
/* 10 */ { "_K9..SaltNrQgIYUAeoY", "726 even" },
|
||||
/* 11 */ { "_J9..SDSD5YGyRCr4W4c", "" },
|
||||
/* "old"-style, valid salts */
|
||||
/* 12 */ { "CCNf8Sbh3HDfQ", "U*U*U*U*" },
|
||||
/* 13 */ { "CCX.K.MFy4Ois", "U*U***U" },
|
||||
/* 14 */ { "CC4rMpbg9AMZ.", "U*U***U*" },
|
||||
/* 15 */ { "XXxzOu6maQKqQ", "*U*U*U*U" },
|
||||
/* 16 */ { "SDbsugeBiC58A", "" },
|
||||
/* 17 */ { "./xZjzHv5vzVE", "password" },
|
||||
/* 18 */ { "0A2hXM1rXbYgo", "password" },
|
||||
/* 19 */ { "A9RXdR23Y.cY6", "password" },
|
||||
/* 20 */ { "ZziFATVXHo2.6", "password" },
|
||||
/* 21 */ { "zZDDIZ0NOlPzw", "password" },
|
||||
/* "old"-style, "reasonable" invalid salts, UFC-crypt behavior expected */
|
||||
/* 22 */ { "\001\002wyd0KZo65Jo", "password" },
|
||||
/* 23 */ { "a_C10Dk/ExaG.", "password" },
|
||||
/* 24 */ { "~\377.5OTsRVjwLo", "password" },
|
||||
/* The below are erroneous inputs, so NULL return is expected/required */
|
||||
/* 25 */ { "", "" }, /* no salt */
|
||||
/* 26 */ { " ", "" }, /* setting string is too short */
|
||||
/* 27 */ { "a:", "" }, /* unsafe character */
|
||||
/* 28 */ { "\na", "" }, /* unsafe character */
|
||||
/* 29 */ { "_/......", "" }, /* setting string is too short for its type */
|
||||
/* 30 */ { "_........", "" }, /* zero iteration count */
|
||||
/* 31 */ { "_/!......", "" }, /* invalid character in count */
|
||||
/* 32 */ { "_/......!", "" }, /* invalid character in salt */
|
||||
/* 33 */ { NULL, NULL }
|
||||
};
|
||||
|
||||
ATF_TC(crypt_salts);
|
||||
|
||||
ATF_TC_HEAD(crypt_salts, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "crypt(3) salt consistency checks");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(crypt_salts, tc)
|
||||
{
|
||||
for (size_t i = 0; tests[i].hash; i++) {
|
||||
char *hash = crypt(tests[i].pw, tests[i].hash);
|
||||
if (!hash) {
|
||||
ATF_CHECK_MSG(0, "Test %zu NULL\n", i);
|
||||
continue;
|
||||
}
|
||||
if (strcmp(hash, "*0") == 0 && strlen(tests[i].hash) < 13)
|
||||
continue; /* expected failure */
|
||||
if (strcmp(hash, tests[i].hash))
|
||||
ATF_CHECK_MSG(0, "Test %zu %s != %s\n",
|
||||
i, hash, tests[i].hash);
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
ATF_TP_ADD_TC(tp, crypt_salts);
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.1 2010/08/25 16:46:36 jmmv Exp $
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/libdes
|
||||
|
||||
LDADD+= -ldes
|
||||
WARNS?= 4
|
||||
|
||||
TESTS_C= t_des
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,989 +0,0 @@
|
|||
/* $NetBSD: t_des.c,v 1.1 2010/08/25 16:46:36 jmmv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) All rights
|
||||
* reserved.
|
||||
*
|
||||
* This package is an SSL implementation written by Eric Young
|
||||
* (eay@cryptsoft.com). The implementation was written so as to conform with
|
||||
* Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as the
|
||||
* following conditions are aheared to. The following conditions apply to
|
||||
* all code found in this distribution, be it the RC4, RSA, lhash, DES, etc.,
|
||||
* code; not just the SSL code. The SSL documentation included with this
|
||||
* distribution is covered by the same copyright terms except that the holder
|
||||
* is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in the code
|
||||
* are not to be removed. If this package is used in a product, Eric Young
|
||||
* should be given attribution as the author of the parts of the library
|
||||
* used. This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* 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 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. 3. All advertising materials
|
||||
* mentioning features or use of this software must display the following
|
||||
* acknowledgement: "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)" The word 'cryptographic' can be left out
|
||||
* if the rouines from the library being used are not cryptographic related
|
||||
* :-). 4. If you include any Windows specific code (or a derivative thereof)
|
||||
* from the apps directory (application code) you must include an
|
||||
* acknowledgement: "This product includes software written by Tim Hudson
|
||||
* (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 AUTHOR 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply
|
||||
* be copied and put under another distribution licence [including the GNU
|
||||
* Public Licence.]
|
||||
*/
|
||||
|
||||
#include <atf-c.h>
|
||||
#include <des.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define crypt(c,s) (des_crypt((c),(s)))
|
||||
|
||||
/* tisk tisk - the test keys don't all have odd parity :-( */
|
||||
/* test data */
|
||||
#define NUM_TESTS 34
|
||||
static unsigned char key_data[NUM_TESTS][8] = {
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
|
||||
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
|
||||
{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10},
|
||||
{0x7C, 0xA1, 0x10, 0x45, 0x4A, 0x1A, 0x6E, 0x57},
|
||||
{0x01, 0x31, 0xD9, 0x61, 0x9D, 0xC1, 0x37, 0x6E},
|
||||
{0x07, 0xA1, 0x13, 0x3E, 0x4A, 0x0B, 0x26, 0x86},
|
||||
{0x38, 0x49, 0x67, 0x4C, 0x26, 0x02, 0x31, 0x9E},
|
||||
{0x04, 0xB9, 0x15, 0xBA, 0x43, 0xFE, 0xB5, 0xB6},
|
||||
{0x01, 0x13, 0xB9, 0x70, 0xFD, 0x34, 0xF2, 0xCE},
|
||||
{0x01, 0x70, 0xF1, 0x75, 0x46, 0x8F, 0xB5, 0xE6},
|
||||
{0x43, 0x29, 0x7F, 0xAD, 0x38, 0xE3, 0x73, 0xFE},
|
||||
{0x07, 0xA7, 0x13, 0x70, 0x45, 0xDA, 0x2A, 0x16},
|
||||
{0x04, 0x68, 0x91, 0x04, 0xC2, 0xFD, 0x3B, 0x2F},
|
||||
{0x37, 0xD0, 0x6B, 0xB5, 0x16, 0xCB, 0x75, 0x46},
|
||||
{0x1F, 0x08, 0x26, 0x0D, 0x1A, 0xC2, 0x46, 0x5E},
|
||||
{0x58, 0x40, 0x23, 0x64, 0x1A, 0xBA, 0x61, 0x76},
|
||||
{0x02, 0x58, 0x16, 0x16, 0x46, 0x29, 0xB0, 0x07},
|
||||
{0x49, 0x79, 0x3E, 0xBC, 0x79, 0xB3, 0x25, 0x8F},
|
||||
{0x4F, 0xB0, 0x5E, 0x15, 0x15, 0xAB, 0x73, 0xA7},
|
||||
{0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBF},
|
||||
{0x01, 0x83, 0x10, 0xDC, 0x40, 0x9B, 0x26, 0xD6},
|
||||
{0x1C, 0x58, 0x7F, 0x1C, 0x13, 0x92, 0x4F, 0xEF},
|
||||
{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
|
||||
{0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E},
|
||||
{0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
|
||||
{0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10}
|
||||
};
|
||||
|
||||
static unsigned char plain_data[NUM_TESTS][8] = {
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
|
||||
{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
|
||||
{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
|
||||
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
|
||||
{0x01, 0xA1, 0xD6, 0xD0, 0x39, 0x77, 0x67, 0x42},
|
||||
{0x5C, 0xD5, 0x4C, 0xA8, 0x3D, 0xEF, 0x57, 0xDA},
|
||||
{0x02, 0x48, 0xD4, 0x38, 0x06, 0xF6, 0x71, 0x72},
|
||||
{0x51, 0x45, 0x4B, 0x58, 0x2D, 0xDF, 0x44, 0x0A},
|
||||
{0x42, 0xFD, 0x44, 0x30, 0x59, 0x57, 0x7F, 0xA2},
|
||||
{0x05, 0x9B, 0x5E, 0x08, 0x51, 0xCF, 0x14, 0x3A},
|
||||
{0x07, 0x56, 0xD8, 0xE0, 0x77, 0x47, 0x61, 0xD2},
|
||||
{0x76, 0x25, 0x14, 0xB8, 0x29, 0xBF, 0x48, 0x6A},
|
||||
{0x3B, 0xDD, 0x11, 0x90, 0x49, 0x37, 0x28, 0x02},
|
||||
{0x26, 0x95, 0x5F, 0x68, 0x35, 0xAF, 0x60, 0x9A},
|
||||
{0x16, 0x4D, 0x5E, 0x40, 0x4F, 0x27, 0x52, 0x32},
|
||||
{0x6B, 0x05, 0x6E, 0x18, 0x75, 0x9F, 0x5C, 0xCA},
|
||||
{0x00, 0x4B, 0xD6, 0xEF, 0x09, 0x17, 0x60, 0x62},
|
||||
{0x48, 0x0D, 0x39, 0x00, 0x6E, 0xE7, 0x62, 0xF2},
|
||||
{0x43, 0x75, 0x40, 0xC8, 0x69, 0x8F, 0x3C, 0xFA},
|
||||
{0x07, 0x2D, 0x43, 0xA0, 0x77, 0x07, 0x52, 0x92},
|
||||
{0x02, 0xFE, 0x55, 0x77, 0x81, 0x17, 0xF1, 0x2A},
|
||||
{0x1D, 0x9D, 0x5C, 0x50, 0x18, 0xF7, 0x28, 0xC2},
|
||||
{0x30, 0x55, 0x32, 0x28, 0x6D, 0x6F, 0x29, 0x5A},
|
||||
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
|
||||
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
|
||||
{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
|
||||
};
|
||||
|
||||
static unsigned char cipher_data[NUM_TESTS][8] = {
|
||||
{0x8C, 0xA6, 0x4D, 0xE9, 0xC1, 0xB1, 0x23, 0xA7},
|
||||
{0x73, 0x59, 0xB2, 0x16, 0x3E, 0x4E, 0xDC, 0x58},
|
||||
{0x95, 0x8E, 0x6E, 0x62, 0x7A, 0x05, 0x55, 0x7B},
|
||||
{0xF4, 0x03, 0x79, 0xAB, 0x9E, 0x0E, 0xC5, 0x33},
|
||||
{0x17, 0x66, 0x8D, 0xFC, 0x72, 0x92, 0x53, 0x2D},
|
||||
{0x8A, 0x5A, 0xE1, 0xF8, 0x1A, 0xB8, 0xF2, 0xDD},
|
||||
{0x8C, 0xA6, 0x4D, 0xE9, 0xC1, 0xB1, 0x23, 0xA7},
|
||||
{0xED, 0x39, 0xD9, 0x50, 0xFA, 0x74, 0xBC, 0xC4},
|
||||
{0x69, 0x0F, 0x5B, 0x0D, 0x9A, 0x26, 0x93, 0x9B},
|
||||
{0x7A, 0x38, 0x9D, 0x10, 0x35, 0x4B, 0xD2, 0x71},
|
||||
{0x86, 0x8E, 0xBB, 0x51, 0xCA, 0xB4, 0x59, 0x9A},
|
||||
{0x71, 0x78, 0x87, 0x6E, 0x01, 0xF1, 0x9B, 0x2A},
|
||||
{0xAF, 0x37, 0xFB, 0x42, 0x1F, 0x8C, 0x40, 0x95},
|
||||
{0x86, 0xA5, 0x60, 0xF1, 0x0E, 0xC6, 0xD8, 0x5B},
|
||||
{0x0C, 0xD3, 0xDA, 0x02, 0x00, 0x21, 0xDC, 0x09},
|
||||
{0xEA, 0x67, 0x6B, 0x2C, 0xB7, 0xDB, 0x2B, 0x7A},
|
||||
{0xDF, 0xD6, 0x4A, 0x81, 0x5C, 0xAF, 0x1A, 0x0F},
|
||||
{0x5C, 0x51, 0x3C, 0x9C, 0x48, 0x86, 0xC0, 0x88},
|
||||
{0x0A, 0x2A, 0xEE, 0xAE, 0x3F, 0xF4, 0xAB, 0x77},
|
||||
{0xEF, 0x1B, 0xF0, 0x3E, 0x5D, 0xFA, 0x57, 0x5A},
|
||||
{0x88, 0xBF, 0x0D, 0xB6, 0xD7, 0x0D, 0xEE, 0x56},
|
||||
{0xA1, 0xF9, 0x91, 0x55, 0x41, 0x02, 0x0B, 0x56},
|
||||
{0x6F, 0xBF, 0x1C, 0xAF, 0xCF, 0xFD, 0x05, 0x56},
|
||||
{0x2F, 0x22, 0xE4, 0x9B, 0xAB, 0x7C, 0xA1, 0xAC},
|
||||
{0x5A, 0x6B, 0x61, 0x2C, 0xC2, 0x6C, 0xCE, 0x4A},
|
||||
{0x5F, 0x4C, 0x03, 0x8E, 0xD1, 0x2B, 0x2E, 0x41},
|
||||
{0x63, 0xFA, 0xC0, 0xD0, 0x34, 0xD9, 0xF7, 0x93},
|
||||
{0x61, 0x7B, 0x3A, 0x0C, 0xE8, 0xF0, 0x71, 0x00},
|
||||
{0xDB, 0x95, 0x86, 0x05, 0xF8, 0xC8, 0xC6, 0x06},
|
||||
{0xED, 0xBF, 0xD1, 0xC6, 0x6C, 0x29, 0xCC, 0xC7},
|
||||
{0x35, 0x55, 0x50, 0xB2, 0x15, 0x0E, 0x24, 0x51},
|
||||
{0xCA, 0xAA, 0xAF, 0x4D, 0xEA, 0xF1, 0xDB, 0xAE},
|
||||
{0xD5, 0xD4, 0x4F, 0xF7, 0x20, 0x68, 0x3D, 0x0D},
|
||||
{0x2A, 0x2B, 0xB0, 0x08, 0xDF, 0x97, 0xC2, 0xF2}
|
||||
};
|
||||
|
||||
static unsigned char cipher_ecb2[NUM_TESTS - 1][8] = {
|
||||
{0x92, 0x95, 0xB5, 0x9B, 0xB3, 0x84, 0x73, 0x6E},
|
||||
{0x19, 0x9E, 0x9D, 0x6D, 0xF3, 0x9A, 0xA8, 0x16},
|
||||
{0x2A, 0x4B, 0x4D, 0x24, 0x52, 0x43, 0x84, 0x27},
|
||||
{0x35, 0x84, 0x3C, 0x01, 0x9D, 0x18, 0xC5, 0xB6},
|
||||
{0x4A, 0x5B, 0x2F, 0x42, 0xAA, 0x77, 0x19, 0x25},
|
||||
{0xA0, 0x6B, 0xA9, 0xB8, 0xCA, 0x5B, 0x17, 0x8A},
|
||||
{0xAB, 0x9D, 0xB7, 0xFB, 0xED, 0x95, 0xF2, 0x74},
|
||||
{0x3D, 0x25, 0x6C, 0x23, 0xA7, 0x25, 0x2F, 0xD6},
|
||||
{0xB7, 0x6F, 0xAB, 0x4F, 0xBD, 0xBD, 0xB7, 0x67},
|
||||
{0x8F, 0x68, 0x27, 0xD6, 0x9C, 0xF4, 0x1A, 0x10},
|
||||
{0x82, 0x57, 0xA1, 0xD6, 0x50, 0x5E, 0x81, 0x85},
|
||||
{0xA2, 0x0F, 0x0A, 0xCD, 0x80, 0x89, 0x7D, 0xFA},
|
||||
{0xCD, 0x2A, 0x53, 0x3A, 0xDB, 0x0D, 0x7E, 0xF3},
|
||||
{0xD2, 0xC2, 0xBE, 0x27, 0xE8, 0x1B, 0x68, 0xE3},
|
||||
{0xE9, 0x24, 0xCF, 0x4F, 0x89, 0x3C, 0x5B, 0x0A},
|
||||
{0xA7, 0x18, 0xC3, 0x9F, 0xFA, 0x9F, 0xD7, 0x69},
|
||||
{0x77, 0x2C, 0x79, 0xB1, 0xD2, 0x31, 0x7E, 0xB1},
|
||||
{0x49, 0xAB, 0x92, 0x7F, 0xD0, 0x22, 0x00, 0xB7},
|
||||
{0xCE, 0x1C, 0x6C, 0x7D, 0x85, 0xE3, 0x4A, 0x6F},
|
||||
{0xBE, 0x91, 0xD6, 0xE1, 0x27, 0xB2, 0xE9, 0x87},
|
||||
{0x70, 0x28, 0xAE, 0x8F, 0xD1, 0xF5, 0x74, 0x1A},
|
||||
{0xAA, 0x37, 0x80, 0xBB, 0xF3, 0x22, 0x1D, 0xDE},
|
||||
{0xA6, 0xC4, 0xD2, 0x5E, 0x28, 0x93, 0xAC, 0xB3},
|
||||
{0x22, 0x07, 0x81, 0x5A, 0xE4, 0xB7, 0x1A, 0xAD},
|
||||
{0xDC, 0xCE, 0x05, 0xE7, 0x07, 0xBD, 0xF5, 0x84},
|
||||
{0x26, 0x1D, 0x39, 0x2C, 0xB3, 0xBA, 0xA5, 0x85},
|
||||
{0xB4, 0xF7, 0x0F, 0x72, 0xFB, 0x04, 0xF0, 0xDC},
|
||||
{0x95, 0xBA, 0xA9, 0x4E, 0x87, 0x36, 0xF2, 0x89},
|
||||
{0xD4, 0x07, 0x3A, 0xF1, 0x5A, 0x17, 0x82, 0x0E},
|
||||
{0xEF, 0x6F, 0xAF, 0xA7, 0x66, 0x1A, 0x7E, 0x89},
|
||||
{0xC1, 0x97, 0xF5, 0x58, 0x74, 0x8A, 0x20, 0xE7},
|
||||
{0x43, 0x34, 0xCF, 0xDA, 0x22, 0xC4, 0x86, 0xC8},
|
||||
{0x08, 0xD7, 0xB4, 0xFB, 0x62, 0x9D, 0x08, 0x85}
|
||||
};
|
||||
|
||||
static unsigned char cbc_key[8] = {
|
||||
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||
};
|
||||
static unsigned char cbc2_key[8] = {
|
||||
0xf1, 0xe0, 0xd3, 0xc2, 0xb5, 0xa4, 0x97, 0x86,
|
||||
};
|
||||
static unsigned char cbc3_key[8] = {
|
||||
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||
};
|
||||
static unsigned char cbc_iv[8] = {
|
||||
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||
};
|
||||
/*
|
||||
* Changed the following text constant to binary so it will work on ebcdic
|
||||
* machines :-)
|
||||
*/
|
||||
/* static char cbc_data[40]="7654321 Now is the time for \0001"; */
|
||||
static unsigned char cbc_data[40] = {
|
||||
0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
|
||||
0x4E, 0x6F, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x74, 0x69, 0x6D, 0x65, 0x20,
|
||||
0x66, 0x6F, 0x72, 0x20, 0x00, 0x31, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static unsigned char cbc_ok[32] = {
|
||||
0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
|
||||
0xac, 0xd8, 0xae, 0xfd, 0xdf, 0xd8, 0xa1, 0xeb,
|
||||
0x46, 0x8e, 0x91, 0x15, 0x78, 0x88, 0xba, 0x68,
|
||||
0x1d, 0x26, 0x93, 0x97, 0xf7, 0xfe, 0x62, 0xb4,
|
||||
};
|
||||
|
||||
#ifdef SCREW_THE_PARITY
|
||||
#error "SCREW_THE_PARITY is not ment to be defined."
|
||||
#error "Original vectors are preserved for reference only."
|
||||
static unsigned char cbc2_key[8] = {
|
||||
0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87,
|
||||
};
|
||||
static unsigned char xcbc_ok[32] = {
|
||||
0x86, 0x74, 0x81, 0x0D, 0x61, 0xA4, 0xA5, 0x48,
|
||||
0xB9, 0x93, 0x03, 0xE1, 0xB8, 0xBB, 0xBD, 0xBD,
|
||||
0x64, 0x30, 0x0B, 0xB9, 0x06, 0x65, 0x81, 0x76,
|
||||
0x04, 0x1D, 0x77, 0x62, 0x17, 0xCA, 0x2B, 0xD2,
|
||||
};
|
||||
#else
|
||||
static unsigned char xcbc_ok[32] = {
|
||||
0x84, 0x6B, 0x29, 0x14, 0x85, 0x1E, 0x9A, 0x29,
|
||||
0x54, 0x73, 0x2F, 0x8A, 0xA0, 0xA6, 0x11, 0xC1,
|
||||
0x15, 0xCD, 0xC2, 0xD7, 0x95, 0x1B, 0x10, 0x53,
|
||||
0xA6, 0x3C, 0x5E, 0x03, 0xB2, 0x1A, 0xA3, 0xC4,
|
||||
};
|
||||
#endif
|
||||
|
||||
static unsigned char cbc3_ok[32] = {
|
||||
0x3F, 0xE3, 0x01, 0xC9, 0x62, 0xAC, 0x01, 0xD0,
|
||||
0x22, 0x13, 0x76, 0x3C, 0x1C, 0xBD, 0x4C, 0xDC,
|
||||
0x79, 0x96, 0x57, 0xC0, 0x64, 0xEC, 0xF5, 0xD4,
|
||||
0x1C, 0x67, 0x38, 0x12, 0xCF, 0xDE, 0x96, 0x75
|
||||
};
|
||||
|
||||
static unsigned char pcbc_ok[32] = {
|
||||
0xcc, 0xd1, 0x73, 0xff, 0xab, 0x20, 0x39, 0xf4,
|
||||
0x6d, 0xec, 0xb4, 0x70, 0xa0, 0xe5, 0x6b, 0x15,
|
||||
0xae, 0xa6, 0xbf, 0x61, 0xed, 0x7d, 0x9c, 0x9f,
|
||||
0xf7, 0x17, 0x46, 0x3b, 0x8a, 0xb3, 0xcc, 0x88
|
||||
};
|
||||
|
||||
static unsigned char cfb_key[8] = {
|
||||
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||
};
|
||||
static unsigned char cfb_iv[8] = {
|
||||
0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
|
||||
};
|
||||
static unsigned char cfb_buf1[40], cfb_buf2[40], cfb_tmp[8];
|
||||
static unsigned char plain[24] =
|
||||
{
|
||||
0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73,
|
||||
0x20, 0x74, 0x68, 0x65, 0x20, 0x74,
|
||||
0x69, 0x6d, 0x65, 0x20, 0x66, 0x6f,
|
||||
0x72, 0x20, 0x61, 0x6c, 0x6c, 0x20,
|
||||
};
|
||||
static unsigned char cfb_cipher8[24] = {
|
||||
0xf3, 0x1f, 0xda, 0x07, 0x01, 0x14,
|
||||
0x62, 0xee, 0x18, 0x7f, 0x43, 0xd8,
|
||||
0x0a, 0x7c, 0xd9, 0xb5, 0xb0, 0xd2,
|
||||
0x90, 0xda, 0x6e, 0x5b, 0x9a, 0x87,
|
||||
};
|
||||
static unsigned char cfb_cipher16[24] = {
|
||||
0xF3, 0x09, 0x87, 0x87, 0x7F, 0x57,
|
||||
0xF7, 0x3C, 0x36, 0xB6, 0xDB, 0x70,
|
||||
0xD8, 0xD5, 0x34, 0x19, 0xD3, 0x86,
|
||||
0xB2, 0x23, 0xB7, 0xB2, 0xAD, 0x1B,
|
||||
};
|
||||
static unsigned char cfb_cipher32[24] = {
|
||||
0xF3, 0x09, 0x62, 0x49, 0xA4, 0xDF,
|
||||
0xA4, 0x9F, 0x33, 0xDC, 0x7B, 0xAD,
|
||||
0x4C, 0xC8, 0x9F, 0x64, 0xE4, 0x53,
|
||||
0xE5, 0xEC, 0x67, 0x20, 0xDA, 0xB6,
|
||||
};
|
||||
static unsigned char cfb_cipher48[24] = {
|
||||
0xF3, 0x09, 0x62, 0x49, 0xC7, 0xF4,
|
||||
0x30, 0xB5, 0x15, 0xEC, 0xBB, 0x85,
|
||||
0x97, 0x5A, 0x13, 0x8C, 0x68, 0x60,
|
||||
0xE2, 0x38, 0x34, 0x3C, 0xDC, 0x1F,
|
||||
};
|
||||
static unsigned char cfb_cipher64[24] = {
|
||||
0xF3, 0x09, 0x62, 0x49, 0xC7, 0xF4,
|
||||
0x6E, 0x51, 0xA6, 0x9E, 0x83, 0x9B,
|
||||
0x1A, 0x92, 0xF7, 0x84, 0x03, 0x46,
|
||||
0x71, 0x33, 0x89, 0x8E, 0xA6, 0x22,
|
||||
};
|
||||
|
||||
static unsigned char ofb_key[8] = {
|
||||
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||
};
|
||||
static unsigned char ofb_iv[8] = {
|
||||
0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef,
|
||||
};
|
||||
static unsigned char ofb_buf1[24], ofb_buf2[24], ofb_tmp[8];
|
||||
static unsigned char ofb_cipher[24] =
|
||||
{
|
||||
0xf3, 0x09, 0x62, 0x49, 0xc7, 0xf4, 0x6e, 0x51,
|
||||
0x35, 0xf2, 0x4a, 0x24, 0x2e, 0xeb, 0x3d, 0x3f,
|
||||
0x3d, 0x6d, 0x5b, 0xe3, 0x25, 0x5a, 0xf8, 0xc3
|
||||
};
|
||||
|
||||
static DES_LONG cbc_cksum_ret = 0xB462FEF7L;
|
||||
static unsigned char cbc_cksum_data[8] = {
|
||||
0x1D, 0x26, 0x93, 0x97, 0xf7, 0xfe, 0x62, 0xb4,
|
||||
};
|
||||
|
||||
static char *
|
||||
pt(unsigned char *p)
|
||||
{
|
||||
static char bufs[10][20];
|
||||
static int bnum = 0;
|
||||
char *ret;
|
||||
int i;
|
||||
static const char *f = "0123456789ABCDEF";
|
||||
|
||||
ret = &(bufs[bnum++][0]);
|
||||
bnum %= 10;
|
||||
for (i = 0; i < 8; i++) {
|
||||
ret[i * 2] = f[(p[i] >> 4) & 0xf];
|
||||
ret[i * 2 + 1] = f[p[i] & 0xf];
|
||||
}
|
||||
ret[16] = '\0';
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static void
|
||||
fail_cfb_buf(const char *msg, unsigned char *ptr)
|
||||
{
|
||||
char buf[1024];
|
||||
int i;
|
||||
|
||||
*buf = '\0';
|
||||
for (i = 0; i < 24; i += 8) {
|
||||
char buf2[128];
|
||||
snprintf(buf2, sizeof(buf2), "%s /", pt(&(cfb_buf1[i])));
|
||||
strlcat(buf, buf2, sizeof(buf));
|
||||
}
|
||||
|
||||
atf_tc_fail_nonfatal("%s: %s", msg, buf);
|
||||
}
|
||||
|
||||
#if !defined(LIBDES_LIT)
|
||||
static void
|
||||
cfb_test(int bits, unsigned char *cfb_cipher)
|
||||
{
|
||||
des_key_schedule ks;
|
||||
|
||||
des_set_key_checked(&cfb_key, ks);
|
||||
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
|
||||
des_cfb_encrypt(plain, cfb_buf1, bits, sizeof(plain), ks, &cfb_tmp,
|
||||
DES_ENCRYPT);
|
||||
if (memcmp(cfb_cipher, cfb_buf1, sizeof(plain)) != 0)
|
||||
fail_cfb_buf("cfb_encrypt encrypt error", cfb_buf1);
|
||||
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
|
||||
des_cfb_encrypt(cfb_buf1, cfb_buf2, bits, sizeof(plain), ks, &cfb_tmp,
|
||||
DES_DECRYPT);
|
||||
if (memcmp(plain, cfb_buf2, sizeof(plain)) != 0)
|
||||
fail_cfb_buf("cfb_encrypt decrypt error", cfb_buf2);
|
||||
}
|
||||
#endif /* !defined(LIBDES_LIT) */
|
||||
|
||||
#if !defined(LIBDES_LIT)
|
||||
static void
|
||||
cfb64_test(unsigned char *cfb_cipher)
|
||||
{
|
||||
int n;
|
||||
des_key_schedule ks;
|
||||
|
||||
des_set_key_checked(&cfb_key, ks);
|
||||
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
|
||||
n = 0;
|
||||
des_cfb64_encrypt(plain, cfb_buf1, 12, ks, &cfb_tmp, &n, DES_ENCRYPT);
|
||||
des_cfb64_encrypt(&(plain[12]), &(cfb_buf1[12]), sizeof(plain) - 12, ks,
|
||||
&cfb_tmp, &n, DES_ENCRYPT);
|
||||
if (memcmp(cfb_cipher, cfb_buf1, sizeof(plain)) != 0)
|
||||
fail_cfb_buf("cfb_encrypt encrypt error", cfb_buf1);
|
||||
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
|
||||
n = 0;
|
||||
des_cfb64_encrypt(cfb_buf1, cfb_buf2, 17, ks, &cfb_tmp, &n, DES_DECRYPT);
|
||||
des_cfb64_encrypt(&(cfb_buf1[17]), &(cfb_buf2[17]),
|
||||
sizeof(plain) - 17, ks, &cfb_tmp, &n, DES_DECRYPT);
|
||||
if (memcmp(plain, cfb_buf2, sizeof(plain)) != 0)
|
||||
fail_cfb_buf("cfb_encrypt decrypt error", cfb_buf2);
|
||||
}
|
||||
#endif /* !defined(LIBDES_LIT) */
|
||||
|
||||
#if !defined(LIBDES_LIT)
|
||||
static void
|
||||
ede_cfb64_test(unsigned char *cfb_cipher)
|
||||
{
|
||||
int n;
|
||||
des_key_schedule ks;
|
||||
|
||||
des_set_key_checked(&cfb_key, ks);
|
||||
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
|
||||
n = 0;
|
||||
des_ede3_cfb64_encrypt(plain, cfb_buf1, 12, ks, ks, ks, &cfb_tmp, &n,
|
||||
DES_ENCRYPT);
|
||||
des_ede3_cfb64_encrypt(&(plain[12]), &(cfb_buf1[12]),
|
||||
sizeof(plain) - 12, ks, ks, ks,
|
||||
&cfb_tmp, &n, DES_ENCRYPT);
|
||||
if (memcmp(cfb_cipher, cfb_buf1, sizeof(plain)) != 0)
|
||||
fail_cfb_buf("ede_cfb_encrypt encrypt error", cfb_buf1);
|
||||
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
|
||||
n = 0;
|
||||
des_ede3_cfb64_encrypt(cfb_buf1, cfb_buf2, (long) 17, ks, ks, ks,
|
||||
&cfb_tmp, &n, DES_DECRYPT);
|
||||
des_ede3_cfb64_encrypt(&(cfb_buf1[17]), &(cfb_buf2[17]),
|
||||
sizeof(plain) - 17, ks, ks, ks,
|
||||
&cfb_tmp, &n, DES_DECRYPT);
|
||||
if (memcmp(plain, cfb_buf2, sizeof(plain)) != 0)
|
||||
fail_cfb_buf("ede_cfb_encrypt decrypt error", cfb_buf2);
|
||||
}
|
||||
#endif /* !defined(LIBDES_LIT) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(cbcm);
|
||||
#if defined(NO_DESCBCM)
|
||||
ATF_TC_BODY(cbcm, tc)
|
||||
{
|
||||
atf_tc_skip("Test program built with NO_DESCBCM");
|
||||
}
|
||||
#else /* defined(NO_DESCBM) */
|
||||
ATF_TC_BODY(cbcm, tc)
|
||||
{
|
||||
int i, j;
|
||||
des_cblock iv3, iv2;
|
||||
unsigned char cbc_in[40], cbc_out[40];
|
||||
des_key_schedule ks, ks2, ks3;
|
||||
|
||||
if ((j = des_set_key_checked(&cbc_key, ks)) != 0) {
|
||||
atf_tc_fail_nonfatal("Key error %d\n", j);
|
||||
}
|
||||
if ((j = des_set_key_checked(&cbc2_key, ks2)) != 0) {
|
||||
atf_tc_fail_nonfatal("Key error %d\n", j);
|
||||
}
|
||||
if ((j = des_set_key_checked(&cbc3_key, ks3)) != 0) {
|
||||
atf_tc_fail_nonfatal("Key error %d\n", j);
|
||||
}
|
||||
memset(cbc_out, 0, 40);
|
||||
memset(cbc_in, 0, 40);
|
||||
i = strlen((char *) cbc_data) + 1;
|
||||
/* i=((i+7)/8)*8; */
|
||||
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
|
||||
memset(iv2, '\0', sizeof iv2);
|
||||
|
||||
des_ede3_cbcm_encrypt(cbc_data, cbc_out, 16L, ks, ks2, ks3, &iv3, &iv2,
|
||||
DES_ENCRYPT);
|
||||
des_ede3_cbcm_encrypt(&cbc_data[16], &cbc_out[16], i - 16, ks, ks2, ks3,
|
||||
&iv3, &iv2, DES_ENCRYPT);
|
||||
/*
|
||||
* if (memcmp(cbc_out,cbc3_ok, (unsigned int)(strlen((char
|
||||
* *)cbc_data)+1+7)/8*8) != 0) { printf("des_ede3_cbc_encrypt encrypt
|
||||
* error\n"); err=1; }
|
||||
*/
|
||||
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
|
||||
memset(iv2, '\0', sizeof iv2);
|
||||
des_ede3_cbcm_encrypt(cbc_out, cbc_in, i, ks, ks2, ks3, &iv3, &iv2,
|
||||
DES_DECRYPT);
|
||||
if (memcmp(cbc_in, cbc_data, strlen((char *) cbc_data) + 1) != 0) {
|
||||
char buf[1024];
|
||||
int n;
|
||||
|
||||
*buf = '\0';
|
||||
for (n = 0; n < i; ++n) {
|
||||
char buf2[16];
|
||||
snprintf(buf2, sizeof(buf2), " %02x", cbc_data[n]);
|
||||
strlcat(buf, buf2, sizeof(buf));
|
||||
}
|
||||
strlcat(buf, ", ", sizeof(buf));
|
||||
for (n = 0; n < i; ++n) {
|
||||
char buf2[16];
|
||||
snprintf(buf2, sizeof(buf2), " %02x", cbc_in[n]);
|
||||
strlcat(buf, buf2, sizeof(buf));
|
||||
}
|
||||
|
||||
atf_tc_fail_nonfatal("des_ede3_cbcm_encrypt decrypt error: %s",
|
||||
buf);
|
||||
}
|
||||
}
|
||||
#endif /* defined(NO_DESCBM) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(ecb);
|
||||
ATF_TC_BODY(ecb, tc)
|
||||
{
|
||||
int i;
|
||||
des_cblock in, out, outin;
|
||||
des_key_schedule ks;
|
||||
|
||||
for (i = 0; i < NUM_TESTS; i++) {
|
||||
des_set_key_unchecked(&key_data[i], ks);
|
||||
memcpy(in, plain_data[i], 8);
|
||||
memset(out, 0, 8);
|
||||
memset(outin, 0, 8);
|
||||
des_ecb_encrypt(&in, &out, ks, DES_ENCRYPT);
|
||||
des_ecb_encrypt(&out, &outin, ks, DES_DECRYPT);
|
||||
|
||||
if (memcmp(out, cipher_data[i], 8) != 0) {
|
||||
atf_tc_fail_nonfatal("Encryption error %2d\nk=%s p=%s "
|
||||
"o=%s act=%s\n", i + 1,
|
||||
pt(key_data[i]), pt(in),
|
||||
pt(cipher_data[i]), pt(out));
|
||||
}
|
||||
if (memcmp(in, outin, 8) != 0) {
|
||||
atf_tc_fail_nonfatal("Decryption error %2d\nk=%s p=%s "
|
||||
"o=%s act=%s\n", i + 1,
|
||||
pt(key_data[i]), pt(out), pt(in),
|
||||
pt(outin));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(ede_ecb);
|
||||
#if defined(LIBDES_LIT)
|
||||
ATF_TC_BODY(ede_ecb, tc)
|
||||
{
|
||||
atf_tc_skip("Test program built with LIBDES_LIT");
|
||||
}
|
||||
#else /* defined(LIBDES_LIT) */
|
||||
ATF_TC_BODY(ede_ecb, tc)
|
||||
{
|
||||
int i;
|
||||
des_cblock in, out, outin;
|
||||
des_key_schedule ks, ks2, ks3;
|
||||
|
||||
for (i = 0; i < (NUM_TESTS - 1); i++) {
|
||||
des_set_key_unchecked(&key_data[i], ks);
|
||||
des_set_key_unchecked(&key_data[i + 1], ks2);
|
||||
des_set_key_unchecked(&key_data[i + 2], ks3);
|
||||
memcpy(in, plain_data[i], 8);
|
||||
memset(out, 0, 8);
|
||||
memset(outin, 0, 8);
|
||||
des_ecb2_encrypt(&in, &out, ks, ks2, DES_ENCRYPT);
|
||||
des_ecb2_encrypt(&out, &outin, ks, ks2, DES_DECRYPT);
|
||||
|
||||
if (memcmp(out, cipher_ecb2[i], 8) != 0) {
|
||||
atf_tc_fail_nonfatal("Encryption error %2d\nk=%s p=%s o=%s act=%s\n",
|
||||
i + 1, pt(key_data[i]), pt(in), pt(cipher_ecb2[i]),
|
||||
pt(out));
|
||||
}
|
||||
if (memcmp(in, outin, 8) != 0) {
|
||||
atf_tc_fail_nonfatal("Decryption error %2d\nk=%s p=%s o=%s act=%s\n",
|
||||
i + 1, pt(key_data[i]), pt(out), pt(in), pt(outin));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* defined(LIBDES_LIT) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(cbc);
|
||||
ATF_TC_BODY(cbc, tc)
|
||||
{
|
||||
int j;
|
||||
des_cblock iv3;
|
||||
des_key_schedule ks;
|
||||
unsigned char cbc_in[40], cbc_out[40];
|
||||
|
||||
if ((j = des_set_key_checked(&cbc_key, ks)) != 0)
|
||||
atf_tc_fail_nonfatal("Key error %d\n", j);
|
||||
memset(cbc_out, 0, 40);
|
||||
memset(cbc_in, 0, 40);
|
||||
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
|
||||
des_ncbc_encrypt(cbc_data, cbc_out, strlen((char *) cbc_data) + 1, ks,
|
||||
&iv3, DES_ENCRYPT);
|
||||
if (memcmp(cbc_out, cbc_ok, 32) != 0)
|
||||
atf_tc_fail_nonfatal("cbc_encrypt encrypt error\n");
|
||||
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
|
||||
des_ncbc_encrypt(cbc_out, cbc_in, strlen((char *) cbc_data) + 1, ks,
|
||||
&iv3, DES_DECRYPT);
|
||||
if (memcmp(cbc_in, cbc_data, strlen((char *) cbc_data)) != 0)
|
||||
atf_tc_fail_nonfatal("cbc_encrypt decrypt error\n");
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(desx_cbc);
|
||||
#if defined(LIBDES_LIT)
|
||||
ATF_TC_BODY(desx_cbc, tc)
|
||||
{
|
||||
atf_tc_skip("Test program built with LIBDES_LIT");
|
||||
}
|
||||
#else /* defined(LIBDES_LIT) */
|
||||
ATF_TC_BODY(desx_cbc, tc)
|
||||
{
|
||||
int j;
|
||||
des_cblock iv3;
|
||||
des_key_schedule ks;
|
||||
unsigned char cbc_in[40], cbc_out[40];
|
||||
|
||||
if ((j = des_set_key_checked(&cbc_key, ks)) != 0) {
|
||||
atf_tc_fail_nonfatal("Key error %d\n", j);
|
||||
}
|
||||
memset(cbc_out, 0, 40);
|
||||
memset(cbc_in, 0, 40);
|
||||
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
|
||||
des_xcbc_encrypt(cbc_data, cbc_out, strlen((char *) cbc_data) + 1, ks,
|
||||
&iv3, &cbc2_key, &cbc3_key, DES_ENCRYPT);
|
||||
if (memcmp(cbc_out, xcbc_ok, 32) != 0) {
|
||||
atf_tc_fail_nonfatal("des_xcbc_encrypt encrypt error\n");
|
||||
}
|
||||
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
|
||||
des_xcbc_encrypt(cbc_out, cbc_in, strlen((char *) cbc_data) + 1, ks,
|
||||
&iv3, &cbc2_key, &cbc3_key, DES_DECRYPT);
|
||||
if (memcmp(cbc_in, cbc_data, strlen((char *) cbc_data) + 1) != 0) {
|
||||
atf_tc_fail_nonfatal("des_xcbc_encrypt decrypt error\n");
|
||||
}
|
||||
}
|
||||
#endif /* defined(LIBDES_LIT) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(ede_cbc);
|
||||
ATF_TC_BODY(ede_cbc, tc)
|
||||
{
|
||||
int i, j;
|
||||
des_cblock iv3;
|
||||
des_key_schedule ks, ks2, ks3;
|
||||
unsigned char cbc_in[40], cbc_out[40];
|
||||
|
||||
if ((j = des_set_key_checked(&cbc_key, ks)) != 0)
|
||||
atf_tc_fail_nonfatal("Key error %d\n", j);
|
||||
if ((j = des_set_key_checked(&cbc2_key, ks2)) != 0)
|
||||
atf_tc_fail_nonfatal("Key error %d\n", j);
|
||||
if ((j = des_set_key_checked(&cbc3_key, ks3)) != 0)
|
||||
atf_tc_fail_nonfatal("Key error %d\n", j);
|
||||
memset(cbc_out, 0, 40);
|
||||
memset(cbc_in, 0, 40);
|
||||
i = strlen((char *) cbc_data) + 1;
|
||||
/* i=((i+7)/8)*8; */
|
||||
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
|
||||
|
||||
des_ede3_cbc_encrypt(cbc_data, cbc_out, 16L, ks, ks2, ks3, &iv3,
|
||||
DES_ENCRYPT);
|
||||
des_ede3_cbc_encrypt(&(cbc_data[16]), &(cbc_out[16]), i - 16, ks, ks2,
|
||||
ks3, &iv3, DES_ENCRYPT);
|
||||
if (memcmp(cbc_out, cbc3_ok, (unsigned int)
|
||||
(strlen((char *) cbc_data) + 1 + 7) / 8 * 8) != 0)
|
||||
atf_tc_fail_nonfatal("des_ede3_cbc_encrypt encrypt error\n");
|
||||
memcpy(iv3, cbc_iv, sizeof(cbc_iv));
|
||||
des_ede3_cbc_encrypt(cbc_out, cbc_in, i, ks, ks2, ks3, &iv3,
|
||||
DES_DECRYPT);
|
||||
if (memcmp(cbc_in, cbc_data, strlen((char *) cbc_data) + 1) != 0)
|
||||
atf_tc_fail_nonfatal("des_ede3_cbc_encrypt decrypt error\n");
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(pcbc);
|
||||
#if defined(LIBDES_LIT)
|
||||
ATF_TC_BODY(pcbc, tc)
|
||||
{
|
||||
atf_tc_skip("Test program built with LIBDES_LIT");
|
||||
}
|
||||
#else /* defined(LIBDES_LIT) */
|
||||
ATF_TC_BODY(pcbc, tc)
|
||||
{
|
||||
int j;
|
||||
unsigned char cbc_in[40], cbc_out[40];
|
||||
des_key_schedule ks;
|
||||
|
||||
if ((j = des_set_key_checked(&cbc_key, ks)) != 0) {
|
||||
atf_tc_fail_nonfatal("Key error %d\n", j);
|
||||
}
|
||||
memset(cbc_out, 0, 40);
|
||||
memset(cbc_in, 0, 40);
|
||||
des_pcbc_encrypt(cbc_data, cbc_out, strlen((char *) cbc_data) + 1, ks,
|
||||
&cbc_iv, DES_ENCRYPT);
|
||||
if (memcmp(cbc_out, pcbc_ok, 32) != 0) {
|
||||
atf_tc_fail_nonfatal("pcbc_encrypt encrypt error\n");
|
||||
}
|
||||
des_pcbc_encrypt(cbc_out, cbc_in, strlen((char *) cbc_data) + 1, ks, &cbc_iv,
|
||||
DES_DECRYPT);
|
||||
if (memcmp(cbc_in, cbc_data, strlen((char *) cbc_data) + 1) != 0) {
|
||||
atf_tc_fail_nonfatal("pcbc_encrypt decrypt error\n");
|
||||
}
|
||||
}
|
||||
#endif /* defined(LIBDES_LIT) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(cfb);
|
||||
#if defined(LIBDES_LIT)
|
||||
ATF_TC_BODY(cfb, tc)
|
||||
{
|
||||
atf_tc_skip("Test program built with LIBDES_LIT");
|
||||
}
|
||||
#else /* defined(LIBDES_LIT) */
|
||||
ATF_TC_BODY(cfb, tc)
|
||||
{
|
||||
size_t i;
|
||||
des_key_schedule ks;
|
||||
|
||||
printf("cfb8\n");
|
||||
cfb_test(8, cfb_cipher8);
|
||||
printf("cfb16\n");
|
||||
cfb_test(16, cfb_cipher16);
|
||||
printf("cfb32\n");
|
||||
cfb_test(32, cfb_cipher32);
|
||||
printf("cfb48\n");
|
||||
cfb_test(48, cfb_cipher48);
|
||||
printf("cfb64\n");
|
||||
cfb_test(64, cfb_cipher64);
|
||||
|
||||
printf("cfb64()\n");
|
||||
cfb64_test(cfb_cipher64);
|
||||
|
||||
des_set_key_checked(&cfb_key, ks);
|
||||
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
|
||||
for (i = 0; i < sizeof(plain); i++)
|
||||
des_cfb_encrypt(&(plain[i]), &(cfb_buf1[i]),
|
||||
8, 1, ks, &cfb_tmp, DES_ENCRYPT);
|
||||
if (memcmp(cfb_cipher8, cfb_buf1, sizeof(plain)) != 0)
|
||||
atf_tc_fail_nonfatal("cfb_encrypt small encrypt error\n");
|
||||
memcpy(cfb_tmp, cfb_iv, sizeof(cfb_iv));
|
||||
for (i = 0; i < sizeof(plain); i++)
|
||||
des_cfb_encrypt(&(cfb_buf1[i]), &(cfb_buf2[i]),
|
||||
8, 1, ks, &cfb_tmp, DES_DECRYPT);
|
||||
if (memcmp(plain, cfb_buf2, sizeof(plain)) != 0)
|
||||
atf_tc_fail_nonfatal("cfb_encrypt small decrypt error\n");
|
||||
printf("ede_cfb64()\n");
|
||||
ede_cfb64_test(cfb_cipher64);
|
||||
}
|
||||
#endif /* defined(LIBDES_LIT) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(ofb);
|
||||
#if defined(LIBDES_LIT)
|
||||
ATF_TC_BODY(ofb, tc)
|
||||
{
|
||||
atf_tc_skip("Test program built with LIBDES_LIT");
|
||||
}
|
||||
#else /* defined(LIBDES_LIT) */
|
||||
ATF_TC_BODY(ofb, tc)
|
||||
{
|
||||
des_key_schedule ks;
|
||||
|
||||
des_set_key_checked(&ofb_key, ks);
|
||||
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
|
||||
des_ofb_encrypt(plain, ofb_buf1, 64, sizeof(plain) / 8, ks, &ofb_tmp);
|
||||
if (memcmp(ofb_cipher, ofb_buf1, sizeof(ofb_buf1)) != 0) {
|
||||
atf_tc_fail_nonfatal("ofb_encrypt encrypt error: "
|
||||
"%02X %02X %02X %02X %02X %02X %02X %02X, "
|
||||
"%02X %02X %02X %02X %02X %02X %02X %02X",
|
||||
ofb_buf1[8 + 0], ofb_buf1[8 + 1],
|
||||
ofb_buf1[8 + 2], ofb_buf1[8 + 3],
|
||||
ofb_buf1[8 + 4], ofb_buf1[8 + 5],
|
||||
ofb_buf1[8 + 6], ofb_buf1[8 + 7],
|
||||
ofb_buf1[8 + 0], ofb_cipher[8 + 1],
|
||||
ofb_cipher[8 + 2], ofb_cipher[8 + 3],
|
||||
ofb_buf1[8 + 4], ofb_cipher[8 + 5],
|
||||
ofb_cipher[8 + 6], ofb_cipher[8 + 7]);
|
||||
}
|
||||
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
|
||||
des_ofb_encrypt(ofb_buf1, ofb_buf2, 64, sizeof(ofb_buf1) / 8, ks,
|
||||
&ofb_tmp);
|
||||
if (memcmp(plain, ofb_buf2, sizeof(ofb_buf2)) != 0) {
|
||||
atf_tc_fail_nonfatal("ofb_encrypt decrypt error: "
|
||||
"%02X %02X %02X %02X %02X %02X %02X %02X, "
|
||||
"%02X %02X %02X %02X %02X %02X %02X %02X",
|
||||
ofb_buf2[8 + 0], ofb_buf2[8 + 1],
|
||||
ofb_buf2[8 + 2], ofb_buf2[8 + 3],
|
||||
ofb_buf2[8 + 4], ofb_buf2[8 + 5],
|
||||
ofb_buf2[8 + 6], ofb_buf2[8 + 7],
|
||||
plain[8 + 0], plain[8 + 1],
|
||||
plain[8 + 2], plain[8 + 3],
|
||||
plain[8 + 4], plain[8 + 5],
|
||||
plain[8 + 6], plain[8 + 7]);
|
||||
}
|
||||
}
|
||||
#endif /* defined(LIBDES_LIT) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(ofb64);
|
||||
#if defined(LIBDES_LIT)
|
||||
ATF_TC_BODY(ofb64, tc)
|
||||
{
|
||||
atf_tc_skip("Test program built with LIBDES_LIT");
|
||||
}
|
||||
#else /* defined(LIBDES_LIT) */
|
||||
ATF_TC_BODY(ofb64, tc)
|
||||
{
|
||||
int num;
|
||||
size_t i;
|
||||
des_key_schedule ks;
|
||||
|
||||
des_set_key_checked(&ofb_key, ks);
|
||||
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
|
||||
memset(ofb_buf1, 0, sizeof(ofb_buf1));
|
||||
memset(ofb_buf2, 0, sizeof(ofb_buf1));
|
||||
num = 0;
|
||||
for (i = 0; i < sizeof(plain); i++) {
|
||||
des_ofb64_encrypt(&(plain[i]), &(ofb_buf1[i]), 1, ks, &ofb_tmp,
|
||||
&num);
|
||||
}
|
||||
if (memcmp(ofb_cipher, ofb_buf1, sizeof(ofb_buf1)) != 0) {
|
||||
atf_tc_fail_nonfatal("ofb64_encrypt encrypt error\n");
|
||||
}
|
||||
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
|
||||
num = 0;
|
||||
des_ofb64_encrypt(ofb_buf1, ofb_buf2, sizeof(ofb_buf1), ks, &ofb_tmp, &num);
|
||||
if (memcmp(plain, ofb_buf2, sizeof(ofb_buf2)) != 0) {
|
||||
atf_tc_fail_nonfatal("ofb64_encrypt decrypt error\n");
|
||||
}
|
||||
}
|
||||
#endif /* defined(LIBDES_LIT) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(ede_ofb64);
|
||||
#if defined(LIBDES_LIT)
|
||||
ATF_TC_BODY(ede_ofb64, tc)
|
||||
{
|
||||
atf_tc_skip("Test program built with LIBDES_LIT");
|
||||
}
|
||||
#else /* defined(LIBDES_LIT) */
|
||||
ATF_TC_BODY(ede_ofb64, tc)
|
||||
{
|
||||
int num;
|
||||
size_t i;
|
||||
des_key_schedule ks;
|
||||
|
||||
des_set_key_checked(&ofb_key, ks);
|
||||
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
|
||||
memset(ofb_buf1, 0, sizeof(ofb_buf1));
|
||||
memset(ofb_buf2, 0, sizeof(ofb_buf1));
|
||||
num = 0;
|
||||
for (i = 0; i < sizeof(plain); i++) {
|
||||
des_ede3_ofb64_encrypt(&(plain[i]), &(ofb_buf1[i]), 1, ks, ks, ks,
|
||||
&ofb_tmp, &num);
|
||||
}
|
||||
if (memcmp(ofb_cipher, ofb_buf1, sizeof(ofb_buf1)) != 0) {
|
||||
atf_tc_fail_nonfatal("ede_ofb64_encrypt encrypt error\n");
|
||||
}
|
||||
memcpy(ofb_tmp, ofb_iv, sizeof(ofb_iv));
|
||||
num = 0;
|
||||
des_ede3_ofb64_encrypt(ofb_buf1, ofb_buf2, sizeof(ofb_buf1), ks,
|
||||
ks, ks, &ofb_tmp, &num);
|
||||
if (memcmp(plain, ofb_buf2, sizeof(ofb_buf2)) != 0) {
|
||||
atf_tc_fail_nonfatal("ede_ofb64_encrypt decrypt error\n");
|
||||
}
|
||||
}
|
||||
#endif /* defined(LIBDES_LIT) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(cbc_cksum);
|
||||
#if defined(LIBDES_LIT)
|
||||
ATF_TC_BODY(cbc_cksum, tc)
|
||||
{
|
||||
atf_tc_skip("Test program built with LIBDES_LIT");
|
||||
}
|
||||
#else /* defined(LIBDES_LIT) */
|
||||
ATF_TC_BODY(cbc_cksum, tc)
|
||||
{
|
||||
unsigned char cret[8];
|
||||
des_key_schedule ks;
|
||||
DES_LONG cs;
|
||||
|
||||
des_set_key_checked(&cbc_key, ks);
|
||||
cs = des_cbc_cksum(cbc_data, &cret, strlen((char *) cbc_data), ks, &cbc_iv);
|
||||
if (cs != cbc_cksum_ret) {
|
||||
atf_tc_fail_nonfatal("bad return value (%08lX), should be %08lX\n",
|
||||
(unsigned long) cs, (unsigned long) cbc_cksum_ret);
|
||||
}
|
||||
if (memcmp(cret, cbc_cksum_data, 8) != 0) {
|
||||
atf_tc_fail_nonfatal("bad cbc_cksum block returned\n");
|
||||
}
|
||||
}
|
||||
#endif /* defined(LIBDES_LIT) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(quad_cksum);
|
||||
#if defined(LIBDES_LIT)
|
||||
ATF_TC_BODY(quad_cksum, tc)
|
||||
{
|
||||
atf_tc_skip("Test program built with LIBDES_LIT");
|
||||
}
|
||||
#else /* defined(LIBDES_LIT) */
|
||||
ATF_TC_BODY(quad_cksum, tc)
|
||||
{
|
||||
DES_LONG cs, lqret[4];
|
||||
|
||||
cs = quad_cksum(cbc_data, (des_cblock *) lqret,
|
||||
(long) strlen((char *) cbc_data), 2, (des_cblock *) cbc_iv);
|
||||
if (cs != 0x70d7a63aL) {
|
||||
atf_tc_fail_nonfatal("quad_cksum error, ret %08lx should be 70d7a63a\n",
|
||||
(unsigned long) cs);
|
||||
}
|
||||
if (lqret[0] != 0x327eba8dL) {
|
||||
atf_tc_fail_nonfatal("quad_cksum error, out[0] %08lx is not %08lx\n",
|
||||
(unsigned long) lqret[0], 0x327eba8dUL);
|
||||
}
|
||||
if (lqret[1] != 0x201a49ccL) {
|
||||
atf_tc_fail_nonfatal("quad_cksum error, out[1] %08lx is not %08lx\n",
|
||||
(unsigned long) lqret[1], 0x201a49ccUL);
|
||||
}
|
||||
if (lqret[2] != 0x70d7a63aL) {
|
||||
atf_tc_fail_nonfatal("quad_cksum error, out[2] %08lx is not %08lx\n",
|
||||
(unsigned long) lqret[2], 0x70d7a63aUL);
|
||||
}
|
||||
if (lqret[3] != 0x501c2c26L) {
|
||||
atf_tc_fail_nonfatal("quad_cksum error, out[3] %08lx is not %08lx\n",
|
||||
(unsigned long) lqret[3], 0x501c2c26UL);
|
||||
}
|
||||
}
|
||||
#endif /* defined(LIBDES_LIT) */
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(align);
|
||||
ATF_TC_BODY(align, tc)
|
||||
{
|
||||
int i;
|
||||
unsigned char cbc_in[40], cbc_out[40];
|
||||
des_key_schedule ks;
|
||||
|
||||
printf("input word alignment test");
|
||||
for (i = 0; i < 4; i++) {
|
||||
printf(" %d", i);
|
||||
des_ncbc_encrypt(&(cbc_out[i]), cbc_in,
|
||||
strlen((char *) cbc_data) + 1, ks,
|
||||
&cbc_iv, DES_ENCRYPT);
|
||||
}
|
||||
|
||||
printf("\noutput word alignment test");
|
||||
for (i = 0; i < 4; i++) {
|
||||
printf(" %d", i);
|
||||
des_ncbc_encrypt(cbc_out, &(cbc_in[i]),
|
||||
strlen((char *) cbc_data) + 1, ks,
|
||||
&cbc_iv, DES_ENCRYPT);
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(fast_crypt);
|
||||
ATF_TC_BODY(fast_crypt, tc)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = crypt("testing", "ef");
|
||||
if (strcmp("efGnQx2725bI2", str) != 0)
|
||||
atf_tc_fail_nonfatal("fast crypt error, %s should be efGnQx2725bI2\n", str);
|
||||
str = crypt("bca76;23", "yA");
|
||||
if (strcmp("yA1Rp/1hZXIJk", str) != 0)
|
||||
atf_tc_fail_nonfatal("fast crypt error, %s should be yA1Rp/1hZXIJk\n", str);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
ATF_TP_ADD_TC(tp, cbcm);
|
||||
ATF_TP_ADD_TC(tp, ecb);
|
||||
ATF_TP_ADD_TC(tp, ede_ecb);
|
||||
ATF_TP_ADD_TC(tp, cbc);
|
||||
ATF_TP_ADD_TC(tp, desx_cbc);
|
||||
ATF_TP_ADD_TC(tp, ede_cbc);
|
||||
ATF_TP_ADD_TC(tp, pcbc);
|
||||
ATF_TP_ADD_TC(tp, cfb);
|
||||
ATF_TP_ADD_TC(tp, ofb);
|
||||
ATF_TP_ADD_TC(tp, ofb64);
|
||||
ATF_TP_ADD_TC(tp, ede_ofb64);
|
||||
ATF_TP_ADD_TC(tp, cbc_cksum);
|
||||
ATF_TP_ADD_TC(tp, quad_cksum);
|
||||
ATF_TP_ADD_TC(tp, align);
|
||||
ATF_TP_ADD_TC(tp, fast_crypt);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.2 2013/04/11 17:00:12 christos Exp $
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/libevent
|
||||
|
||||
TESTS_SH= t_event
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include <../../../external/bsd/libevent/Makefile.inc>
|
||||
|
||||
.PATH: ${LIBEVENT_DIST}/test
|
||||
|
||||
BINDIR= ${TESTSDIR}
|
||||
|
||||
PROG= h_event
|
||||
MAN= # defined
|
||||
#__MINIX: Not Supported: regress_thread.c
|
||||
SRCS= regress.c regress.gen.c regress_dns.c regress_http.c \
|
||||
regress_rpc.c regress_main.c tinytest.c regress_testutils.c \
|
||||
regress_minheap.c regress_util.c \
|
||||
regress_buffer.c regress_bufferevent.c regress_listener.c \
|
||||
regress_zlib.c regress_et.c
|
||||
|
||||
.if ${MKCRYPTO} == "yes"
|
||||
SRCS+= regress_ssl.c
|
||||
DPADD+= ${LIBEVENT_OPENSSL} ${LIBSSL} ${LIBCRYPTO}
|
||||
LDADD+= -levent_openssl -lssl -lcrypto
|
||||
CPPFLAGS+= -DLIBEVENT_CRYPTO
|
||||
.endif
|
||||
.if !defined(__MINIX)
|
||||
DPADD+= ${LIBEVENT} ${LIBEVENT_PTHREADS} ${LIBZ} ${LIBPTHREAD}
|
||||
LDADD+= -levent_pthreads -levent -lz -lpthread
|
||||
.else
|
||||
DPADD+= ${LIBEVENT} ${LIBZ}
|
||||
LDADD+= -levent -lz
|
||||
.endif # !defined(__MINIX)
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
# $NetBSD: t_event.sh,v 1.3 2010/11/29 18:21:15 pgoyette Exp $
|
||||
#
|
||||
# Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
#
|
||||
# This is not great but rather than reimplementing the libevent
|
||||
# provided regression tests, we use an ATF wrapper around the test
|
||||
# program which carries out all the tests and prints an extensive
|
||||
# report.
|
||||
#
|
||||
|
||||
atf_test_case kqueue
|
||||
kqueue_head() {
|
||||
atf_set "descr" "Test libevent with kqueue backend"
|
||||
}
|
||||
kqueue_body() {
|
||||
EVENT_NOPOLL=1 EVENT_NOSELECT=1 \
|
||||
$(atf_get_srcdir)/h_event 2>&1 || atf_fail "check report"
|
||||
}
|
||||
|
||||
atf_test_case poll
|
||||
poll_head() {
|
||||
atf_set "descr" "Test libevent with poll backend"
|
||||
}
|
||||
poll_body() {
|
||||
EVENT_NOKQUEUE=1 EVENT_NOSELECT=1 \
|
||||
$(atf_get_srcdir)/h_event 2>&1 || atf_fail "check report"
|
||||
}
|
||||
|
||||
atf_test_case select
|
||||
select_head() {
|
||||
atf_set "descr" "Test libevent with select backend"
|
||||
}
|
||||
select_body() {
|
||||
EVENT_NOKQUEUE=1 EVENT_NOPOLL=1 \
|
||||
$(atf_get_srcdir)/h_event 2>&1 || atf_fail "check report"
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case kqueue
|
||||
atf_add_test_case poll
|
||||
atf_add_test_case select
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.2 2011/05/20 13:03:45 joerg Exp $
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/libobjc
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
UNSUPPORTED_COMPILER.clang= # defined
|
||||
UNSUPPORTED_COMPILER.pcc= # defined
|
||||
|
||||
.if !empty(AVAILABLE_COMPILER:Mgcc)
|
||||
TESTS_C= t_threads
|
||||
.endif
|
||||
|
||||
SRCS.t_threads= t_threads.m
|
||||
WARNS?= 4
|
||||
CFLAGS+= -pthread
|
||||
LDFLAGS+= -pthread
|
||||
DPADD+= ${LIBOBJC}
|
||||
LDADD+= -lobjc
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
/* $NetBSD: t_threads.m,v 1.2 2013/10/31 21:02:11 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Originally written by David Wetzel */
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <objc/objc.h>
|
||||
#include <objc/thr.h>
|
||||
#include <objc/Object.h>
|
||||
#if __GNUC_PREREQ__(4,8)
|
||||
#include <objc/runtime.h>
|
||||
#endif
|
||||
|
||||
static int IsMultithreaded = 0;
|
||||
static objc_mutex_t Mutex;
|
||||
static objc_condition_t Condition;
|
||||
|
||||
@interface MyClass : Object
|
||||
{
|
||||
}
|
||||
-(void)start;
|
||||
#if __GNUC_PREREQ__(4,8)
|
||||
-init;
|
||||
+new;
|
||||
+alloc;
|
||||
-free;
|
||||
#endif
|
||||
@end
|
||||
|
||||
@implementation MyClass
|
||||
-(void)start
|
||||
{
|
||||
printf("detached thread started!\n");
|
||||
|
||||
objc_condition_signal(Condition);
|
||||
}
|
||||
#if __GNUC_PREREQ__(4,8)
|
||||
-init
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
+new
|
||||
{
|
||||
return [[self alloc] init];
|
||||
}
|
||||
|
||||
+alloc
|
||||
{
|
||||
return class_createInstance(self, 0);
|
||||
}
|
||||
|
||||
-free
|
||||
{
|
||||
return object_dispose(self);
|
||||
}
|
||||
#endif
|
||||
@end
|
||||
|
||||
static void
|
||||
becomeMultiThreaded(void)
|
||||
{
|
||||
printf("becoming multithreaded!\n");
|
||||
IsMultithreaded++;
|
||||
}
|
||||
|
||||
ATF_TC(thread_callback);
|
||||
ATF_TC_HEAD(thread_callback, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Checks that the thread callback is only"
|
||||
"called once");
|
||||
}
|
||||
ATF_TC_BODY(thread_callback, tc)
|
||||
{
|
||||
id o = [MyClass new];
|
||||
objc_thread_callback cb;
|
||||
objc_thread_t rv;
|
||||
|
||||
cb = objc_set_thread_callback(becomeMultiThreaded);
|
||||
printf("Old Callback: %p\n", cb);
|
||||
ATF_CHECK(cb == 0);
|
||||
|
||||
Mutex = objc_mutex_allocate();
|
||||
Condition = objc_condition_allocate();
|
||||
|
||||
ATF_CHECK_EQ(0, IsMultithreaded);
|
||||
|
||||
rv = objc_thread_detach(@selector(start), o, nil);
|
||||
printf("detach value: %p\n", rv);
|
||||
assert(rv != NULL);
|
||||
|
||||
objc_mutex_lock(Mutex);
|
||||
objc_condition_wait(Condition, Mutex);
|
||||
objc_mutex_unlock(Mutex);
|
||||
|
||||
ATF_CHECK_EQ(1, IsMultithreaded);
|
||||
printf("Shutting down\n");
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
ATF_TP_ADD_TC(tp, thread_callback);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.1 2010/07/16 13:56:31 jmmv Exp $
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/libprop
|
||||
|
||||
LDADD+= -lprop
|
||||
|
||||
TESTS_C= t_basic
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,203 +0,0 @@
|
|||
/* $NetBSD: t_basic.c,v 1.4 2011/04/20 20:02:58 martin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Written by Jason Thorpe 5/26/2006.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__COPYRIGHT("@(#) Copyright (c) 2008\
|
||||
The NetBSD Foundation, inc. All rights reserved.");
|
||||
__RCSID("$NetBSD: t_basic.c,v 1.4 2011/04/20 20:02:58 martin Exp $");
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <prop/proplib.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
static const char compare1[] =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
"<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||
"<plist version=\"1.0\">\n"
|
||||
"<dict>\n"
|
||||
" <key>false-val</key>\n"
|
||||
" <false/>\n"
|
||||
" <key>one</key>\n"
|
||||
" <integer>1</integer>\n"
|
||||
" <key>three</key>\n"
|
||||
" <array>\n"
|
||||
" <dict>\n"
|
||||
" <key>one</key>\n"
|
||||
" <integer>1</integer>\n"
|
||||
" <key>two</key>\n"
|
||||
" <string>number-two</string>\n"
|
||||
" </dict>\n"
|
||||
" <dict>\n"
|
||||
" <key>one</key>\n"
|
||||
" <integer>1</integer>\n"
|
||||
" <key>two</key>\n"
|
||||
" <string>number-two</string>\n"
|
||||
" </dict>\n"
|
||||
" <dict>\n"
|
||||
" <key>one</key>\n"
|
||||
" <integer>1</integer>\n"
|
||||
" <key>two</key>\n"
|
||||
" <string>number-two</string>\n"
|
||||
" </dict>\n"
|
||||
" </array>\n"
|
||||
" <key>true-val</key>\n"
|
||||
" <true/>\n"
|
||||
" <key>two</key>\n"
|
||||
" <string>number-two</string>\n"
|
||||
"</dict>\n"
|
||||
"</plist>\n";
|
||||
|
||||
ATF_TC(prop_basic);
|
||||
ATF_TC_HEAD(prop_basic, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "A basic test of proplib(3)");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(prop_basic, tc)
|
||||
{
|
||||
prop_dictionary_t dict;
|
||||
char *ext1;
|
||||
|
||||
dict = prop_dictionary_create();
|
||||
ATF_REQUIRE(dict != NULL);
|
||||
|
||||
{
|
||||
prop_number_t num = prop_number_create_integer(1);
|
||||
ATF_REQUIRE(num != NULL);
|
||||
|
||||
ATF_REQUIRE_EQ(prop_dictionary_set(dict, "one", num), true);
|
||||
prop_object_release(num);
|
||||
}
|
||||
|
||||
{
|
||||
prop_string_t str = prop_string_create_cstring("number-two");
|
||||
ATF_REQUIRE(str != NULL);
|
||||
|
||||
ATF_REQUIRE_EQ(prop_dictionary_set(dict, "two", str), true);
|
||||
prop_object_release(str);
|
||||
}
|
||||
|
||||
{
|
||||
prop_array_t arr;
|
||||
prop_dictionary_t dict_copy;
|
||||
int i;
|
||||
|
||||
arr = prop_array_create();
|
||||
ATF_REQUIRE(arr != NULL);
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
dict_copy = prop_dictionary_copy(dict);
|
||||
ATF_REQUIRE(dict_copy != NULL);
|
||||
ATF_REQUIRE_EQ(prop_array_add(arr, dict_copy), true);
|
||||
prop_object_release(dict_copy);
|
||||
}
|
||||
|
||||
ATF_REQUIRE_EQ(prop_dictionary_set(dict, "three", arr), true);
|
||||
prop_object_release(arr);
|
||||
}
|
||||
|
||||
{
|
||||
prop_bool_t val = prop_bool_create(true);
|
||||
ATF_REQUIRE(val != NULL);
|
||||
ATF_REQUIRE_EQ(prop_dictionary_set(dict, "true-val", val), true);
|
||||
prop_object_release(val);
|
||||
|
||||
val = prop_bool_create(false);
|
||||
ATF_REQUIRE(val != NULL);
|
||||
ATF_REQUIRE_EQ(prop_dictionary_set(dict, "false-val", val), true);
|
||||
prop_object_release(val);
|
||||
}
|
||||
|
||||
ext1 = prop_dictionary_externalize(dict);
|
||||
ATF_REQUIRE(ext1 != NULL);
|
||||
ATF_REQUIRE_STREQ(compare1, ext1);
|
||||
|
||||
{
|
||||
prop_dictionary_t dict2;
|
||||
char *ext2;
|
||||
|
||||
dict2 = prop_dictionary_internalize(ext1);
|
||||
ATF_REQUIRE(dict2 != NULL);
|
||||
ext2 = prop_dictionary_externalize(dict2);
|
||||
ATF_REQUIRE(ext2 != NULL);
|
||||
ATF_REQUIRE_STREQ(ext1, ext2);
|
||||
prop_object_release(dict2);
|
||||
free(ext2);
|
||||
}
|
||||
|
||||
prop_object_release(dict);
|
||||
free(ext1);
|
||||
}
|
||||
|
||||
ATF_TC(prop_dictionary_equals);
|
||||
ATF_TC_HEAD(prop_dictionary_equals, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Test prop_dictionary_equals(3)");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(prop_dictionary_equals, tc)
|
||||
{
|
||||
prop_dictionary_t c, d;
|
||||
|
||||
/*
|
||||
* Fixed, should not fail any more...
|
||||
*
|
||||
atf_tc_expect_death("PR lib/43964");
|
||||
*
|
||||
*/
|
||||
|
||||
d = prop_dictionary_internalize(compare1);
|
||||
|
||||
ATF_REQUIRE(d != NULL);
|
||||
|
||||
c = prop_dictionary_copy(d);
|
||||
|
||||
ATF_REQUIRE(c != NULL);
|
||||
|
||||
if (prop_dictionary_equals(c, d) != true)
|
||||
atf_tc_fail("dictionaries are not equal");
|
||||
|
||||
prop_object_release(c);
|
||||
prop_object_release(d);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
|
||||
ATF_TP_ADD_TC(tp, prop_basic);
|
||||
ATF_TP_ADD_TC(tp, prop_dictionary_equals);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.4 2015/06/22 00:05:23 matt Exp $
|
||||
#
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.if (${MKRUMP} != "no") && !defined(BSD_MK_COMPAT_FILE)
|
||||
TESTS_SUBDIRS= pthread
|
||||
.endif
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/semaphore
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.3 2014/06/10 04:28:39 he Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/lib/semaphore/pthread
|
||||
|
||||
TESTS_C= t_sem_pth
|
||||
|
||||
CPPFLAGS+= -I${.CURDIR}/..
|
||||
|
||||
LDADD+= -lrump -lrumpuser -lrump -lpthread
|
||||
|
||||
WARNS= 4
|
||||
|
||||
.include <bsd.test.mk>
|
||||
|
|
@ -1,332 +0,0 @@
|
|||
/* $NetBSD: sem.c,v 1.10 2012/03/09 14:25:34 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Common code for semaphore tests. This can be included both into
|
||||
* programs using librt and libpthread.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <rump/rump.h>
|
||||
#include <rump/rump_syscalls.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <sched.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../../h_macros.h"
|
||||
|
||||
ATF_TC(postwait);
|
||||
ATF_TC_HEAD(postwait, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "tests post and wait from a "
|
||||
"single thread (%s)", LIBNAME);
|
||||
}
|
||||
|
||||
ATF_TC_BODY(postwait, tc)
|
||||
{
|
||||
sem_t sem;
|
||||
int rv;
|
||||
|
||||
rump_init();
|
||||
|
||||
ATF_REQUIRE_EQ(sem_init(&sem, 1, 0), 0);
|
||||
|
||||
sem_post(&sem);
|
||||
sem_post(&sem);
|
||||
|
||||
sem_wait(&sem);
|
||||
sem_wait(&sem);
|
||||
rv = sem_trywait(&sem);
|
||||
ATF_REQUIRE(errno == EAGAIN);
|
||||
ATF_REQUIRE(rv == -1);
|
||||
}
|
||||
|
||||
ATF_TC(initvalue);
|
||||
ATF_TC_HEAD(initvalue, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "tests initialization with a non-zero "
|
||||
"value (%s)", LIBNAME);
|
||||
}
|
||||
|
||||
ATF_TC_BODY(initvalue, tc)
|
||||
{
|
||||
sem_t sem;
|
||||
|
||||
rump_init();
|
||||
sem_init(&sem, 1, 4);
|
||||
|
||||
ATF_REQUIRE_EQ(sem_trywait(&sem), 0);
|
||||
ATF_REQUIRE_EQ(sem_trywait(&sem), 0);
|
||||
ATF_REQUIRE_EQ(sem_trywait(&sem), 0);
|
||||
ATF_REQUIRE_EQ(sem_trywait(&sem), 0);
|
||||
ATF_REQUIRE_EQ(sem_trywait(&sem), -1);
|
||||
}
|
||||
|
||||
ATF_TC(destroy);
|
||||
ATF_TC_HEAD(destroy, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "tests sem_destroy works (%s)", LIBNAME);
|
||||
}
|
||||
|
||||
ATF_TC_BODY(destroy, tc)
|
||||
{
|
||||
sem_t sem;
|
||||
int rv, i;
|
||||
|
||||
rump_init();
|
||||
for (i = 0; i < 2; i++) {
|
||||
sem_init(&sem, 1, 1);
|
||||
|
||||
ATF_REQUIRE_EQ(sem_trywait(&sem), 0);
|
||||
ATF_REQUIRE_EQ(sem_trywait(&sem), -1);
|
||||
ATF_REQUIRE_EQ(sem_destroy(&sem), 0);
|
||||
rv = sem_trywait(&sem);
|
||||
ATF_REQUIRE_EQ(errno, EINVAL);
|
||||
ATF_REQUIRE_EQ(rv, -1);
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TC(busydestroy);
|
||||
ATF_TC_HEAD(busydestroy, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "tests sem_destroy report EBUSY for "
|
||||
"a busy semaphore (%s)", LIBNAME);
|
||||
}
|
||||
|
||||
static void *
|
||||
hthread(void *arg)
|
||||
{
|
||||
sem_t *semmarit = arg;
|
||||
|
||||
for (;;) {
|
||||
sem_post(&semmarit[2]);
|
||||
sem_wait(&semmarit[1]);
|
||||
sem_wait(&semmarit[0]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ATF_TC_BODY(busydestroy, tc)
|
||||
{
|
||||
sem_t semmarit[3];
|
||||
pthread_t pt;
|
||||
int i;
|
||||
|
||||
/* use a unicpu rump kernel. this means less chance for race */
|
||||
setenv("RUMP_NCPU", "1", 1);
|
||||
|
||||
rump_init();
|
||||
sem_init(&semmarit[0], 1, 0);
|
||||
sem_init(&semmarit[1], 1, 0);
|
||||
sem_init(&semmarit[2], 1, 0);
|
||||
|
||||
pthread_create(&pt, NULL, hthread, semmarit);
|
||||
|
||||
/*
|
||||
* Make a best-effort to catch the other thread with its pants down.
|
||||
* We can't do this for sure, can we? Although, we could reach
|
||||
* inside the rump kernel and inquire about the thread's sleep
|
||||
* status.
|
||||
*/
|
||||
for (i = 0; i < 1000; i++) {
|
||||
sem_wait(&semmarit[2]);
|
||||
usleep(1);
|
||||
if (sem_destroy(&semmarit[1]) == -1)
|
||||
if (errno == EBUSY)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Didn't catch it? ok, recreate and post to make the
|
||||
* other thread run
|
||||
*/
|
||||
sem_init(&semmarit[1], 1, 0);
|
||||
sem_post(&semmarit[0]);
|
||||
sem_post(&semmarit[1]);
|
||||
|
||||
}
|
||||
if (i == 1000)
|
||||
atf_tc_fail("sem destroy not reporting EBUSY");
|
||||
|
||||
pthread_cancel(pt);
|
||||
pthread_join(pt, NULL);
|
||||
}
|
||||
|
||||
ATF_TC(blockwait);
|
||||
ATF_TC_HEAD(blockwait, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "tests sem_wait can handle blocking "
|
||||
"(%s)", LIBNAME);
|
||||
atf_tc_set_md_var(tc, "timeout", "2");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(blockwait, tc)
|
||||
{
|
||||
sem_t semmarit[3];
|
||||
pthread_t pt;
|
||||
int i;
|
||||
|
||||
rump_init();
|
||||
sem_init(&semmarit[0], 1, 0);
|
||||
sem_init(&semmarit[1], 1, 0);
|
||||
sem_init(&semmarit[2], 1, 0);
|
||||
|
||||
pthread_create(&pt, NULL, hthread, semmarit);
|
||||
|
||||
/*
|
||||
* Make a best-effort. Unless we're extremely unlucky, we should
|
||||
* at least one blocking wait.
|
||||
*/
|
||||
for (i = 0; i < 10; i++) {
|
||||
sem_wait(&semmarit[2]);
|
||||
usleep(1);
|
||||
sem_post(&semmarit[0]);
|
||||
sem_post(&semmarit[1]);
|
||||
|
||||
}
|
||||
|
||||
pthread_cancel(pt);
|
||||
pthread_join(pt, NULL);
|
||||
}
|
||||
|
||||
ATF_TC(blocktimedwait);
|
||||
ATF_TC_HEAD(blocktimedwait, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "tests sem_timedwait can handle blocking"
|
||||
" (%s)", LIBNAME);
|
||||
atf_tc_set_md_var(tc, "timeout", "2");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(blocktimedwait, tc)
|
||||
{
|
||||
sem_t semid;
|
||||
struct timespec tp;
|
||||
|
||||
rump_init();
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &tp);
|
||||
tp.tv_nsec += 50000000;
|
||||
tp.tv_sec += tp.tv_nsec / 1000000000;
|
||||
tp.tv_nsec %= 1000000000;
|
||||
|
||||
ATF_REQUIRE_EQ(sem_init(&semid, 1, 0), 0);
|
||||
ATF_REQUIRE_ERRNO(ETIMEDOUT, sem_timedwait(&semid, &tp) == -1);
|
||||
}
|
||||
|
||||
ATF_TC(named);
|
||||
ATF_TC_HEAD(named, tc)
|
||||
{
|
||||
|
||||
atf_tc_set_md_var(tc, "descr", "tests named semaphores (%s)", LIBNAME);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wow, easy naming rules. it's these times i'm really happy i can
|
||||
* single-step into the kernel.
|
||||
*/
|
||||
#define SEM1 "/precious_sem"
|
||||
#define SEM2 "/justsem"
|
||||
ATF_TC_BODY(named, tc)
|
||||
{
|
||||
sem_t *sem1, *sem2;
|
||||
void *rv;
|
||||
|
||||
rump_init();
|
||||
sem1 = sem_open(SEM1, 0);
|
||||
ATF_REQUIRE_EQ(errno, ENOENT);
|
||||
ATF_REQUIRE_EQ(sem1, NULL);
|
||||
|
||||
sem1 = sem_open(SEM1, O_CREAT, 0444, 1);
|
||||
if (sem1 == NULL)
|
||||
atf_tc_fail_errno("sem_open O_CREAT");
|
||||
|
||||
rv = sem_open(SEM1, O_CREAT | O_EXCL);
|
||||
ATF_REQUIRE_EQ(errno, EEXIST);
|
||||
ATF_REQUIRE_EQ(rv, NULL);
|
||||
|
||||
sem2 = sem_open(SEM2, O_CREAT, 0444, 0);
|
||||
if (sem2 == NULL)
|
||||
atf_tc_fail_errno("sem_open O_CREAT");
|
||||
|
||||
/* check that semaphores are independent */
|
||||
ATF_REQUIRE_EQ(sem_trywait(sem2), -1);
|
||||
ATF_REQUIRE_EQ(sem_trywait(sem1), 0);
|
||||
ATF_REQUIRE_EQ(sem_trywait(sem1), -1);
|
||||
|
||||
/* check that unlinked remains valid */
|
||||
sem_unlink(SEM2);
|
||||
ATF_REQUIRE_EQ(sem_post(sem2), 0);
|
||||
ATF_REQUIRE_EQ(sem_trywait(sem2), 0);
|
||||
ATF_REQUIRE_EQ(sem_trywait(sem2), -1);
|
||||
ATF_REQUIRE_EQ(errno, EAGAIN);
|
||||
|
||||
#if 0 /* see unlink */
|
||||
/* close it and check that it's gone */
|
||||
if (sem_close(sem2) != 0)
|
||||
atf_tc_fail_errno("sem close");
|
||||
ATF_REQUIRE_EQ(sem_trywait(sem2), -1);
|
||||
ATF_REQUIRE_EQ(errno, EINVAL);
|
||||
#endif
|
||||
|
||||
/* check that we still have sem1 */
|
||||
sem_post(sem1);
|
||||
ATF_REQUIRE_EQ(sem_trywait(sem1), 0);
|
||||
ATF_REQUIRE_EQ(sem_trywait(sem1), -1);
|
||||
ATF_REQUIRE_EQ(errno, EAGAIN);
|
||||
}
|
||||
|
||||
ATF_TC(unlink);
|
||||
ATF_TC_HEAD(unlink, tc)
|
||||
{
|
||||
|
||||
/* this is currently broken. i'll append the PR number soon */
|
||||
atf_tc_set_md_var(tc, "descr", "tests unlinked semaphores can be "
|
||||
"closed (%s)", LIBNAME);
|
||||
}
|
||||
|
||||
#define SEM "/thesem"
|
||||
ATF_TC_BODY(unlink, tc)
|
||||
{
|
||||
sem_t *sem;
|
||||
|
||||
rump_init();
|
||||
sem = sem_open(SEM, O_CREAT, 0444, 0);
|
||||
ATF_REQUIRE(sem);
|
||||
|
||||
if (sem_unlink(SEM) == -1)
|
||||
atf_tc_fail_errno("unlink");
|
||||
if (sem_close(sem) == -1)
|
||||
atf_tc_fail_errno("close unlinked semaphore");
|
||||
}
|
||||
|
||||
/* use rump calls for libpthread _ksem_foo() calls */
|
||||
#define F1(name, a) int _ksem_##name(a); \
|
||||
int _ksem_##name(a v1) {return rump_sys__ksem_##name(v1);}
|
||||
#define F2(name, a, b) int _ksem_##name(a, b); \
|
||||
int _ksem_##name(a v1, b v2) {return rump_sys__ksem_##name(v1, v2);}
|
||||
F2(init, unsigned int, intptr_t *);
|
||||
F1(close, intptr_t);
|
||||
F1(destroy, intptr_t);
|
||||
F1(post, intptr_t);
|
||||
F1(unlink, const char *);
|
||||
F1(trywait, intptr_t);
|
||||
F1(wait, intptr_t);
|
||||
F2(getvalue, intptr_t, unsigned int *);
|
||||
F2(timedwait, intptr_t, const struct timespec *);
|
||||
int _ksem_open(const char *, int, mode_t, unsigned int, intptr_t *);
|
||||
int _ksem_open(const char *a, int b, mode_t c, unsigned int d, intptr_t *e)
|
||||
{return rump_sys__ksem_open(a,b,c,d,e);}
|
||||
Loading…
Reference in New Issue
Block a user