~sircmpwn/ctools

ref: cc69324393fda9bcbc73d30d1bda022263f012a8 ctools/test/nohup -rwxr-xr-x 705 bytes
cc693243 — Gabor Koszegi Correct tee SIGINT test 1 year, 11 months ago
                                                                                
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
#!/bin/sh
tool="nohup"
. "$HARNESS"

should_error_with_no_arg() (
	nohup
	[ $? = 127 ]
)

should_error_not_found() (
	nohup i-don-t-exist > "$TMPDIR/nohup.out"
	[ $? = 127 ]
)

should_error_cannot_execute() (
	echo > "$TMPDIR/a.tst"
	nohup "$TMPDIR/a.tst" > "$TMPDIR/nohup.out"
	[ $? = 126 ]
)

should_run_command() (
	nohup uname > "$TMPDIR/nohup.out" && \
		[ "$(uname)" = "$(cat "$TMPDIR/nohup.out")" ]
)

should_not_hup() (
	nohup sh -c 'sleep 2 && uname -a' > "$TMPDIR/nohup.out" &
	sleep 1
	kill -HUP $!
	wait && [ "$(cat "$TMPDIR/nohup.out")" = "$(uname -a)" ]
)

runtests \
	should_error_with_no_arg \
	should_error_not_found \
	should_error_cannot_execute \
	should_run_command \
	should_not_hup