#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2018, Intel Corporation
#
#
# libpmempool_transform/TEST2 -- test for checking replica transform
#                                check if flags are supported
#                                pmem/issues#367
#

. ../unittest/unittest.sh

require_test_type medium

require_fs_type any

setup

LOG=out${UNITTEST_NUM}.log
LOG_TEMP=out${UNITTEST_NUM}_part.log
rm -f $LOG && touch $LOG
rm -f $LOG_TEMP && touch $LOG_TEMP

LAYOUT=OBJ_LAYOUT$SUFFIX
POOLSET_IN=$DIR/poolset.in
POOLSET_OUT=$DIR/poolset.out

# Create poolset files
create_poolset $POOLSET_IN \
	10M:$DIR/part00:x

create_poolset $POOLSET_OUT \
	10M:$DIR/part00:x \
	r \
	10M:$DIR/part10:x

# Create a pool
expect_normal_exit $PMEMPOOL$EXESUFFIX create --layout=$LAYOUT\
	obj $POOLSET_IN
cat $LOG >> $LOG_TEMP

# Try to transform poolset
FLAG=1 # invalid flag
expect_normal_exit ./libpmempool_transform$EXESUFFIX \
	$POOLSET_IN $POOLSET_OUT $FLAG
cat $LOG >> $LOG_TEMP

FLAG=1024
expect_normal_exit ./libpmempool_transform$EXESUFFIX \
	$POOLSET_IN $POOLSET_OUT $FLAG
cat $LOG >> $LOG_TEMP

mv $LOG_TEMP $LOG
check
pass
