lock_test: make more robust

Before, the test would rely on timeouts to work out. Instead, use marker files
to indicate whether to wait longer. Firstly to signal a blocking process should
end, secondly that it has indeed ended.

Also use a mktemp tempdir instead of /tmp
diff --git a/selftest/lock_test_help.py b/selftest/lock_test_help.py
index 0549981..7b6dfa1 100644
--- a/selftest/lock_test_help.py
+++ b/selftest/lock_test_help.py
@@ -1,17 +1,25 @@
 import sys
 import time
+import os
 
 import _prep
 
-from osmo_gsm_tester.util import FileLock
+from osmo_gsm_tester.util import FileLock, touch_file
 
-fl = FileLock('/tmp/lock_test', '_'.join(sys.argv[1:]))
+testdir, name = sys.argv[1:]
+stop_signalling_file = os.path.join(testdir, name)
+assert os.path.isfile(stop_signalling_file)
+
+lockfile_path = os.path.join(testdir, 'lock_test')
+fl = FileLock(lockfile_path, name)
 
 with fl:
     print('acquired lock: %r' % fl.owner)
     sys.stdout.flush()
-    time.sleep(0.5)
+    while os.path.exists(stop_signalling_file):
+        time.sleep(.1)
     print('leaving lock: %r' % fl.owner)
     sys.stdout.flush()
+touch_file(stop_signalling_file + '.done')
 
 # vim: expandtab tabstop=4 shiftwidth=4