summaryrefslogtreecommitdiffstats
path: root/tests/test7.tst
blob: 7dab5fc54716b167c9e4918e8ce8a5aa59fcf576 (plain)
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
#!/bin/sh

source ${CURDIR}/tests/functions

#
# Test orphanskill feature (explicit)
#
header "Test orphanskill feature (explicit)"
runcmd "$MOCKCMD --offline --init"
runcmd "$MOCKCMD --offline --copyin tests/daemontest.c /tmp"
runcmd "$MOCKCMD --offline --chroot -- gcc -Wall -o /tmp/daemontest /tmp/daemontest.c"
echo -e "#!/bin/sh\n/tmp/daemontest\nsleep 60\n" >> $CHROOT/tmp/try
# the following should launch about three processes in the chroot: bash, sleep, daemontest
$MOCKCMD --offline --chroot -- bash /tmp/try &
mockpid=$!
sleep 1
# now we 'prematurely' kill mock. This should leave the three orphans above
sudo kill -9 $mockpid
if ! pgrep daemontest; then
    echo "Daemontest failed. daemontest should be running now but is not."
    exit 1
fi
$MOCKCMD --offline --orphanskill 
if pgrep daemontest; then
    echo "Daemontest FAILED. found a daemontest process running after exit." 
    exit 1
fi