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

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

. ../unittest/unittest.sh

require_test_type medium
require_fs_type none
require_dax_devices 1

setup

# single mm entry - 0x7fff77423000 4096
#
# 7fff77423000 2147479552
#	extends past mm entry, should produce: 0
# 7fff77423000 2147483648
#	extends past mm entry, should produce: 0
# 7fff77423000 8192
#	extends past mm entry, should produce: 0
# 7fff77423000 4096
#	entirely encompassed by mm entry: should produce: 1
# 7fff77424000 2147479552
#	extends past mm entry, should produce: 0
# 7fff77424000 2147483648
#	extends past mm entry, should produce: 0
# 7fff77424000 8192
#	extends past mm entry, should produce: 0
# 7fff77428000 10240
#	extends past mm entry, should produce: 0
# 7fff77423000 0
#	starts at mm entry: should produce: 1
# 7fff77424000 0
#	starts behind mm entry, should produce: 0
# 7fff77424000 0xffffffffffffffff
#	starts behind 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 0x7fff77423000 4096 DEV_DAX ${DEVICE_DAX_PATH[0]}\
	\
	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
