summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-10-19 14:30:07 +0200
committerKarel Zak <kzak@redhat.com>2011-01-03 12:28:45 +0100
commit9e10ad3d5035686e4676c208c7d88f55f1c1a05c (patch)
treef21962320d8425ac036fa608d031a8508ad0aaca /tests
parentf27feed36e589191622c444f7c19a2e4d6cbe51a (diff)
downloadutil-linux-old-9e10ad3d5035686e4676c208c7d88f55f1c1a05c.tar.gz
tests: add libmount lock test
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/commands.sh.in1
-rw-r--r--tests/expected/libmount/lock1
-rwxr-xr-xtests/ts/libmount/lock37
3 files changed, 39 insertions, 0 deletions
diff --git a/tests/commands.sh.in b/tests/commands.sh.in
index d5e166bd..bcb428d4 100644
--- a/tests/commands.sh.in
+++ b/tests/commands.sh.in
@@ -19,6 +19,7 @@ TS_HELPER_CPUSET="$top_builddir/lib/test_cpuset"
TS_HELPER_LIBMOUNT_OPTSTR="$top_builddir/shlibs/mount/src/test_optstr"
TS_HELPER_LIBMOUNT_TAB="$top_builddir/shlibs/mount/src/test_tab"
TS_HELPER_LIBMOUNT_UTILS="$top_builddir/shlibs/mount/src/test_utils"
+TS_HELPER_LIBMOUNT_LOCK="$top_builddir/shlibs/mount/src/test_lock"
# TODO: use partx
TS_HELPER_PARTITIONS="$top_builddir/shlibs/blkid/samples/partitions"
diff --git a/tests/expected/libmount/lock b/tests/expected/libmount/lock
new file mode 100644
index 00000000..d7e318d9
--- /dev/null
+++ b/tests/expected/libmount/lock
@@ -0,0 +1 @@
+50000 \ No newline at end of file
diff --git a/tests/ts/libmount/lock b/tests/ts/libmount/lock
new file mode 100755
index 00000000..1230e5cc
--- /dev/null
+++ b/tests/ts/libmount/lock
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="lock"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+TESTPROG="$TS_HELPER_LIBMOUNT_LOCK"
+
+#
+# Be careful with number of processes. Don't forget that there is time limit
+# when the mount waits on the mtab lock. If you define too much processes some
+# of them will fail with timeout.
+#
+# Note: the original version (< 2.13) of util-linux is completely useless for
+# this test (maximum for this old version is NLOOPS=10 and NPROCESSES=5 (2-way
+# 2GHz machine)). It has terrible performance due a bad timeouts implemntation
+# in lock_mtab().
+#
+NLOOPS=1000
+NPROCESSES=50
+
+
+> $TS_OUTPUT.debug
+echo 0 > $TS_OUTPUT
+SYNCTIME=$(( $(date +%s) + 5 ))
+
+for id in $(seq 0 $(( $NPROCESSES - 1 ))); do
+ $TESTPROG --lock --synctime $SYNCTIME $TS_OUTPUT $NLOOPS >> $TS_OUTPUT.debug 2>&1 &
+done
+
+wait
+
+ts_finalize