72da4ad47f1bb0d5182706f82c9563ea30fadb28
[platform/upstream/intel-gpu-tools.git] / tests / drm_lib.sh
1 #!/bin/sh
2 die() {
3         echo "$@"
4         exit 1
5 }
6
7 if [ -d /debug/dri ] ; then
8         debugfs_path=/debug/dri
9 fi
10
11 if [ -d /sys/kernel/debug/dri ] ; then
12         debugfs_path=/sys/kernel/debug/dri
13 fi
14
15 i915_dfs_path=x
16 for dir in `ls $debugfs_path` ; do
17         if [ -f $debugfs_path/$dir/i915_error_state ] ; then
18                 i915_dfs_path=$debugfs_path/$dir
19                 break
20         fi
21 done
22
23 if [ $i915_dfs_path = "x" ] ; then
24         die " i915 debugfs path not found."
25 fi
26
27 # read everything we can
28 if [ `cat $i915_dfs_path/clients | wc -l` -gt "2" ] ; then
29         die "ERROR: other drm clients running"
30 fi
31
32 if [ -d /sys/class/drm ] ; then
33     sysfs_path=/sys/class/drm
34 fi
35
36 i915_sfs_path=x
37 for dir in `ls $sysfs_path` ; do
38     if [ -f $sysfs_path/$dir/error_state ] ; then
39         i915_sfs_path=$sysfs_path/$dir
40         break
41     fi
42 done
43
44 if [ $i915_sfs_path = "x" ] ; then
45     die " i915 sysfs path not found."
46 fi
47