aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/simple/driver.sh
blob: 1936631982804a223f8363536b4ef2c0eb7b8c96 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh
#
# Simple test driver: run test cases one by one, assuming test case
# will not trigger panic or reboot.
#
# Copyright (C) 2008, Intel Corp.
#   Author: Huang Ying <ying.huang@intel.com>
#
# This file is released under the GPLv2.
#

sd=$(dirname "$0")
export ROOT=`(cd $sd/../..; pwd)`

export driver=simple

. $ROOT/lib/functions.sh
setup_path
. $ROOT/lib/dirs.sh
. $ROOT/lib/mce.sh

tmp_klog=$WDIR/simple_klog_tmp

chk_err()
{
    if [ \( -n "$DEBUG_MCE_TEST" \) -a \( -s $err_log \) ]; then
	cat $err_log
    fi
}

klog_begin()
{
    dmesg > $tmp_klog.1
}

klog_end()
{
    dmesg | sed -e '1d' > $tmp_klog.2
    diff $tmp_klog.1 $tmp_klog.2 | grep '^> ' | sed 's/> \(.*\)/\1/' > $klog
}

trigger()
{
    reset_gcov

    $CDIR/$case_sh trigger
}

get_result()
{
    $CDIR/$case_sh get_result
}

test_all()
{
    if [ -n "$GCOV" ]; then
	if chk_gcov; then
	    export GCOV=copy
	    export KSRC_DIR
	else
	    echo "gcov is not supported by kernel, or there is no gcov utility installed, disable gcov support."
	    unset GCOV
	fi
    fi

    for case_sh in $CASES; do
	for this_case in $($CDIR/$case_sh enumerate); do
	    set_fake_panic 1

	    export this_case
	    mkdir -p $RDIR/$this_case
	    rm -rf $RDIR/$this_case/*
	    echo -e "\n$this_case:" | tee -a $RDIR/result
	    klog=$RDIR/$this_case/klog

	    mkdir -p $WDIR/$this_case
	    rm -rf $WDIR/$this_case/*
	    local err_log=$WDIR/$this_case/err_log

	    klog_begin
	    trigger 2>$err_log | tee -a $RDIR/result
	    chk_err
	    random_sleep
	    klog_end
	    get_result 2>$err_log | tee -a $RDIR/result
	    chk_err
	    $CDIR/$case_sh verify 2>$err_log | tee -a $RDIR/result
	    chk_err

	    set_fake_panic 0
	done
    done
}

if [ $# -lt 1 ]; then
    die "Usage: $0 <config>"
fi

conf=$(basename "$1")

. $CONF_DIR/$conf

driver_prepare
set_panic_on_oops 0

if [ -n "$START_BACKGROUND" ]; then
    eval $START_BACKGROUND
else
    start_background
fi

test_all

if [ -n "$STOP_BACKGROUND" ]; then
    eval $STOP_BACKGROUND
else
    stop_background
fi