• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Software Inject library: Software inject specific functions
3#
4# Copyright (C) 2008, Intel Corp.
5#   Author: Huang Ying <ying.huang@intel.com>
6#
7# This file is released under the GPLv2.
8#
9
10if [ -n "$this_case" ]; then
11    bcase=$(basename $this_case)
12fi
13mcelog_result=$RDIR/$this_case/mcelog
14klog=$RDIR/$this_case/klog
15
16soft_inject_verify_mcelog()
17{
18    # check mcelog
19    if [ -f $RDIR/$this_case/mcelog ]; then
20	if [ -f $SDIR/refer/$bcase ]; then
21	    mcelog_refer=$SDIR/refer/$bcase
22	else
23	    mcelog_refer=$SDIR/data/$bcase
24	fi
25	mce_reformat $mcelog_refer $RDIR/$this_case/mcelog_refer
26
27	if mce_cmp $RDIR/$this_case/mcelog $mcelog_refer "$removes"; then
28	    echo "  Passed: MCE log is ok"
29	else
30	    echo "  Failed: MCE log is different from input"
31	fi
32    else
33	echo "  Failed: no MCE log result"
34    fi
35}
36
37soft_inject_get_klog()
38{
39    local klog=$RDIR/$this_case/klog
40    local orig_klog=$RDIR/$this_case/orig_klog
41
42    if [ -f $klog ]; then
43	cp $klog $orig_klog
44	filter_fake_panic $orig_klog $klog
45    fi
46}
47
48soft_inject_get_mcelog()
49{
50    case "$driver" in
51	simple*)
52	    get_mcelog_from_dev $mcelog_result
53	    ;;
54	kdump*)
55	    get_mcelog_from_klog $klog $mcelog_result
56	    ;;
57	*)
58	    echo '!!! Unsupported driver !!!'
59    esac
60}
61
62# verify return value
63soft_inject_verify_return_val()
64{
65    if [ -f $RDIR/$this_case/return ] && \
66	[ $(cat $RDIR/$this_case/return) -eq 0 ]; then
67	echo "  Passed: inject process continue"
68    else
69	echo "  Failed: inject process killed"
70    fi
71}
72
73soft_inject_verify_kill()
74{
75    if [ -f $RDIR/$this_case/return ] && \
76	[ $(cat $RDIR/$this_case/return) -eq 139 ]; then
77	echo "  Passed: inject process killed!"
78    else
79	echo "  Failed: Not killed"
80    fi
81}
82
83soft_inject_enumerate()
84{
85    local base=$(relative_path ${CDIR} ${SDIR})
86    [ -z "$base" ] && die "BUG!!! Please contact your software vendor!"
87    for c in $(cd $SDIR/data; ls *[^~]); do
88	echo $base/$c
89    done
90}
91
92soft_inject_trigger()
93{
94    mcelog &> /dev/null
95    case "$driver" in
96	kdump*)
97	    mce-inject --no-random $SDIR/data/$bcase
98	    ;;
99	*)
100	    mce-inject $SDIR/data/$bcase
101	    ;;
102    esac
103    ret=$?
104    echo $ret > $RDIR/$this_case/return
105    sleep 1
106}
107
108soft_inject_verify_panic()
109{
110    local mce_panic="$1"
111    verify_panic_via_klog $klog "$mce_panic"
112}
113
114soft_inject_verify_timeout()
115{
116    verify_timeout_via_klog $klog
117}
118
119soft_inject_verify_exp()
120{
121    verify_exp_via_klog $klog "$@"
122}
123
124soft_inject_main()
125{
126    op="$1"
127    shift
128
129    case "$op" in
130	enumerate)
131	    enumerate
132	    ;;
133	trigger)
134	    trigger "$@"
135	    ;;
136	get_result)
137	    get_result
138	    ;;
139	verify)
140	    verify
141	    ;;
142	*)
143	    die "Usage: $0 enumerate|trigger|get_result|verify"
144    esac
145    exit 0
146}
147