diff options
Diffstat (limited to 'meta-oe/recipes-support/libgpiod/libgpiod-2.x')
-rw-r--r-- | meta-oe/recipes-support/libgpiod/libgpiod-2.x/gpio-manager.init | 76 | ||||
-rw-r--r-- | meta-oe/recipes-support/libgpiod/libgpiod-2.x/run-ptest | 43 |
2 files changed, 107 insertions, 12 deletions
diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.x/gpio-manager.init b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/gpio-manager.init new file mode 100644 index 0000000000..e36755eea2 --- /dev/null +++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/gpio-manager.init | |||
@@ -0,0 +1,76 @@ | |||
1 | #! /bin/sh | ||
2 | ### BEGIN INIT INFO | ||
3 | # Provides: gpio-manager | ||
4 | # Required-Start: $remote_fs $syslog | ||
5 | # Required-Stop: $remote_fs $syslog | ||
6 | # Default-Start: 2 3 4 5 | ||
7 | # Default-Stop: 1 | ||
8 | # Short-Description: Centralized GPIO manager daemon | ||
9 | ### END INIT INFO | ||
10 | # | ||
11 | # -*- coding: utf-8 -*- | ||
12 | # Debian init.d script for gpio-manager | ||
13 | # Copyright (c) 2024 Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | ||
14 | |||
15 | # set -e | ||
16 | |||
17 | # Source function library. | ||
18 | . /etc/init.d/functions | ||
19 | |||
20 | DAEMON=/usr/bin/gpio-manager | ||
21 | NAME=gpio-manager | ||
22 | PIDFILE=/var/run/gpio-manager/pid | ||
23 | DESC="GPIO manager daemon" | ||
24 | |||
25 | test -x $DAEMON || exit 0 | ||
26 | test "$ENABLED" != "0" || exit 0 | ||
27 | |||
28 | do_start() | ||
29 | { | ||
30 | mkdir -p "`dirname $PIDFILE`" | ||
31 | if [ -e $PIDFILE ]; then | ||
32 | PIDDIR=/proc/$(cat $PIDFILE) | ||
33 | if [ -d ${PIDDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then | ||
34 | echo "$DESC already started; not starting." | ||
35 | else | ||
36 | echo "Removing stale PID file $PIDFILE." | ||
37 | rm -f $PIDFILE | ||
38 | fi | ||
39 | fi | ||
40 | |||
41 | echo -n "Starting $DESC: " | ||
42 | start-stop-daemon --user gpio-manager --background --start --quiet --make-pidfile --pidfile $PIDFILE --exec $DAEMON | ||
43 | echo "$NAME." | ||
44 | } | ||
45 | |||
46 | do_stop() | ||
47 | { | ||
48 | echo -n "Stopping $DESC: " | ||
49 | start-stop-daemon --stop --quiet --pidfile $PIDFILE | ||
50 | echo "$NAME." | ||
51 | rm -f $PIDFILE | ||
52 | } | ||
53 | |||
54 | case "$1" in | ||
55 | start) | ||
56 | do_start | ||
57 | ;; | ||
58 | stop) | ||
59 | do_stop | ||
60 | ;; | ||
61 | status) | ||
62 | status $DAEMON | ||
63 | exit $? | ||
64 | ;; | ||
65 | restart) | ||
66 | do_stop | ||
67 | sleep 1 | ||
68 | do_start | ||
69 | ;; | ||
70 | *) | ||
71 | echo "Usage: /etc/init.d/$NAME {start|stop|status|restart}" >&2 | ||
72 | exit 1 | ||
73 | ;; | ||
74 | esac | ||
75 | |||
76 | exit 0 | ||
diff --git a/meta-oe/recipes-support/libgpiod/libgpiod-2.x/run-ptest b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/run-ptest index 29ec0d1027..eae172116f 100644 --- a/meta-oe/recipes-support/libgpiod/libgpiod-2.x/run-ptest +++ b/meta-oe/recipes-support/libgpiod/libgpiod-2.x/run-ptest | |||
@@ -1,24 +1,43 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | testbins="gpiod-test gpio-tools-test.bash gpiod-cxx-test" | ||
4 | |||
5 | ptestdir=$(dirname "$(readlink -f "$0")") | 3 | ptestdir=$(dirname "$(readlink -f "$0")") |
6 | cd $ptestdir/tests | 4 | cd $ptestdir/tests |
7 | 5 | ||
6 | export GPIODBUS_TEST_DAEMON_PATH="$ptestdir/tests/gpio-manager" | ||
7 | export PATH="$ptestdir/tests/:$PATH" | ||
8 | |||
8 | # libgpiod v2 uses gpio-sim - a configfs-based testing module. We need to | 9 | # libgpiod v2 uses gpio-sim - a configfs-based testing module. We need to |
9 | # make sure configfs is mounted before running any tests. | 10 | # make sure configfs is mounted before running any tests. |
10 | modprobe configfs | 11 | modprobe configfs |
11 | mountpoint /sys/kernel/config > /dev/null || mount -t configfs configfs /sys/kernel/config | 12 | mountpoint /sys/kernel/config > /dev/null || mount -t configfs configfs /sys/kernel/config |
12 | 13 | ||
13 | for testbin in $testbins; do | 14 | # Make sure the daemon is not running during tests. |
14 | if test -e ./$testbin; then | 15 | systemctl stop gpio-manager 2> /dev/null > /dev/null |
15 | ./$testbin > ./$testbin.out 2>&1 | 16 | service gpio-manager stop 2> /dev/null > /dev/null |
16 | if [ $? -ne 0 ]; then | 17 | |
17 | echo "FAIL: $testbin" | 18 | run_one_test() { |
18 | else | 19 | testbin="$1" |
19 | echo "PASS: $testbin" | 20 | |
20 | fi | 21 | ./$testbin > ./$testbin.out 2>&1 |
22 | if [ $? -ne 0 ]; then | ||
23 | echo "FAIL: $testbin" | ||
21 | else | 24 | else |
22 | echo "SKIP: $testbin" | 25 | echo "PASS: $testbin" |
23 | fi | 26 | fi |
24 | done | 27 | } |
28 | |||
29 | run_one_test gpiod-test | ||
30 | run_one_test gpio-tools-test.bash | ||
31 | run_one_test gpiod-cxx-test | ||
32 | run_one_test gpiod-glib-test | ||
33 | |||
34 | # Wait for the leftover uevents to be emitted before running DBus tests. | ||
35 | udevadm settle | ||
36 | run_one_test gpiodbus-test | ||
37 | |||
38 | udevadm settle | ||
39 | gpio-manager 2> /dev/null > /dev/null & | ||
40 | GPIO_MANAGER_PID=$! | ||
41 | run_one_test gpiocli-test.bash | ||
42 | kill $GPIO_MANAGER_PID | ||
43 | wait $GPIO_MANAGER_PID | ||