summaryrefslogtreecommitdiff
path: root/tests/ZZ_hangman
blob: 6b310bc9a7b500620bde465c51266724e509c3a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
#
# Testcase: Simulate gpu hang
#
# This check uses the stop_rings facility to exercise the gpu hang code.
# by reading /sys/kernel/debug/dri/0/i915_emon_status too quickly
#

SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
. $SOURCE_DIR/drm_lib.sh

oldpath=`pwd`

cd $i915_dfs_path

if [ ! -f i915_ring_stop ] ; then
	echo "kernel doesn't support ring stopping"
	exit 77
fi

function check_iface {
    dir="$1"
    file="$2"
    mandatory="$3"

    [ -z "$dir" ] && return

    path="$dir/$file"
    echo checking ${path}

    if [ ! -f "$path" ] ; then
	if [  $mandatory != 0 ] ; then
	    echo "'${path}' not found";
	    exit 1;
	else
	    echo "${path} not mandatory";
	    return;
	fi
    fi

    if cat "$path" | grep -v "no error state collected" > /dev/null ; then
	echo "gpu hang detected"
	exit 2
    fi

    echo 0xf > i915_ring_stop
    echo "rings stopped"

    (cd $oldpath; $SOURCE_DIR/gem_exec_big) > /dev/null

    if cat "$path" | grep -v "no error state collected" > /dev/null ; then
	echo "gpu hang correctly detected"
    else
	echo "gpu hang not detected"
	exit 3
    fi

# clear error state
    echo > "$path"

    if cat "$path" | grep -v "no error state collected" > /dev/null ; then
	echo "gpu hang still present"
	exit 4
    fi
}

check_iface "$i915_dfs_path" i915_error_state 1
check_iface "$i915_sfs_path" error 0

exit 0