#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2023, Intel Corporation
#
#
# pmempool_create/TEST8 -- test for pmempool create command with poolset
#

. ../unittest/unittest.sh

require_test_type medium
require_fs_type any

setup

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 \
	O SINGLEHDR

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 \
	O SINGLEHDR

check_file $POOLREP

# PMEMOBJ
rm -f $POOLS
expect_normal_exit $PMEMPOOL$EXESUFFIX create --layout=LAYOUT_NAME$SUFFIX obj $POOLSET
check_files $POOL
check_signatures PMEMOBJ $POOL1

# PMEMOBJ with replica
rm -f $POOLS
expect_normal_exit $PMEMPOOL$EXESUFFIX create --layout=LAYOUT_NAME$SUFFIX obj $POOLREP
check_files $POOLS $REPS
check_signatures PMEMOBJ $POOL1 $REPL1

rm -f $POOLS
rm -f $REPS
rm -f $POOLSET
rm -f $POOLREP

pass
