| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Copyright (C) 2010 Karel Zak <[email protected]> |
| 4 |
|
| 5 |
TS_TOPDIR="${0%/*}/../.." |
| 6 |
TS_DESC="lock" |
| 7 |
|
| 8 |
TS_OPTIONAL="yes" |
| 9 |
|
| 10 |
. "$TS_TOPDIR"/functions.sh |
| 11 |
ts_init "$*" |
| 12 |
|
| 13 |
TESTPROG="$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 |
# |
| 27 |
NLOOPS=1000 |
| 28 |
NPROCESSES=50 |
| 29 |
|
| 30 |
|
| 31 |
> $TS_OUTPUT.debug |
| 32 |
echo 0 > $TS_OUTPUT |
| 33 |
SYNCTIME=$(( $(date +%s) + 5 )) |
| 34 |
|
| 35 |
for id in $(seq 0 $(( $NPROCESSES - 1 ))); do |
| 36 |
ts_run $TESTPROG --lock --synctime $SYNCTIME $TS_OUTPUT $NLOOPS >> $TS_OUTPUT.debug 2>&1 & |
| 37 |
done |
| 38 |
|
| 39 |
wait |
| 40 |
|
| 41 |
ts_finalize |