#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2018, Intel Corporation
#
#
# libpmempool_sync/TEST2 -- test for checking replica sync
#                           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=$DIR/poolset

# Create poolset file
create_poolset $POOLSET \
	10M:$DIR/part00:x \
	r \
	10M:$DIR/part10:x

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

# Delete a part from the second replica
rm -f $DIR/part10

# Try to synchronize replicas
FLAG=32 #invalid flag
expect_normal_exit ./libpmempool_sync$EXESUFFIX $POOLSET $FLAG
cat $LOG >> $LOG_TEMP

FLAG=1024
expect_normal_exit ./libpmempool_sync$EXESUFFIX $POOLSET $FLAG
cat $LOG >> $LOG_TEMP

mv $LOG_TEMP $LOG
check
pass
