86 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03# Media Device Allocator API test script4# Copyright (c) 2019 Shuah Khan <shuah@kernel.org>5 6echo "Media Device Allocator testing: unbind and bind"7echo "media driver $1 audio driver $2"8 9MDRIVER=/sys/bus/usb/drivers/$110cd $MDRIVER11MDEV=$(ls -d *\-*)12 13ADRIVER=/sys/bus/usb/drivers/$214cd $ADRIVER15ADEV=$(ls -d *\-*.1)16 17echo "=================================="18echo "Test unbind both devices - start"19echo "Running unbind of $MDEV from $MDRIVER"20echo $MDEV > $MDRIVER/unbind;21 22echo "Media device should still be present!"23ls -l /dev/media*24 25echo "sound driver is at: $ADRIVER"26echo "Device is: $ADEV"27 28echo "Running unbind of $ADEV from $ADRIVER"29echo $ADEV > $ADRIVER/unbind;30 31echo "Media device should have been deleted!"32ls -l /dev/media*33echo "Test unbind both devices - end"34 35echo "=================================="36 37echo "Test bind both devices - start"38echo "Running bind of $MDEV from $MDRIVER"39echo $MDEV > $MDRIVER/bind;40 41echo "Media device should be present!"42ls -l /dev/media*43 44echo "Running bind of $ADEV from $ADRIVER"45echo $ADEV > $ADRIVER/bind;46 47echo "Media device should be there!"48ls -l /dev/media*49 50echo "Test bind both devices - end"51 52echo "=================================="53 54echo "Test unbind $MDEV - bind $MDEV - unbind $ADEV - bind $ADEV start"55 56echo "Running unbind of $MDEV from $MDRIVER"57echo $MDEV > $MDRIVER/unbind;58 59echo "Media device should be there!"60ls -l /dev/media*61 62sleep 163 64echo "Running bind of $MDEV from $MDRIVER"65echo $MDEV > $MDRIVER/bind;66 67echo "Media device should be there!"68ls -l /dev/media*69 70echo "Running unbind of $ADEV from $ADRIVER"71echo $ADEV > $ADRIVER/unbind;72 73echo "Media device should be there!"74ls -l /dev/media*75 76sleep 177 78echo "Running bind of $ADEV from $ADRIVER"79echo $ADEV > $ADRIVER/bind;80 81echo "Media device should be there!"82ls -l /dev/media*83 84echo "Test unbind $MDEV - bind $MDEV - unbind $ADEV - bind $ADEV end"85echo "=================================="86