1#!/bin/bash
2
3# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
4
5TS_TOPDIR="${0%/*}/../.."
6TS_DESC="lock"
7
8TS_OPTIONAL="yes"
9
10. $TS_TOPDIR/functions.sh
11ts_init "$*"
12
13TESTPROG="$TS_HELPER_LIBMOUNT_LOCK"
14
15[ -x $TESTPROG ] || ts_skip "test not compiled"
16
17#
18# Be careful with number of processes. Don't forget that there is time limit
19# when the mount waits on the mtab lock. If you define too much processes some
20# of them will fail with timeout.
21#
22# Note: the original version (< 2.13) of util-linux is completely useless for
23# this test (maximum for this old version is NLOOPS=10 and NPROCESSES=5 (2-way
24# 2GHz machine)). It has terrible performance due a bad timeouts implementation
25# in lock_mtab().
26#
27NLOOPS=1000
28NPROCESSES=50
29
30
31> $TS_OUTPUT.debug
32echo 0 > $TS_OUTPUT
33SYNCTIME=$(( $(date +%s) + 5 ))
34
35for id in $(seq 0 $(( $NPROCESSES - 1 ))); do
36	ts_run $TESTPROG --lock --synctime $SYNCTIME $TS_OUTPUT $NLOOPS >> $TS_OUTPUT.debug 2>&1 &
37done
38
39wait
40
41ts_finalize
42