#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018, Intel Corporation
#
#
# libpmempool_feature/TEST1 -- unit test for PMEMPOOL_FEAT_CHCKSUM_2K
#

. ../unittest/unittest.sh

require_test_type medium

require_fs_type any

require_sds ./libpmempool_feature$EXESUFFIX

setup
. ./common.sh

require_usc_permission $DIR

expect_normal_exit $PMEMPOOL$EXESUFFIX create obj $POOL

# PMEMPOOL_FEAT_CHCKSUM_2K is enabled by default
libpmempool_feature_query CKSUM_2K

# SHUTDOWN_STATE is disabled by default on Linux
# enable it to interfere toggling CKSUM_2K
libpmempool_feature_enable SHUTDOWN_STATE no-query

# disable PMEMPOOL_FEAT_SHUTDOWN_STATE prior to success
exit_func=expect_abnormal_exit
libpmempool_feature_disable CKSUM_2K # should fail
exit_func=expect_normal_exit
libpmempool_feature_disable SHUTDOWN_STATE
libpmempool_feature_disable CKSUM_2K # should succeed

libpmempool_feature_enable CKSUM_2K

check

pass
