1281432Sngie#!/bin/sh
2281432Sngie#
3281432Sngie# Copyright 2014 EMC Corp.
4281432Sngie# All rights reserved.
5281432Sngie#
6281432Sngie# Redistribution and use in source and binary forms, with or without
7281432Sngie# modification, are permitted provided that the following conditions are
8281432Sngie# met:
9281432Sngie#
10281432Sngie# * Redistributions of source code must retain the above copyright
11281432Sngie#   notice, this list of conditions and the following disclaimer.
12281432Sngie# * Redistributions in binary form must reproduce the above copyright
13281432Sngie#   notice, this list of conditions and the following disclaimer in the
14281432Sngie#   documentation and/or other materials provided with the distribution.
15281432Sngie# * Neither the name of Google Inc. nor the names of its contributors
16281432Sngie#   may be used to endorse or promote products derived from this software
17281432Sngie#   without specific prior written permission.
18281432Sngie#
19281432Sngie# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20281432Sngie# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21281432Sngie# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22281432Sngie# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23281432Sngie# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24281432Sngie# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25281432Sngie# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26281432Sngie# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27281432Sngie# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28281432Sngie# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29281432Sngie# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30281432Sngie#
31281432Sngie# $FreeBSD$
32281432Sngie
33281432Sngie# Testcase # 11 is racy; uses an undocumented kernel interface for testing
34281432Sngie#            locking
35281432Sngie# Testcase # 16 is racy/doesn't handle EINTR properly
36281432Sngielast_testcase=16
37281432Sngie
38281432Sngieecho "1..$last_testcase"
39281432Sngie
40281432Sngiefor n in `seq 1 $last_testcase`; do
41281432Sngie	todomsg=""
42281432Sngie
43281432Sngie	if [ $n -eq 11 ]; then
44281432Sngie		todomsg=" # TODO: racy testcase"
45281432Sngie	# Test 16 fails:
46281432Sngie	# F_SETLKW on locked region by two threads: FAIL ((uintptr_t)res != 0)
47281432Sngie	elif [ $n -eq 16 ]; then
48281432Sngie		todomsg=" # TODO: racy testcase (doesn't handle EINTR properly)"
49281432Sngie	fi
50281432Sngie
51292854Sngie	output=$($(dirname $0)/flock_helper . $n)
52292854Sngie	if echo "$output" | grep -q SUCCEED; then
53281432Sngie		echo "ok $n$todomsg"
54281432Sngie	else
55281432Sngie		echo "not ok $n$todomsg"
56292854Sngie		echo "$output" >&2
57281432Sngie	fi
58281432Sngiedone
59