lib/igt_kms: Unify pipe name helpers
[platform/upstream/intel-gpu-tools.git] / tests / drm_lib.sh
1 #!/bin/sh
2
3 # hacked-up long option parsing
4 for arg in $@ ; do
5         case $arg in
6                 --list-subtests)
7                         exit 79
8                         ;;
9                 --run-subtest)
10                         exit 79
11                         ;;
12         esac
13 done
14
15 die() {
16         echo "$@"
17         exit 1
18 }
19
20 do_or_die() {
21         $@ > /dev/null 2>&1 || (echo "FAIL: $@ ($?)" && exit -1)
22 }
23
24 if [ -d /debug/dri ] ; then
25         debugfs_path=/debug/dri
26 fi
27
28 if [ -d /sys/kernel/debug/dri ] ; then
29         debugfs_path=/sys/kernel/debug/dri
30 fi
31
32 i915_dfs_path=x
33 for minor in `seq 0 16`; do
34         if [ -f $debugfs_path/$minor/i915_error_state ] ; then
35                 i915_dfs_path=$debugfs_path/$minor
36                 break
37         fi
38 done
39
40 if [ $i915_dfs_path = "x" ] ; then
41         die " i915 debugfs path not found."
42 fi
43
44 # read everything we can
45 if [ `cat $i915_dfs_path/clients | wc -l` -gt "2" ] ; then
46         [ -n "$DRM_LIB_ALLOW_NO_MASTER" ] || \
47                 die "ERROR: other drm clients running"
48 fi
49
50 whoami | grep -q root || ( echo ERROR: not running as root; exit 1 )
51
52 i915_sfs_path=
53 if [ -d /sys/class/drm ] ; then
54     sysfs_path=/sys/class/drm
55     if [ -f $sysfs_path/card$minor/error ] ; then
56             i915_sfs_path="$sysfs_path/card$minor"
57     fi
58 fi
59 # sysfs may not exist as the 'error' is a new interface in 3.11
60
61 function drmtest_skip_on_simulation()
62 {
63         [ -n "$INTEL_SIMULATION" ] && exit 77
64 }
65
66 drmtest_skip_on_simulation