#
# Idempotent creat calls
#
TEST=`basename $0`

rm -rf zap
mkdir zap

# Create some files using mode 066 umask 022.
interrupt -ns INT -t 20 -m "${TEST}init (idempotent creat)" \
	-- dirop -n 100 -m 0666 -x 022 -f zap/foo creat

# Check whether the files are there and have the correct mode
interrupt -ns INT -t 20 -m "${TEST}a (idempotent creat - mode check)" \
	-- dirop -z -n 100 -m 0666 -x 022 -f zap/foo creat
rm -rf zap

# Now chck for uid/gid changes. For this, we have to create
# files owned by a non-root user and creat them a second time as root.
if [ `id -u` != 0 ]; then
	echo "Not running as root - skipping uid/gid creat checks"
	exit 0
fi

mkdir -m 777 zap
dirop -z -n 100 -u 5555 -g 5555 -f zap/foo creat

# Now try with a different mode and see if the mode changes
interrupt -ns INT -t 20 -m "${TEST}b (idempotent creat - uid check)" \
	-- dirop -z -n 100 -u 0 -U 5555 -f zap/foo creat

# Now try with a different uid and see if it changes
interrupt -ns INT -t 20 -m "${TEST}c (idempotent creat - gid check)" \
	-- dirop -z -n 100 -g 0 -G 5555 -f zap/foo creat

rm -rf zap
