aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorReto Buerki <reet@codelabs.ch>2013-01-24 18:26:34 +0100
committerTobias Brunner <tobias@strongswan.org>2013-03-19 15:23:50 +0100
commit7b702150a091605dc3473f9d36ef05a22e6fcde7 (patch)
tree4b1df8cc09e7aa8b9f5707425cbf6f4e5d5f1a9a /testing
parent0e1d008d71b52bf84c28fd7ece4adc06e6df9976 (diff)
downloadstrongswan-7b702150a091605dc3473f9d36ef05a22e6fcde7.tar.bz2
strongswan-7b702150a091605dc3473f9d36ef05a22e6fcde7.tar.xz
Add expect-file guest image script
This script can be used in pretest.dat files to wait until a given file appears.
Diffstat (limited to 'testing')
-rwxr-xr-xtesting/hosts/default/usr/local/bin/expect-file29
1 files changed, 29 insertions, 0 deletions
diff --git a/testing/hosts/default/usr/local/bin/expect-file b/testing/hosts/default/usr/local/bin/expect-file
new file mode 100755
index 000000000..6921b6638
--- /dev/null
+++ b/testing/hosts/default/usr/local/bin/expect-file
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# Wait until a given file appears
+#
+# Params:
+# $1 - filename
+# $2 - maximum time to wait in seconds, default is 5 seconds
+
+if [[ $# -lt 1 || $# -gt 2 ]]
+then
+ echo "invalid arguments"
+ exit 1
+fi
+
+secs=$2
+[ ! $secs ] && secs=5
+
+let steps=$secs*10
+for i in `seq 1 $steps`
+do
+ # -f does not work for special files (e.g. UNIX domain sockets), use ls
+ # instead
+ ls $1 >/dev/null 2>&1
+ [ $? -eq 0 ] && exit 0
+ sleep 0.1
+done
+
+echo "File '$1' not available after $secs second(s)"
+exit 1