/*-
* 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.
*/
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
__RCSID("$NetBSD: t_extent.c,v 1.5 2017/01/13 21:30:41 christos Exp $");
ATF_TC(bound1);
ATF_TC_HEAD(bound1, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks for overflow in boundary check, before an allocated region "
"(fixed in 1.32)");
}
ATF_TC_BODY(bound1, tc)
{
h_create("test4", 0xf0000000, 0xffffffff, 0);
ATF_TC(bound2);
ATF_TC_HEAD(bound2, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks for overflow in boundary checks, before the subregion end "
"(fixed in 1.32)");
}
ATF_TC_BODY(bound2, tc)
{
h_create("test5", 0xf0000000, 0xffffffff, 0);
ATF_TC(bound4);
ATF_TC_HEAD(bound4, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks allocation beyond last boundary line: last allocation "
"should be bumped to the next boundary and exactly fit the "
"remaining space");
}
ATF_TC_BODY(bound4, tc)
{
h_create("test7", 0, 11, 0);
ATF_TC(subregion3);
ATF_TC_HEAD(subregion3, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks that we don't allocate a region pasts the end of "
"subregion (i.e., the second alloc_subregion should fail). "
"subr_extent.c prior to rev. 1.43 allocated region starting "
"from 0x10");
}
ATF_TC_BODY(subregion3, tc)
{
h_create("test8", 0, 0x4f, EX_NOCOALESCE);
ATF_TC(bound5);
ATF_TC_HEAD(bound5, tc)
{
atf_tc_set_md_var(tc, "descr",
"When allocating a region with a boundary constraint, checks "
"proper detection of overflaps once the candidate region has "
"been aligned. subr_extent.c prior 1.45 could corrupt the extent "
"map in this situation");
}
ATF_TC_BODY(bound5, tc)
{
h_create("test9", 0, 0x4f, 0);
ATF_TC(subregion4);
ATF_TC_HEAD(subregion4, tc)
{
atf_tc_set_md_var(tc, "descr",
"Checks for off-by-one bug which would cause a region at the end "
"of the extent to be allocated multiple times (fixed in 1.51)");
}
ATF_TC_BODY(subregion4, tc)
{
h_create("test11", 0x10, 0x20, EX_NOCOALESCE);