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

#
# src/test/pmreorder_flushes/TEST0 -- test for the reordering script
# Tests positive case using no reorder engine. Checks if once flushed
# variable can be overwrite in the next barrier and then persisted properly.
#

. ../unittest/unittest.sh

require_fs_type pmem non-pmem
require_build_type debug
require_test_type medium
require_pmemcheck_version_ge 1 0
require_pmemcheck_version_lt 2 0
require_pmreorder

setup

export PMREORDER_EMIT_LOG=1

# create holey file
truncate -s 4M $DIR/testfile

LOG_FILE=./pmreorder_flushes${UNITTEST_NUM}.log
touch $LOG_FILE

BIN="./pmreorder_flushes$EXESUFFIX"
PMEMCHECK_CMD="$BIN g $DIR/testfile $LOG_FILE"
PMREORDER_CMD="$BIN c $DIR/testfile $LOG_FILE"

pmreorder_create_store_log $DIR/testfile "$PMEMCHECK_CMD"
pmreorder_expect_success NoReorderDoCheck "DO_NOT_CHECK_E=NoReorderNoCheck" "$PMREORDER_CMD"

check

pass
