File: 0020-Add-regression-test-for-forced-rescan-feature.patch

package info (click to toggle)
runit 2.2.0-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,116 kB
  • sloc: ansic: 6,033; sh: 2,544; makefile: 399
file content (113 lines) | stat: -rw-r--r-- 3,549 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
From: Dmitry Bogatov <KAction@debian.org>, <Lorenzo Puliti plorenzo@disroot.org>
Date: 2019-2024
Forwarded: <not-needed>
Subject: refresh, squash 0022,0024,0026 into 0020 and rework the test
Rework the test to address the inability of quilt to preserve permission
or newly created files; the test needs the exec bit, but quilt remove it every
times pop and push are performed (known issue, see #682025  and #749069); as a result
the build fails.
Workaround is to copy the testscript and chmod it in makefile...
To simplify things the setup (directories and the timestamp service)
are created and removed by the test script

Subject: 0020 Add regression test for forced-rescan feature
From: Dmitry Bogatov <KAction@debian.org>
Date: Fri, 26 Jul 2019 07:23:35 +0000

This patch squash 0022,0024,0026 into 0020:

Subject: 0022 Check force-rescan delay more precisely
From: Dmitry Bogatov <KAction@debian.org>
Date: 15 Sep 2019 23:42:50 +0000
Use `data +%s%N` in src/t/runtest.sh to check with nano-second precision
how much time pass between SIGALRM sent and control pipe of new service
appear.

Subject: 0024-Fix-forced-rescan-test-adding-runsv-path.patch
From: <Lorenzo Puliti plorenzo@disroot.org>
Date: 2020-04-11
Fix test failure on sbuild (see #941273 and #941322)
 The test fails in sbuild or in any other environment where runit is not installed
 because runsvdir can't find runsv in PATH. The fix adds the build directory at the
 beginning of PATH in order to make sure that runsvdir pick the right runsv when the
 test is done on machine where runit is installed.

Subject: <0026-Clean up at the end of forced rescan test>
From: <Lorenzo Puliti plorenzo@disroot.org>

--- a/runit-2.2.0/src/Makefile
+++ b/runit-2.2.0/src/Makefile
@@ -4,6 +4,10 @@
 
 check: $(IT)
 	./check-local $(IT)
+	cp ./runsvdir-rescan.test ./dorunsvdir-rescan.test
+	chmod +x ./dorunsvdir-rescan.test
+	./dorunsvdir-rescan.test
+	rm -f ./dorunsvdir-rescan.test
 
 runit: load runit.o unix.a byte.a
 	./load runit unix.a byte.a
--- /dev/null
+++ b/runit-2.2.0/src/runsvdir-rescan.test
@@ -0,0 +1,60 @@
+#!/bin/bash
+set -eu
+
+echo "Checking runsvdir-forced-rescan feature"
+
+trap 'rm -rf "${ctmp}"' EXIT
+
+ctmp="`pwd`/test-tmp"
+rm -rf "${ctmp}"
+
+install -d -m 0777 "${ctmp}"/empty
+ln -s   "${ctmp}"/empty   "${ctmp}"/service
+
+#timestamp service setup
+install -d -m 0777 "${ctmp}"/sv/timestamp
+echo '#!/bin/sh' >"${ctmp}"/sv/timestamp/run
+echo 'date +%s%N >&2' >>"${ctmp}"/sv/timestamp/run
+echo 'exec tail -f /dev/null' >>"${ctmp}"/sv/timestamp/run
+chmod 700 "${ctmp}"/sv/timestamp/run
+
+#runsvdir need to know where to find runsv
+#otherwise it uses the one from the host system, if any
+PATH=`pwd`:$PATH  runsvdir "${ctmp}"/service &
+echo "pid = $!"
+# Wait till runsvdir scans directory and concludes it is empty
+sleep 1
+now=$(date +%s%N)
+echo "now = ${now}"
+unlink "${ctmp}"/service
+ln -sf   "${ctmp}"/sv  "${ctmp}"/service
+#rescan with alrm
+kill -ALRM $!
+
+# Wait until runsvdir discovers ""${ctmp}"/service/timestamp" symbolic link
+# and is ready to accept commands on control pipe.
+
+while ! test -e "${ctmp}"/sv/timestamp/supervise/control ; do
+    sleep 0.001
+done
+
+new=$(date +%s%N)
+echo "new = ${new}"
+kill -HUP $!
+
+diff=$((new - now))
+echo "diff = ${diff}"
+
+#wait for runsvdir to finish, to avoid race in testdir removal
+wait
+
+if [[ ${diff} -lt 1000000000 ]] ; then
+    echo "fine. forced-rescan seems to work"
+    sleep 1
+    exit 0
+else
+    echo "bad. forced-rescan took too long"
+    sleep 1
+    exit 1
+fi
+