summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/libgpiod/libgpiod-2.x
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-support/libgpiod/libgpiod-2.x')
-rw-r--r--meta-oe/recipes-support/libgpiod/libgpiod-2.x/gpio-manager.init76
-rw-r--r--meta-oe/recipes-support/libgpiod/libgpiod-2.x/run-ptest43
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
20DAEMON=/usr/bin/gpio-manager
21NAME=gpio-manager
22PIDFILE=/var/run/gpio-manager/pid
23DESC="GPIO manager daemon"
24
25test -x $DAEMON || exit 0
26test "$ENABLED" != "0" || exit 0
27
28do_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
46do_stop()
47{
48 echo -n "Stopping $DESC: "
49 start-stop-daemon --stop --quiet --pidfile $PIDFILE
50 echo "$NAME."
51 rm -f $PIDFILE
52}
53
54case "$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 ;;
74esac
75
76exit 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
3testbins="gpiod-test gpio-tools-test.bash gpiod-cxx-test"
4
5ptestdir=$(dirname "$(readlink -f "$0")") 3ptestdir=$(dirname "$(readlink -f "$0")")
6cd $ptestdir/tests 4cd $ptestdir/tests
7 5
6export GPIODBUS_TEST_DAEMON_PATH="$ptestdir/tests/gpio-manager"
7export 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.
10modprobe configfs 11modprobe configfs
11mountpoint /sys/kernel/config > /dev/null || mount -t configfs configfs /sys/kernel/config 12mountpoint /sys/kernel/config > /dev/null || mount -t configfs configfs /sys/kernel/config
12 13
13for testbin in $testbins; do 14# Make sure the daemon is not running during tests.
14 if test -e ./$testbin; then 15systemctl stop gpio-manager 2> /dev/null > /dev/null
15 ./$testbin > ./$testbin.out 2>&1 16service gpio-manager stop 2> /dev/null > /dev/null
16 if [ $? -ne 0 ]; then 17
17 echo "FAIL: $testbin" 18run_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
24done 27}
28
29run_one_test gpiod-test
30run_one_test gpio-tools-test.bash
31run_one_test gpiod-cxx-test
32run_one_test gpiod-glib-test
33
34# Wait for the leftover uevents to be emitted before running DBus tests.
35udevadm settle
36run_one_test gpiodbus-test
37
38udevadm settle
39gpio-manager 2> /dev/null > /dev/null &
40GPIO_MANAGER_PID=$!
41run_one_test gpiocli-test.bash
42kill $GPIO_MANAGER_PID
43wait $GPIO_MANAGER_PID