xref: /freebsd-src/tests/sys/file/flock_test.sh (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
13cedbec3SEnji Cooper#!/bin/sh
23cedbec3SEnji Cooper#
33cedbec3SEnji Cooper# Copyright 2014 EMC Corp.
43cedbec3SEnji Cooper# All rights reserved.
53cedbec3SEnji Cooper#
63cedbec3SEnji Cooper# Redistribution and use in source and binary forms, with or without
73cedbec3SEnji Cooper# modification, are permitted provided that the following conditions are
83cedbec3SEnji Cooper# met:
93cedbec3SEnji Cooper#
103cedbec3SEnji Cooper# * Redistributions of source code must retain the above copyright
113cedbec3SEnji Cooper#   notice, this list of conditions and the following disclaimer.
123cedbec3SEnji Cooper# * Redistributions in binary form must reproduce the above copyright
133cedbec3SEnji Cooper#   notice, this list of conditions and the following disclaimer in the
143cedbec3SEnji Cooper#   documentation and/or other materials provided with the distribution.
153cedbec3SEnji Cooper# * Neither the name of Google Inc. nor the names of its contributors
163cedbec3SEnji Cooper#   may be used to endorse or promote products derived from this software
173cedbec3SEnji Cooper#   without specific prior written permission.
183cedbec3SEnji Cooper#
193cedbec3SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
203cedbec3SEnji Cooper# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
213cedbec3SEnji Cooper# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
223cedbec3SEnji Cooper# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
233cedbec3SEnji Cooper# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
243cedbec3SEnji Cooper# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
253cedbec3SEnji Cooper# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
263cedbec3SEnji Cooper# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
273cedbec3SEnji Cooper# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
283cedbec3SEnji Cooper# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
293cedbec3SEnji Cooper# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
303cedbec3SEnji Cooper#
313cedbec3SEnji Cooper
323cedbec3SEnji Cooper# Testcase # 11 is racy; uses an undocumented kernel interface for testing
333cedbec3SEnji Cooper#            locking
343cedbec3SEnji Cooperlast_testcase=16
353cedbec3SEnji Cooper
363cedbec3SEnji Cooperecho "1..$last_testcase"
373cedbec3SEnji Cooper
383cedbec3SEnji Cooperfor n in `seq 1 $last_testcase`; do
393cedbec3SEnji Cooper	todomsg=""
403cedbec3SEnji Cooper
413cedbec3SEnji Cooper	if [ $n -eq 11 ]; then
423cedbec3SEnji Cooper		todomsg=" # TODO: racy testcase"
433cedbec3SEnji Cooper	fi
443cedbec3SEnji Cooper
45*8b302ecdSEnji Cooper	output=$($(dirname $0)/flock_helper . $n)
46*8b302ecdSEnji Cooper	if echo "$output" | grep -q SUCCEED; then
473cedbec3SEnji Cooper		echo "ok $n$todomsg"
483cedbec3SEnji Cooper	else
493cedbec3SEnji Cooper		echo "not ok $n$todomsg"
50*8b302ecdSEnji Cooper		echo "$output" >&2
513cedbec3SEnji Cooper	fi
523cedbec3SEnji Cooperdone
53