File: cli

package info (click to toggle)
policykit-1 122-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,280 kB
  • sloc: ansic: 20,980; sh: 12,380; xml: 4,321; cpp: 1,031; makefile: 173; python: 124; javascript: 83; sed: 16; perl: 11
file content (49 lines) | stat: -rwxr-xr-x 1,297 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
set -eu

assert_fail() {
    if $1 2>&1; then
        echo "FAIL: command '$1' unexpectedly succeeded" >&2
        exit 1
    fi
}

assert_eq() {
    if [ "$1" != "$2" ]; then
        echo "FAIL: expected: '$2' actual: '$1'" >&2
        exit 1
    fi
}

assert_in() {
    if ! echo "$2" | grep -q "$1"; then
        echo "FAIL: '$1' not found in:" >&2
        echo "$2" >&2
        exit 1
    fi
}

if [ $(id -u) = 0 ]; then
    # lxc autopkgtest containers don't always have dbus already running
    service dbus start || :
fi

if ! [ -e /run/dbus/system_bus_socket ]; then
    echo "SKIP: dbus system bus not running and could not be started"
    exit 77
fi

echo "TEST: pkaction"
assert_in "org.freedesktop.policykit.exec" "$(pkaction)"
assert_eq "org.freedesktop.policykit.exec" "$(pkaction -a org.freedesktop.policykit.exec)"
assert_in "active.*auth_admin" "$(pkaction --verbose -a org.freedesktop.policykit.exec)"
assert_fail "pkaction -a unknown.action"

echo "TEST: pkcheck"
if [ $(id -u) = 0 ]; then
    assert_eq "" "$(pkcheck -a org.freedesktop.policykit.exec -p 1)"
    assert_eq "" "$(pkcheck -a org.freedesktop.policykit.exec -p $$)"
else
    assert_fail "pkcheck -a org.freedesktop.policykit.exec -p 1"
    assert_fail "pkcheck -a org.freedesktop.policykit.exec -p $$"
fi