• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# APEI ERST firmware interface and implementation has no multiple users
4# in mind. For example, there is four records in storage with ID: 1, 2,
5# 3 and 4, if two ERST readers enumerate the records via
6# GET_NEXT_RECORD_ID as follow,
7#
8# reader 1             reader 2
9# 1
10#                      2
11# 3
12#                      4
13# -1
14#                      -1
15#
16# where -1 signals there is no more record ID.
17#
18# Reader 1 has no chance to check record 2 and 4, while reader 2 has no
19# chance to check record 1 and 3. And any other GET_NEXT_RECORD_ID will
20# return -1, that is, other readers will has no chance to check any
21# record even they are not cleared by anyone.
22#
23# This makes raw GET_NEXT_RECORD_ID not suitable for usage of multiple
24# users.
25#
26# This issue has been resolved since 2.6.39-rc1, so please run this case
27# with Linux kernel >=2.6.39-rc1
28#
29# This program is free software; you can redistribute it and/or
30# modify it under the terms of the GNU General Public
31# License as published by the Free Software Foundation; version 2.
32#
33# This program is distributed in the hope that it will be useful,
34# but WITHOUT ANY WARRANTY; without even the implied warranty of
35# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
36# General Public License for more details.
37#
38# You should find a copy of v2 of the GNU General Public License somewhere
39# on your Linux system; if not, write to the Free Software Foundation,
40# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
41#
42# Copyright (C) 2011, Intel Corp.
43# Author: Chen Gong <gong.chen@intel.com>
44#
45
46
47ID=0xdeadbeaf
48ERST=./erst-inject
49LOG=./erst.log
50MODSTATUS=0
51
52err()
53{
54       echo "$*"
55       echo "test fails"
56       exit 1
57}
58
59#prepare the test env
60ls /dev/erst_dbg >/dev/null 2>&1
61if [ ! $? -eq 0 ]; then
62       modinfo erst_dbg > /dev/null 2>&1
63       [ $? -eq 0 ] || err "please ensure module erst_dbg existing"
64       modprobe erst_dbg
65       [ $? -eq 0 ] || err "fail to load module erst_dbg"
66       MODSTATUS=1
67fi
68
69ls $ERST > /dev/null 2>&1
70[ $? -eq 0 ] || err "please compile the test program first"
71
72echo "write one error record into ERST..."
73$ERST -i $ID 1>/dev/null
74if [ ! $? -eq 0 ]; then
75       err "ERST writing operation fails"
76fi
77echo "done"
78# read all error records in ERST
79$ERST -p > $LOG
80echo "check if existing the error record written before..."
81grep -q $ID $LOG
82if [ ! $? -eq 0 ]; then
83       err "don't find the error record written before in ERST"
84fi
85echo "done"
86
87echo "clear the error record written before..."
88$ERST -c $ID 1>/dev/null
89if [ ! $? -eq 0 ]; then
90       err "ERST writing opertion fails"
91fi
92echo "done"
93
94#read all error records again
95$ERST -p > $LOG
96
97echo "check if the error record has been cleared..."
98grep -q $ID $LOG
99if [ $? -eq 0 ]; then
100       err "ERST clearing opertion fails"
101fi
102echo "done"
103echo -e "\ntest passes"
104
105rm -f $LOG
106if [ $MODSTATUS -eq 1 ]; then
107       rmmod -f erst_dbg
108fi
109