#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019, Intel Corporation
#
#
# pmempool_rm/TEST12 -- test for pmempool rm - verify removing of
# a write-protected part file by answering with invalid response
#

. ../unittest/unittest.sh

require_test_type medium
require_fs_type any
require_no_superuser

setup

LOG=out$UNITTEST_NUM.log

# Create poolset with replica
create_poolset $DIR/pool.set 32M:$DIR/pool.part1:z 32M:$DIR/pool.part2:z\
	R 32M:$DIR/rep.part1:z 32M:$DIR/rep.part2:z

chmod 0400 $DIR/pool.set $DIR/pool.part1 $DIR/pool.part2 $DIR/rep.part1 $DIR/rep.part2

# Check if all pools and poolset exist
check_files\
	$DIR/pool.set\
	$DIR/pool.part1\
	$DIR/pool.part2\
	$DIR/rep.part1\
	$DIR/rep.part2

expect_normal_exit $PMEMPOOL$EXESUFFIX rm -il $DIR/pool.part1 >> $LOG 2>&1 <<EOF
x
x
\x03
EOF

check_files\
	$DIR/pool.part1

check

pass
