#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2013 Fusion IO.  All Rights Reserved.
#
# FS QA Test No. 022
#
# Test the basic qgroup exceed case
#
. ./common/preamble
_begin_fstest auto qgroup limit

. ./common/filter

_require_scratch
_require_qgroup_rescan
_require_btrfs_qgroup_report

# This test requires specific data usage, skip if we have compression enabled
_require_no_compress

#basic exceed limit testing
_limit_test_exceed()
{
	echo "=== limit exceed test ===" >> $seqres.full
	_btrfs subvolume create $SCRATCH_MNT/a
	_btrfs quota enable $SCRATCH_MNT
	subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
	_btrfs qgroup limit 5M 0/$subvolid $SCRATCH_MNT
	_ddt of=$SCRATCH_MNT/a/file bs=10M count=1 >> $seqres.full 2>&1
	[ $? -ne 0 ] || _fail "quota should have limited us"
}
units=`_btrfs_qgroup_units`

_scratch_mkfs > /dev/null 2>&1
_scratch_mount
_limit_test_exceed
_scratch_unmount
_check_scratch_fs

# success, all done
echo "Silence is golden"
status=0
exit
