blob 51b91b7e2a608ae463085abff1e4d5ccbe007abd 2727 bytes (raw)
name: tests/extra-ports.sh # note: path name is non-authoritative(*)
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
| | socket="t-socket-$$"
conf="t-conf-$$"
log="t-log-$$"
pid="t-pid-$$"
testfile1="t-testfile1-$$"
testfile2="t-testfile2-$$"
resultfile="t-resultfile-$$"
herd="herd -s $socket"
trap "cat $log || true;
rm -f $socket $conf $log $testfile1 $testfile2 $resultfile;
test -f $pid && kill \`cat $pid\` || true; rm -f $pid" EXIT
printf "test1" > "$testfile1"
printf "test2" > "$testfile2"
cat > "$conf"<<EOF
(register-services
(list (service
'(test-extra-ports)
#:requirement '()
#:start (lambda _
(call-with-input-file "$testfile1"
(lambda (test1)
(call-with-input-file "$testfile2"
(lambda (test2)
;; test1 and test2 should hopefully have adjacent fds
(define ports
(append
;; Fill up the fd range so that the source and
;; destination ranges overlap
(map (const test1)
(iota (- (min (fileno test1)
(fileno test2))
3)))
(sort (list test1 test2)
(lambda (a b)
(> (fileno a)
(fileno b))))))
(define command
(list
"sh"
"-c"
(string-append
"set -x;"
" cat >> ${resultfile}.tmp <&" (number->string
(fileno test1))
"; cat >> ${resultfile}.tmp <&" (number->string
(fileno test2))
"; mv ${resultfile}.tmp ${resultfile}")))
(fork+exec-command command
#:extra-ports
ports
#:directory
"$(pwd)"))))))
#:stop (const #f)
#:respawn? #f)))
EOF
rm -f "$pid"
shepherd -I -s "$socket" -c "$conf" -l "$log" --pid="$pid" &
while ! test -f "$pid" ; do sleep 0.3 ; done
shepherd_pid="`cat $pid`"
kill -0 $shepherd_pid
$herd start test-extra-ports
while ! test -f "$resultfile" ; do sleep 0.3 ; done
result="$(cat $resultfile)"
test "$result" = "test1test2" -o "$result" = "test2test1"
|
debug log:
solving 51b91b7 ...
found 51b91b7 in https://yhetil.org/guix-patches/20230818202239.21177-1-striness@tilde.club/
applying [1/1] https://yhetil.org/guix-patches/20230818202239.21177-1-striness@tilde.club/
diff --git a/tests/extra-ports.sh b/tests/extra-ports.sh
new file mode 100644
index 0000000..51b91b7
Checking patch tests/extra-ports.sh...
Applied patch tests/extra-ports.sh cleanly.
index at:
100644 51b91b7e2a608ae463085abff1e4d5ccbe007abd tests/extra-ports.sh
(*) Git path names are given by the tree(s) the blob belongs to.
Blobs themselves have no identifier aside from the hash of its contents.^
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).