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

#
# src/test/util_badblock/TEST10 -- unit test for util_badblock
#                                 - regular file with no bad blocks
#                                   on a pmem filesystem
#

. ../unittest/unittest.sh

require_test_type medium
require_linked_with_ndctl ./util_badblock$EXESUFFIX

#
# Listing bad blocks on a pmem filesystem requires superuser privileges.
#
require_fs_type pmem
require_sudo_allowed

# it's not possible to run sudo under Valgrind
configure_valgrind force-disable

setup

$FALLOCATE 100M $DIR/testfile1

ENV="\
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
UNITTEST_NUM=${UNITTEST_NUM} \
UNITTEST_NAME=${UNITTEST_NAME} \
UNITTEST_LOG_LEVEL=${UNITTEST_LOG_LEVEL} \
UNITTEST_CHECK_OPEN_FILES_IGNORE_BADBLOCKS=${UNITTEST_CHECK_OPEN_FILES_IGNORE_BADBLOCKS}"

expect_normal_exit sudo bash -c \"${ENV} \
	./util_badblock$EXESUFFIX $DIR/testfile1 l \"

check

pass
