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