tests: Add simple test for input accel

This commit is contained in:
Bastien Nocera
2021-01-19 16:30:25 +01:00
parent ccf5dbcd9e
commit 7a12f6bbc9
3 changed files with 81 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
@DEV /dev/input/event4
EVIOCGABS 0 0000000000FEFFFF00020000000000000000000000000000
EVIOCGABS(1) 0 00FFFFFF00FEFFFF00020000000000000000000000000000
EVIOCGABS(2) 0 0000000000FEFFFF00020000000000000000000000000000
EVIOCGABS(1) 0 0001000000FEFFFF00020000000000000000000000000000

54
tests/input-accel-device Normal file
View File

@@ -0,0 +1,54 @@
P: /devices/virtual/input/input159/event4
N: input/event4
E: DEVNAME=/dev/input/event4
E: MAJOR=13
E: MINOR=68
E: SUBSYSTEM=input
E: ID_INPUT=1
E: ID_INPUT_ACCELEROMETER=1
E: IIO_SENSOR_PROXY_TYPE=input-accel
E: SYSTEMD_WANTS=iio-sensor-proxy.service
E: TAGS=:systemd:
A: dev=13:68
L: device=../../input159
A: power/control=auto
A: power/runtime_active_time=0
A: power/runtime_status=unsupported
A: power/runtime_suspended_time=0
P: /devices/virtual/input/input159
E: PRODUCT=6/0/0/0
E: NAME="iio-sensor-proxy test application"
E: PROP=0
E: EV=9
E: ABS=7
E: MODALIAS=input:b0006v0000p0000e0000-e0,3,kra0,1,2,mlsfw
E: SUBSYSTEM=input
E: ID_INPUT=1
E: ID_INPUT_ACCELEROMETER=1
E: IIO_SENSOR_PROXY_TYPE=input-accel
E: SYSTEMD_WANTS=iio-sensor-proxy.service
E: TAGS=:systemd:seat:
A: capabilities/abs=7
A: capabilities/ev=9
A: capabilities/ff=0
A: capabilities/key=0
A: capabilities/led=0
A: capabilities/msc=0
A: capabilities/rel=0
A: capabilities/snd=0
A: capabilities/sw=0
A: id/bustype=0006
A: id/product=0000
A: id/vendor=0000
A: id/version=0000
A: modalias=input:b0006v0000p0000e0000-e0,3,kra0,1,2,mlsfw
A: name=iio-sensor-proxy test application
A: phys=
A: power/control=auto
A: power/runtime_active_time=0
A: power/runtime_status=unsupported
A: power/runtime_suspended_time=0
A: properties=0
A: uniq=

View File

@@ -125,7 +125,7 @@ class Tests(dbusmock.DBusTestCase):
# Daemon control and D-BUS I/O
#
def start_daemon(self, env = None):
def start_daemon(self, env = None, wrapper = None):
'''Start daemon and create DBus proxy.
When done, this sets self.proxy as the Gio.DBusProxy for power-profiles-daemon.
@@ -139,10 +139,14 @@ class Tests(dbusmock.DBusTestCase):
# have to do that ourselves
env['UMOCKDEV_DIR'] = self.testbed.get_root_dir()
self.log = tempfile.NamedTemporaryFile()
if os.getenv('VALGRIND') != None:
daemon_path = ['valgrind', self.daemon_path, '-v']
if wrapper:
daemon_path = wrapper + [ self.daemon_path ]
else:
daemon_path = [self.daemon_path, '-v']
daemon_path = [ self.daemon_path ]
if os.getenv('VALGRIND') != None:
daemon_path = ['valgrind'] + daemon_path + ['-v']
else:
daemon_path = daemon_path + ['-v']
self.daemon = subprocess.Popen(daemon_path,
env=env, stdout=self.log,
@@ -399,6 +403,20 @@ class Tests(dbusmock.DBusTestCase):
self.stop_daemon()
def test_input_accel(self):
'''input accelerometer'''
top_srcdir = os.getenv('top_srcdir', '.')
script = ['umockdev-run', '-d', top_srcdir + '/tests/input-accel-device',
'-i', '/dev/input/event4=%s/tests/input-accel-capture.ioctl' % (top_srcdir),
'--']
self.start_daemon(wrapper=script)
self.assertEqual(self.get_dbus_property('HasAccelerometer'), True)
self.assertEqual(self.get_dbus_property('AccelerometerOrientation'), 'normal')
self.stop_daemon()
#
# Helper methods
#