base: Fix AddrRange::isSubset() check
Making _end non-inclusive, introduced a bug in isSubset() which was checking if _end is included in the input address range. This CL changes the behavior and now we test if _end - 1 is in the range. Change-Id: Ib8822472b7c266e10d55f3d5cf22a46aa45c1fc7 Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23663 Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -390,7 +390,7 @@ class AddrRange
|
||||
// whether it would fit in a continuous segment of the input
|
||||
// addr range.
|
||||
if (r.interleaved()) {
|
||||
return r.contains(_start) && r.contains(_end) &&
|
||||
return r.contains(_start) && r.contains(_end - 1) &&
|
||||
size() <= r.granularity();
|
||||
} else {
|
||||
return _start >= r._start && _end <= r._end;
|
||||
|
||||
@@ -261,6 +261,30 @@ TEST(AddrRangeTest, isSubsetPartialSubset)
|
||||
EXPECT_FALSE(r2.isSubset(r1));
|
||||
}
|
||||
|
||||
TEST(AddrRangeTest, isSubsetInterleavedCompleteOverlap)
|
||||
{
|
||||
AddrRange r1(0x00, 0x100, {0x40}, 0);
|
||||
AddrRange r2(0x00, 0x40);
|
||||
|
||||
EXPECT_TRUE(r2.isSubset(r1));
|
||||
}
|
||||
|
||||
TEST(AddrRangeTest, isSubsetInterleavedNoOverlap)
|
||||
{
|
||||
AddrRange r1(0x00, 0x100, {0x40}, 1);
|
||||
AddrRange r2(0x00, 0x40);
|
||||
|
||||
EXPECT_FALSE(r2.isSubset(r1));
|
||||
}
|
||||
|
||||
TEST(AddrRangeTest, isSubsetInterleavedPartialOverlap)
|
||||
{
|
||||
AddrRange r1(0x00, 0x100, {0x40}, 0);
|
||||
AddrRange r2(0x10, 0x50);
|
||||
|
||||
EXPECT_FALSE(r2.isSubset(r1));
|
||||
}
|
||||
|
||||
TEST(AddrRangeTest, Contains)
|
||||
{
|
||||
AddrRange r(0xF0, 0xF5);
|
||||
@@ -1038,4 +1062,4 @@ TEST(AddrRangeTest, RangeSizeConstruction){
|
||||
AddrRange r = RangeSize(0x5, 5);
|
||||
EXPECT_EQ(0x5, r.start());
|
||||
EXPECT_EQ(0xA, r.end());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user