File: devmon.sh

package info (click to toggle)
finit 4.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,216 kB
  • sloc: ansic: 17,060; sh: 6,281; makefile: 532
file content (61 lines) | stat: -rwxr-xr-x 937 bytes parent folder | download
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
#!/bin/sh
#
# Verify device monitor (built-in plugin)
#

set -eu

TEST_DIR=$(dirname "$0")

test_teardown()
{
    say "Running test teardown."

    run "rm -f $FINIT_CONF /tmp/post"
}

# Cannot run mknod as non-root even in a chroot
# touch is close enough for our needs
mkdev()
{
    dir=$(dirname "$1")
    run "mkdir -p $dir"
    run "touch $1"
}

rmdev()
{
    run "rm $1"
}

test_one()
{
    cond="$1"
    node="/$cond"

    say "Checking cond $cond and device $node ..."
    run "echo service log:null \<$cond\> serv -np >> $FINIT_CONF"
    run "cat $FINIT_CONF"
    run "initctl reload"

    assert_status "serv" "waiting"

    mkdev "$node"
    assert_status "serv" "running"

    rmdev "$node"
    assert_status "serv" "waiting"

    say "Cleaning up ..."
    run "rm $FINIT_CONF"
    run "initctl reload"
}

# shellcheck source=/dev/null
. "$TEST_DIR/lib/setup.sh"

sep
test_one "dev/fbsplash"
sep
test_one "dev/subdir/42"
sep