Module Name: src Committed By: jruoho Date: Thu May 5 05:39:12 UTC 2011
Modified Files: src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.tests src/tests/include: Makefile Added Files: src/tests/include/machine: Makefile t_bswap.c Removed Files: src/tests/include: t_bswap.c Log Message: Follow the real tree with the test directory structure. To generate a diff of this commit: cvs rdiff -u -r1.328 -r1.329 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.46 -r1.47 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.8 -r1.9 src/tests/include/Makefile cvs rdiff -u -r1.1 -r0 src/tests/include/t_bswap.c cvs rdiff -u -r0 -r1.1 src/tests/include/machine/Makefile \ src/tests/include/machine/t_bswap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.328 src/distrib/sets/lists/tests/mi:1.329 --- src/distrib/sets/lists/tests/mi:1.328 Thu May 5 05:28:52 2011 +++ src/distrib/sets/lists/tests/mi Thu May 5 05:39:11 2011 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.328 2011/05/05 05:28:52 jruoho Exp $ +# $NetBSD: mi,v 1.329 2011/05/05 05:39:11 jruoho Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -280,12 +280,14 @@ ./usr/libdata/debug/usr/tests/fs/vfs/t_vfsops.debug tests-fs-debug debug,atf ./usr/libdata/debug/usr/tests/fs/vfs/t_vnops.debug tests-fs-debug debug,atf ./usr/libdata/debug/usr/tests/include tests-include-tests +./usr/libdata/debug/usr/tests/include/machine tests-include-tests +./usr/libdata/debug/usr/tests/include/machine/t_bswap.debug tests-include-tests debug,atf ./usr/libdata/debug/usr/tests/include/sys tests-include-tests ./usr/libdata/debug/usr/tests/include/sys/t_bitops.debug tests-include-tests debug,atf ./usr/libdata/debug/usr/tests/include/sys/t_bootblock.debug tests-include-tests debug,atf ./usr/libdata/debug/usr/tests/include/sys/t_types.debug tests-include-tests debug,atf ./usr/libdata/debug/usr/tests/include/t_bitstring.debug tests-include-tests debug,atf -./usr/libdata/debug/usr/tests/include/t_bswap.debug tests-include-tests debug,atf +./usr/libdata/debug/usr/tests/include/t_bswap.debug tests-obsolete obsolete ./usr/libdata/debug/usr/tests/include/t_errno.debug tests-include-tests debug,atf ./usr/libdata/debug/usr/tests/include/t_glob.debug tests-include-tests debug,atf ./usr/libdata/debug/usr/tests/include/t_inttypes.debug tests-include-tests debug,atf @@ -1381,13 +1383,16 @@ ./usr/tests/include/d_bitstring_64.out tests-include-tests atf ./usr/tests/include/d_bitstring_67.out tests-include-tests atf ./usr/tests/include/d_bitstring_8.out tests-include-tests atf +./usr/tests/include/machine tests-include-tests +./usr/tests/include/machine/Atffile tests-include-tests atf +./usr/tests/include/machine/t_bswap tests-include-tests atf ./usr/tests/include/sys tests-include-tests ./usr/tests/include/sys/Atffile tests-include-tests atf ./usr/tests/include/sys/t_bitops tests-include-tests atf ./usr/tests/include/sys/t_bootblock tests-include-tests atf ./usr/tests/include/sys/t_types tests-include-tests atf ./usr/tests/include/t_bitstring tests-include-tests atf -./usr/tests/include/t_bswap tests-include-tests atf +./usr/tests/include/t_bswap tests-obsolete obsolete ./usr/tests/include/t_errno tests-include-tests atf ./usr/tests/include/t_glob tests-include-tests atf ./usr/tests/include/t_inttypes tests-include-tests atf Index: src/etc/mtree/NetBSD.dist.tests diff -u src/etc/mtree/NetBSD.dist.tests:1.46 src/etc/mtree/NetBSD.dist.tests:1.47 --- src/etc/mtree/NetBSD.dist.tests:1.46 Tue May 3 15:13:50 2011 +++ src/etc/mtree/NetBSD.dist.tests Thu May 5 05:39:11 2011 @@ -1,4 +1,4 @@ -# $NetBSD: NetBSD.dist.tests,v 1.46 2011/05/03 15:13:50 jruoho Exp $ +# $NetBSD: NetBSD.dist.tests,v 1.47 2011/05/05 05:39:11 jruoho Exp $ ./usr/libdata/debug/usr/tests ./usr/libdata/debug/usr/tests/atf @@ -36,6 +36,7 @@ ./usr/libdata/debug/usr/tests/fs/union ./usr/libdata/debug/usr/tests/fs/vfs ./usr/libdata/debug/usr/tests/include +./usr/libdata/debug/usr/tests/include/machine ./usr/libdata/debug/usr/tests/include/sys ./usr/libdata/debug/usr/tests/ipf ./usr/libdata/debug/usr/tests/kernel @@ -150,6 +151,7 @@ ./usr/tests/fs/zfs ./usr/tests/games ./usr/tests/include +./usr/tests/include/machine ./usr/tests/include/sys ./usr/tests/ipf ./usr/tests/ipf/expected Index: src/tests/include/Makefile diff -u src/tests/include/Makefile:1.8 src/tests/include/Makefile:1.9 --- src/tests/include/Makefile:1.8 Thu May 5 05:24:44 2011 +++ src/tests/include/Makefile Thu May 5 05:39:10 2011 @@ -1,14 +1,13 @@ -# $NetBSD: Makefile,v 1.8 2011/05/05 05:24:44 jruoho Exp $ +# $NetBSD: Makefile,v 1.9 2011/05/05 05:39:10 jruoho Exp $ NOMAN= # defined .include <bsd.own.mk> TESTSDIR= ${TESTSBASE}/include -TESTS_SUBDIRS= sys +TESTS_SUBDIRS= machine sys TESTS_C= t_bitstring -TESTS_C+= t_bswap TESTS_C+= t_errno TESTS_C+= t_glob TESTS_C+= t_inttypes Added files: Index: src/tests/include/machine/Makefile diff -u /dev/null src/tests/include/machine/Makefile:1.1 --- /dev/null Thu May 5 05:39:12 2011 +++ src/tests/include/machine/Makefile Thu May 5 05:39:11 2011 @@ -0,0 +1,10 @@ +# $NetBSD: Makefile,v 1.1 2011/05/05 05:39:11 jruoho Exp $ + +NOMAN= # defined + +.include <bsd.own.mk> + +TESTSDIR= ${TESTSBASE}/include/machine +TESTS_C= t_bswap + +.include <bsd.test.mk> Index: src/tests/include/machine/t_bswap.c diff -u /dev/null src/tests/include/machine/t_bswap.c:1.1 --- /dev/null Thu May 5 05:39:12 2011 +++ src/tests/include/machine/t_bswap.c Thu May 5 05:39:11 2011 @@ -0,0 +1,178 @@ +/* $NetBSD: t_bswap.c,v 1.1 2011/05/05 05:39:11 jruoho Exp $ */ + +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jukka Ruohonen. + * + * 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 <sys/cdefs.h> +__RCSID("$NetBSD: t_bswap.c,v 1.1 2011/05/05 05:39:11 jruoho Exp $"); + +#include <sys/types.h> +#include <machine/bswap.h> + +#include <atf-c.h> + +static uint16_t x16; +static uint32_t x32; +static uint64_t x64; + +static uint16_t unconst16(uint16_t); +static uint32_t unconst32(uint32_t); +static uint64_t unconst64(uint64_t); + +/* + * Given the use of __builtin_constant_p(3), + * these functions try to avoid gcc(1) from + * treating the arguments as constants. + */ +static uint16_t +unconst16(uint16_t val) +{ + return val + x16; +} + +static uint32_t +unconst32(uint32_t val) +{ + return val + x32; +} + +static uint64_t +unconst64(uint64_t val) +{ + return val + x64; +} + +ATF_TC(bswap16_basic); +ATF_TC_HEAD(bswap16_basic, tc) +{ + atf_tc_set_md_var(tc, "descr", "A naive test of bswap16(3), #1"); +} + +ATF_TC_BODY(bswap16_basic, tc) +{ + ATF_REQUIRE_EQ(bswap16(0x0000), 0x0000); + ATF_REQUIRE_EQ(bswap16(0xff00), 0x00ff); + ATF_REQUIRE_EQ(bswap16(0xffff), 0xffff); + ATF_REQUIRE_EQ(bswap16(0x1234), 0x3412); +} + +ATF_TC(bswap16_unconst); +ATF_TC_HEAD(bswap16_unconst, tc) +{ + atf_tc_set_md_var(tc, "descr", "A naive test of bswap16(3), #2"); +} + +ATF_TC_BODY(bswap16_unconst, tc) +{ + x16 = 0; + + ATF_REQUIRE_EQ(bswap16(unconst16(0x0000)), 0x0000); + ATF_REQUIRE_EQ(bswap16(unconst16(0xff00)), 0x00ff); + ATF_REQUIRE_EQ(bswap16(unconst16(0xffff)), 0xffff); + ATF_REQUIRE_EQ(bswap16(unconst16(0x1234)), 0x3412); +} + +ATF_TC(bswap32_basic); +ATF_TC_HEAD(bswap32_basic, tc) +{ + atf_tc_set_md_var(tc, "descr", "A naive test of bswap32(3), #1"); +} + +ATF_TC_BODY(bswap32_basic, tc) +{ + ATF_REQUIRE_EQ(bswap32(0x00000000), 0x00000000); + ATF_REQUIRE_EQ(bswap32(0xffff0000), 0x0000ffff); + ATF_REQUIRE_EQ(bswap32(0xffffffff), 0xffffffff); + ATF_REQUIRE_EQ(bswap32(0x12345678), 0x78563412); +} + +ATF_TC(bswap32_unconst); +ATF_TC_HEAD(bswap32_unconst, tc) +{ + atf_tc_set_md_var(tc, "descr", "A naive test of bswap32(3), #2"); +} + +ATF_TC_BODY(bswap32_unconst, tc) +{ + x32 = 0; + + ATF_REQUIRE_EQ(bswap32(unconst32(0x00000000)), 0x00000000); + ATF_REQUIRE_EQ(bswap32(unconst32(0xffff0000)), 0x0000ffff); + ATF_REQUIRE_EQ(bswap32(unconst32(0xffffffff)), 0xffffffff); + ATF_REQUIRE_EQ(bswap32(unconst32(0x12345678)), 0x78563412); +} + +ATF_TC(bswap64_basic); +ATF_TC_HEAD(bswap64_basic, tc) +{ + atf_tc_set_md_var(tc, "descr", "A naive test of bswap64(3), #1"); +} + +ATF_TC_BODY(bswap64_basic, tc) +{ + ATF_REQUIRE_EQ(bswap64(0x0000000000000000), 0x0000000000000000); + ATF_REQUIRE_EQ(bswap64(0xffffffff00000000), 0x00000000ffffffff); + ATF_REQUIRE_EQ(bswap64(0xffffffffffffffff), 0xffffffffffffffff); + ATF_REQUIRE_EQ(bswap64(0x123456789abcdeff), 0xffdebc9a78563412); +} + +ATF_TC(bswap64_unconst); +ATF_TC_HEAD(bswap64_unconst, tc) +{ + atf_tc_set_md_var(tc, "descr", "A naive test of bswap64(3), #2"); +} + +ATF_TC_BODY(bswap64_unconst, tc) +{ + x64 = 0; + + ATF_REQUIRE_EQ(bswap64(unconst64(0x0000000000000000)), + 0x0000000000000000); + + ATF_REQUIRE_EQ(bswap64(unconst64(0xffffffff00000000)), + 0x00000000ffffffff); + + ATF_REQUIRE_EQ(bswap64(unconst64(0xffffffffffffffff)), + 0xffffffffffffffff); + + ATF_REQUIRE_EQ(bswap64(unconst64(0x123456789abcdeff)), + 0xffdebc9a78563412); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, bswap16_basic); + ATF_TP_ADD_TC(tp, bswap16_unconst); + ATF_TP_ADD_TC(tp, bswap32_basic); + ATF_TP_ADD_TC(tp, bswap32_unconst); + ATF_TP_ADD_TC(tp, bswap64_basic); + ATF_TP_ADD_TC(tp, bswap64_unconst); + + return atf_no_error(); +}