• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Simple test driver: run test cases one by one, assuming test case
4# will not trigger panic or reboot.
5#
6# Copyright (C) 2008, Intel Corp.
7#   Author: Huang Ying <ying.huang@intel.com>
8#
9# This file is released under the GPLv2.
10#
11
12sd=$(dirname "$0")
13export ROOT=`(cd $sd/../..; pwd)`
14
15export driver=simple
16
17. $ROOT/lib/functions.sh
18setup_path
19. $ROOT/lib/dirs.sh
20. $ROOT/lib/mce.sh
21
22tmp_klog=$WDIR/simple_klog_tmp
23
24chk_err()
25{
26    if [ \( -n "$DEBUG_MCE_TEST" \) -a \( -s $err_log \) ]; then
27	cat $err_log
28    fi
29}
30
31klog_begin()
32{
33    dmesg > $tmp_klog.1
34}
35
36klog_end()
37{
38    dmesg | sed -e '1d' > $tmp_klog.2
39    diff $tmp_klog.1 $tmp_klog.2 | grep '^> ' | sed 's/> \(.*\)/\1/' > $klog
40}
41
42trigger()
43{
44    reset_gcov
45
46    $CDIR/$case_sh trigger
47}
48
49get_result()
50{
51    $CDIR/$case_sh get_result
52}
53
54test_all()
55{
56    if [ -n "$GCOV" ]; then
57	if chk_gcov; then
58	    export GCOV=copy
59	    export KSRC_DIR
60	else
61	    echo "gcov is not supported by kernel or there is no " \
62		"gcov utility installed"
63	    echo "disabling gcov support."
64	    unset GCOV
65	fi
66    fi
67
68    #if mce_inject is a module, it is ensured to have been loaded
69    modinfo mce_inject > /dev/null 2>&1
70    if [ $? -eq 0 ]; then
71        lsmod | grep mce_inject > /dev/null 2>&1
72        [ $? -eq 0 ] || modprobe mce_inject
73        [ $? -eq 0 ] || die "module mce_inject isn't supported ?"
74    fi
75
76    for case_sh in $CASES; do
77	for this_case in $($CDIR/$case_sh enumerate); do
78	    set_fake_panic 1
79
80	    export this_case
81	    mkdir -p $RDIR/$this_case
82	    rm -rf $RDIR/$this_case/*
83	    echo -e "\n$this_case:" | tee -a $RDIR/result
84	    klog=$RDIR/$this_case/klog
85
86	    mkdir -p $WDIR/$this_case
87	    rm -rf $WDIR/$this_case/*
88	    local err_log=$WDIR/$this_case/err_log
89
90	    klog_begin
91	    trigger 2>$err_log | tee -a $RDIR/result
92	    chk_err
93	    random_sleep
94	    klog_end
95	    get_result 2>$err_log | tee -a $RDIR/result
96	    chk_err
97	    $CDIR/$case_sh verify 2>$err_log | tee -a $RDIR/result
98	    chk_err
99
100	    set_fake_panic 0
101	done
102    done
103}
104
105if [ $# -lt 1 ]; then
106    die "Usage: $0 <config>"
107fi
108
109conf=$(basename "$1")
110
111. $CONF_DIR/$conf
112
113driver_prepare
114set_panic_on_oops 0
115
116if [ -n "$START_BACKGROUND" ]; then
117    eval $START_BACKGROUND
118else
119    start_background
120fi
121
122[ -d $RDIR ] && mv $RDIR --backup=numbered -T $RDIR.old
123[ -d $WDIR ] && mv $WDIR --backup=numbered -T $WDIR.old
124
125test_all
126
127if [ -n "$STOP_BACKGROUND" ]; then
128    eval $STOP_BACKGROUND
129else
130    stop_background
131fi
132
133