[tor-commits] [oonib/master] Add script for killing the TravisCI spawned oonib after thirty seconds.

isis at torproject.org isis at torproject.org
Sat May 4 16:10:28 UTC 2013


commit 99d86cfb7a4944e57d179709168e5c7c7e9a64a3
Author: Isis Lovecruft <isis at torproject.org>
Date:   Sun Apr 21 07:25:37 2013 +0000

    Add script for killing the TravisCI spawned oonib after thirty seconds.
    
     * ∃!isisⒶwintermute:~/code/torproject/ooni-backend ∴ date
       Sun Apr 21 07:25:24 UTC 2013
       ∃!isisⒶwintermute:~/code/torproject/ooni-backend ∴ travis-lint
       Hooray, /home/isis/code/torproject/ooni-backend/.travis.yml seems to be solid!
---
 .travis.test.sh |   31 +++++++++++++++++++++++++++++++
 .travis.yml     |    2 +-
 2 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/.travis.test.sh b/.travis.test.sh
new file mode 100755
index 0000000..8af421d
--- /dev/null
+++ b/.travis.test.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+##############################################################################
+#
+# .travis.test.sh
+# -------------------
+# Run $2 for $1 seconds and then kill the process.
+#
+# :authors: Isis Agora Lovecruft, 0x2cdb8b35
+# :date: 21 April 2013
+# :version: 0.0.1
+##############################################################################
+
+function killitwithfire () {
+    trap - ALRM
+    kill -ALRM $prog 2>/dev/null
+    kill $! 2>/dev/null && exit 124
+}
+
+function waitforit () {
+    trap "killitwithfire" ALRM
+    sleep $1 & wait
+    kill -ALRM $$
+}
+
+waitforit $1& prog=$! ; shift ;
+trap "killitwithfire" ALRM INT
+"$@" & wait $1
+RET=$?
+kill -ALRM $prog
+wait $prog
+exit $RET
diff --git a/.travis.yml b/.travis.yml
index f347600..ac0bd29 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,4 +22,4 @@ script:
   - openssl x509 -req -days 365 -in server.csr -signkey private.key -out certificate.crt
   - test -f "private.key.org" && rm -f private.key.org
   - test -f "server.csr" && rm -f server.csr
-  - bin/oonib
+  - chmod +x .travis.test.sh && ./.travis.test.sh 30 bin/oonib





More information about the tor-commits mailing list