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.ok b/selftest/lock_test.ok
index 2c0f31b..0e3db40 100644
--- a/selftest/lock_test.ok
+++ b/selftest/lock_test.ok
@@ -1,7 +1,7 @@
-acquired lock: 'long_name'
-launched first, locked by: long_name
-launched second, locked by: long_name
-leaving lock: 'long_name'
+acquired lock: 'long name'
+launched first, locked by: long name
+launched second, locked by: long name
+leaving lock: 'long name'
 acquired lock: 'shorter'
 waited, locked by: shorter
 leaving lock: 'shorter'