#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2019, Intel Corporation

#
# src/test/pmem_is_pmem_posix/TEST2 -- unit test for pmem_is_pmem
#

. ../unittest/unittest.sh

require_test_type medium
require_fs_type none

setup

# single mm entry - 0x7fff77424000 2147479552
#
# 7fff77423000 2147479552
#	starts before mm entry, should produce: 0
# 7fff77423000 2147483648
#	starts before mm entry, should produce: 0
# 7fff77423000 8192
#	starts before mm entry, should produce: 0
# 7fff77423000 4096
#	starts before mm entry, should produce: 0
# 7fff77424000 2147479552
#	exactly matches mm entry, should produce: 1
# 7fff77424000 2147483648
#	extends past mm entry, should produce: 0
# 7fff77424000 8192
#	entirely encompassed by mm entry: should produce: 1
# 7fff77428000 10240
#	subset of mm entry: should produce: 1
# 7fff77423000 0
#	starts before mm entry, should produce: 0
# 7fff77424000 0
#	starts at mm entry: should produce: 1
# 7fff77424000 0xffffffffffffffff
#	extends past second mm entry, should produce: 0
# 7fff77423008 1
#	entirely encompassed by first mm entry: should produce: 0
# 7fff77423ff0 32
#	start at first mm entry, extends into second: should produce: 0

expect_normal_exit ./pmem_is_pmem_posix$EXESUFFIX\
	a 0x7fff77424000 2147479552 MAP_SYNC\
	\
	t 0x7fff77423000 2147479552\
	t 0x7fff77423000 2147483648\
	t 0x7fff77423000 8192\
	t 0x7fff77423000 4096\
	t 0x7fff77424000 2147479552\
	t 0x7fff77424000 2147483648\
	t 0x7fff77424000 8192\
	t 0x7fff77428000 10240\
	t 0x7fff77423000 0\
	t 0x7fff77424000 0\
	t 0x7fff77424000 0xffffffffffffffff\
	t 0x7fff77423008 1\
	t 0x7fff77423FF0 32

check

pass
