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

#
# src/test/util_sds/TEST7 -- unittest for shutdown state
#

. ../unittest/unittest.sh

require_test_type medium

require_fs_type any

require_build_type debug

setup

export PMEM2_LOG_LEVEL=2
export PMEM2_LOG_FILE=./test$UNITTEST_NUM.log

# fail after an open flag is set
expect_normal_exit ./util_sds 1 5 \
				   $DIR/testfile1 5 0 \
				   $DIR/testfile2 7 0 \
				   $DIR/testfile3 9 0

# ADR failure - USC was incremented
expect_abnormal_exit ./util_sds 0 0 \
				   $DIR/testfile1 5 0 \
				   $DIR/testfile2 7 1 \
				   $DIR/testfile3 9 0

grep "shutdown_state_check" test$UNITTEST_NUM.log > grep$UNITTEST_NUM.log || true

check

pass
