#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2023, Intel Corporation
#
#
# pmempool_info/TEST16 -- test for info command
#

. ../unittest/unittest.sh

require_test_type medium

require_fs_type pmem non-pmem

setup

LOG=out${UNITTEST_NUM}.log
LOG_REP0=rep${UNITTEST_NUM}.0.log
LOG_REP1=rep${UNITTEST_NUM}.1.log

rm -f $LOG_REP0 $LOG_REP1
rm -f $LOG && touch $LOG

POOLSET=$DIR/pool.set
POOL1=$DIR/pool.part1
POOL2=$DIR/pool.part2
POOL3=$DIR/pool.part3
POOLS="$POOL1 $POOL2 $POOL3"
POOLREP=$DIR/rep.set
REPL1=$DIR/pool.rep.part1
REPL2=$DIR/pool.rep.part2
REPL3=$DIR/pool.rep.part3
REPS="$REPL1 $REPL2 $REPL3"

create_poolset $POOLSET 32M:$POOL1:z 32M:$POOL2:z 32M:$POOL3:z
check_file $POOLSET

rm -f $POOLREP
create_poolset $POOLREP 32M:$POOL1:z 32M:$POOL2:z 32M:$POOL3:z\
	R 32M:$REPL1:z 32M:$REPL2:z 32M:$REPL3:z
check_file $POOLREP

rm -f $POOLS $REPS
expect_normal_exit $PMEMPOOL$EXESUFFIX create obj --layout pmempool$SUFFIX $POOLREP
expect_normal_exit $PMEMPOOL$EXESUFFIX info $POOLREP >> $LOG
expect_normal_exit $PMEMPOOL$EXESUFFIX info --replica 0 $POOLREP | $GREP 'UUID' > $LOG_REP0
expect_normal_exit $PMEMPOOL$EXESUFFIX info --replica 1 $POOLREP | $GREP 'UUID' > $LOG_REP1

echo "DIFF" >> $LOG
diff --normal $LOG_REP0 $LOG_REP1 >> $LOG || true

check

pass
