#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018-2019, Intel Corporation

#
# src/test/util_poolset_parse/TEST4 -- unit test for parsing a pool set file
#
# Duplicate directories
#

. ../unittest/unittest.sh

require_test_type medium
require_build_type debug
require_fs_type any

setup

export PARSER_LOG_LEVEL=4
export PARSER_LOG_FILE=./parser$UNITTEST_NUM.log

RESVSIZE=$((260 * 1024 * 1024)) # 264MiB (base part + 2 extends)
MIN_POOL=$((128 * 1024 * 1024)) # 128MiB
export TEST_LOG_LEVEL=4
export TEST_LOG_FILE=./test$UNITTEST_NUM.log

# prepare pool sets
create_poolset $DIR/testset1\
	$RESVSIZE:$DIR/testset11:d $RESVSIZE:$DIR/testset11:d\
	O SINGLEHDR # fail
create_poolset $DIR/testset2\
	$RESVSIZE:$DIR/testset21:d R $RESVSIZE:$DIR/testset21:d\
	O SINGLEHDR # fail

POOLSETS="$DIR/testset1 $DIR/testset2"

expect_normal_exit ./util_poolset_parse$EXESUFFIX t $POOLSETS

$GREP -e "<[14]>.*\[.*util_parse_add_directory\]" ./parser$UNITTEST_NUM.log | \
	sed -e "s/^.*util_parse_add_directory][ ]*//g" > grep$UNITTEST_NUM.log

check

pass
