summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-07-06 18:04:32 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-07-06 18:04:32 +0200
commita7f89980e5b3f4b9a74c70dbc5ffe8aabd28be28 (patch)
tree41c4deec1fdfbafd7821b4ca7a9772ac0abd92f5 /test
Imported Upstream version 2.9.3upstream/2.9.3
Diffstat (limited to 'test')
-rw-r--r--test/Kconfig12
-rw-r--r--test/Makefile325
-rw-r--r--test/Makefile-2463
-rw-r--r--test/Makefile-269
-rw-r--r--test/dopanic.833
-rw-r--r--test/dopanic_drv.c51
-rwxr-xr-xtest/ipmievt.sh45
-rwxr-xr-xtest/make26017
-rwxr-xr-xtest/panicsel-c.sh19
-rwxr-xr-xtest/panicsel-k.sh13
-rw-r--r--test/panicsel_apptool_test.sh550
-rw-r--r--test/panicsel_test_needreboot.sh162
-rwxr-xr-xtest/retro.sh37
-rw-r--r--test/sensor-CG2100.txt148
-rw-r--r--test/sensor-TIGW1U.txt106
-rwxr-xr-xtest/testipmi.sh400
-rw-r--r--test/unittest.cmd125
-rwxr-xr-xtest/unittest.sh254
18 files changed, 2369 insertions, 0 deletions
diff --git a/test/Kconfig b/test/Kconfig
new file mode 100644
index 0000000..0c24991
--- /dev/null
+++ b/test/Kconfig
@@ -0,0 +1,12 @@
+#
+# DOPANIC device configuration
+#
+
+menu "DOPANIC"
+config DOPANIC
+ tristate 'Do Panic'
+ help
+ This causes a Linux kernel panic when loaded.
+ If unsure, say N.
+
+endmenu
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..2c5ba97
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,325 @@
+################################################################################
+#
+#
+# Copyright(c) 1999 - 2007 Intel Corporation. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# The full GNU General Public License is included in this distribution in the
+# file called LICENSE.
+#
+# Contact Information:
+# Linux NICS <linux.nics@intel.com>
+# Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+#
+################################################################################
+MYDIR =$(shell echo `pwd`)
+
+###########################################################################
+# Driver files
+
+# core driver files
+CFILES = dopanic_drv.c
+HFILES =
+ifeq (,$(BUILD_KERNEL))
+BUILD_KERNEL=$(shell uname -r)
+endif
+
+###########################################################################
+# Environment tests
+
+# Kernel Search Path
+# All the places we look for kernel source
+KSP := /lib/modules/$(BUILD_KERNEL)/source \
+ /lib/modules/$(BUILD_KERNEL)/build \
+ /usr/src/linux-$(BUILD_KERNEL) \
+ /usr/src/linux-$($(BUILD_KERNEL) | sed 's/-.*//') \
+ /usr/src/kernel-headers-$(BUILD_KERNEL) \
+ /usr/src/kernel-source-$(BUILD_KERNEL) \
+ /usr/src/linux-$($(BUILD_KERNEL) | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
+ /usr/src/linux
+
+# prune the list down to only values that exist
+# and have an include/linux sub-directory
+test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
+KSP := $(foreach dir, $(KSP), $(test_dir))
+
+# we will use this first valid entry in the search path
+ifeq (,$(KSRC))
+ KSRC := $(firstword $(KSP))
+endif
+
+ifeq (,$(KSRC))
+ $(error Linux kernel source not found)
+else
+ifeq (/lib/modules/$(shell uname -r)/source, $(KSRC))
+ KOBJ := /lib/modules/$(shell uname -r)/build
+else
+ KOBJ := $(KSRC)
+endif
+endif
+
+# check for version.h and autoconf.h for running kernel in /boot (SUSE)
+ifneq (,$(wildcard /boot/vmlinuz.version.h))
+ VERSION_FILE := /boot/vmlinuz.version.h
+ CONFIG_FILE := /boot/vmlinuz.autoconf.h
+ KVER := $(shell $(CC) $(CFLAGS) -E -dM $(VERSION_FILE) | \
+ grep UTS_RELEASE | awk '{ print $$3 }' | sed 's/\"//g')
+ ifeq ($(KVER),$(shell uname -r))
+ # set up include path to override headers from kernel source
+ x:=$(shell rm -rf include)
+ x:=$(shell mkdir -p include/linux)
+ x:=$(shell cp /boot/vmlinuz.version.h include/linux/version.h)
+ x:=$(shell cp /boot/vmlinuz.autoconf.h include/linux/autoconf.h)
+ CFLAGS += -I./include
+ else
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+ CONFIG_FILE := $(KSRC)/include/linux/autoconf.h
+ endif
+else
+ VERSION_FILE := $(KOBJ)/include/linux/version.h
+ CONFIG_FILE := $(KSRC)/include/linux/autoconf.h
+endif
+
+ifeq (,$(wildcard $(VERSION_FILE)))
+ $(error Linux kernel source not configured - missing version.h)
+endif
+
+ifeq (,$(wildcard $(CONFIG_FILE)))
+ $(error Linux kernel source not configured - missing config.h)
+endif
+
+# pick a compiler
+ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
+ CC := kgcc gcc cc
+else
+ CC := gcc cc
+endif
+test_cc = $(shell $(cc) --version > /dev/null 2>&1 && echo $(cc))
+CC := $(foreach cc, $(CC), $(test_cc))
+CC := $(firstword $(CC))
+ifeq (,$(CC))
+ $(error Compiler not found)
+endif
+
+# we need to know what platform the driver is being built on
+# some additional features are only built on Intel platforms
+ARCH := $(shell uname -m | sed 's/i.86/i386/')
+ifeq ($(ARCH),alpha)
+ CFLAGS += -ffixed-8 -mno-fp-regs
+endif
+ifeq ($(ARCH),x86_64)
+ CFLAGS += -mcmodel=kernel -mno-red-zone
+endif
+ifeq ($(ARCH),ppc)
+ CFLAGS += -msoft-float
+endif
+ifeq ($(ARCH),ppc64)
+ CFLAGS += -m64 -msoft-float
+ LDFLAGS += -melf64ppc
+endif
+
+# standard flags for module builds
+CFLAGS += -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall
+CFLAGS += -I$(KSRC)/include -I.
+CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
+ echo "-DMODVERSIONS -DEXPORT_SYMTAB \
+ -include $(KSRC)/include/linux/modversions.h")
+
+CFLAGS += $(CFLAGS_EXTRA)
+#ifeq (,$(shell echo $(CFLAGS_EXTRA) | grep NAPI))
+#CFLAGS += -DE1000_NO_NAPI
+#CFLAGS_EXTRA += -DE1000_NO_NAPI
+#endif
+
+RHC := $(KSRC)/include/linux/rhconfig.h
+ifneq (,$(wildcard $(RHC)))
+ # 7.3 typo in rhconfig.h
+ ifneq (,$(shell $(CC) $(CFLAGS) -E -dM $(RHC) | grep __module__bigmem))
+ CFLAGS += -D__module_bigmem
+ endif
+endif
+
+# get the kernel version - we use this to find the correct install path
+KVER := $(shell $(CC) $(CFLAGS) -E -dM $(VERSION_FILE) | grep UTS_RELEASE | \
+ awk '{ print $$3 }' | sed 's/\"//g')
+
+KKVER := $(shell echo $(KVER) | \
+ awk '{ if ($$0 ~ /2\.[4-9]\./) print "1"; else print "0"}')
+# ifeq ($(KKVER), 0)
+# $(error *** Aborting the build. \
+# *** This driver is not supported on kernel versions older than 2.4.0)
+# endif
+
+# set the install path
+INSTDIR := /lib/modules/$(KVER)/kernel/drivers/char
+
+# look for SMP in config.h
+SMP := $(shell $(CC) $(CFLAGS) -E -dM $(CONFIG_FILE) | \
+ grep CONFIG_SMP | awk '{ print $$3 }')
+ifneq ($(SMP),1)
+ SMP := 0
+endif
+
+ifneq ($(SMP),$(shell uname -a | grep SMP > /dev/null 2>&1 && echo 1 || echo 0))
+ $(warning ***)
+ ifeq ($(SMP),1)
+ $(warning *** Warning: kernel source configuration (SMP))
+ $(warning *** does not match running kernel (UP))
+ else
+ $(warning *** Warning: kernel source configuration (UP))
+ $(warning *** does not match running kernel (SMP))
+ endif
+ $(warning *** Continuing with build,)
+ $(warning *** resulting driver may not be what you want)
+ $(warning ***)
+endif
+
+ifeq ($(SMP),1)
+ CFLAGS += -D__SMP__
+endif
+
+# Any special handling for this driver
+
+###########################################################################
+# 2.4.x & 2.6.x Specific rules
+
+K_VERSION:=$(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
+
+ifeq ($(K_VERSION), 2.6)
+
+# Makefile for 2.6.x kernel
+TARGET = dopanic.ko
+
+# man page
+MANSECTION = 8
+MANFILE = $(TARGET:.ko=.$(MANSECTION))
+# ifeq (,$(wildcard /etc/SuSE-release))
+# CFLAGS_DOPANIC += -I$(KSRC)/include/asm/mach-generic
+# CFLAGS_EXTRA += $(CFLAGS_DOPANIC)
+# endif
+
+ifneq ($(PATCHLEVEL),)
+EXTRA_CFLAGS += $(CFLAGS_EXTRA)
+obj-m += dopanic.o
+dopanic-objs := $(CFILES:.c=.o)
+else
+default:
+ifeq ($(KOBJ),$(KSRC))
+ make -C $(KSRC) V=1 SUBDIRS=$(shell pwd) modules
+else
+ make -C $(KSRC) V=1 O=$(KOBJ) SUBDIRS=$(shell pwd) modules
+endif
+endif
+
+else # ifeq ($(K_VERSION),2.6)
+
+# Makefile for 2.4.x kernel
+TARGET = dopanic
+
+# man page
+MANSECTION = 8
+MANFILE = $(TARGET:.o=.$(MANSECTION))
+
+# Get rid of compile warnings in kernel header files from SuSE
+ifneq (,$(wildcard /etc/SuSE-release))
+ CFLAGS += -Wno-sign-compare -fno-strict-aliasing
+endif
+
+# Get rid of compile warnings in kernel header files from fedora
+ifneq (,$(wildcard /etc/fedora-release))
+ CFLAGS += -fno-strict-aliasing
+endif
+
+.SILENT: $(TARGET)
+$(TARGET): $(filter-out $(TARGET), $(CFILES:.c=.o))
+ $(LD) $(LDFLAGS) -r $^ -o $@
+ echo; echo
+ echo "**************************************************"
+ echo "** $(TARGET) built for $(KVER)"
+ echo -n "** SMP "
+ if [ "$(SMP)" = "1" ]; \
+ then echo "Enabled"; else echo "Disabled"; fi
+ echo "**************************************************"
+ echo
+
+$(CFILES:.c=.o): $(HFILES) Makefile
+default:
+ echo "** CFLAGS = $(CFLAGS)"
+ make
+
+endif # ifeq ($(K_VERSION),2.6)
+
+ifeq (,$(MANDIR))
+ # find the best place to install the man page
+ MANPATH := $(shell (manpath 2>/dev/null || echo $MANPATH) | sed 's/:/ /g')
+ ifneq (,$(MANPATH))
+ # test based on inclusion in MANPATH
+ test_dir = $(findstring $(dir), $(MANPATH))
+ else
+ # no MANPATH, test based on directory existence
+ test_dir = $(shell [ -e $(dir) ] && echo $(dir))
+ endif
+ # our preferred install path
+ # should /usr/local/man be in here ?
+ MANDIR := /usr/share/man /usr/man
+ MANDIR := $(foreach dir, $(MANDIR), $(test_dir))
+ MANDIR := $(firstword $(MANDIR))
+endif
+ifeq (,$(MANDIR))
+ # fallback to /usr/man
+ MANDIR := /usr/man
+endif
+
+# depmod version for rpm builds
+DEPVER := $(shell /sbin/depmod -V 2>/dev/null | \
+ awk 'BEGIN {FS="."} NR==1 {print $$2}')
+
+###########################################################################
+# Build rules
+
+$(MANFILE).gz: ../$(MANFILE)
+ gzip -c $< > $@
+
+install: default $(MANFILE).gz
+ # remove all old versions of the driver
+ find $(INSTALL_MOD_PATH)/lib/modules/$(KVER) -name $(TARGET) -exec rm -f {} \; || true
+ find $(INSTALL_MOD_PATH)/lib/modules/$(KVER) -name $(TARGET).gz -exec rm -f {} \; || true
+ install -D -m 644 $(TARGET) $(INSTALL_MOD_PATH)$(INSTDIR)/$(TARGET)
+ifeq (,$(INSTALL_MOD_PATH))
+ /sbin/depmod -a || true
+else
+ ifeq ($(DEPVER),1 )
+ /sbin/depmod -r $(INSTALL_MOD_PATH) -a || true
+ else
+ /sbin/depmod -b $(INSTALL_MOD_PATH) -a -n > /dev/null || true
+ endif
+endif
+ install -D -m 644 $(MANFILE).gz $(INSTALL_MOD_PATH)$(MANDIR)/man$(MANSECTION)/$(MANFILE).gz
+ man -c -P'cat > /dev/null' $(MANFILE:.$(MANSECTION)=) || true
+
+uninstall:
+ if [ -e $(INSTDIR)/$(TARGET) ] ; then \
+ rm -f $(INSTDIR)/$(TARGET) ; \
+ fi
+ /sbin/depmod -a
+ if [ -e $(MANDIR)/man$(MANSECTION)/$(MANFILE).gz ] ; then \
+ rm -f $(MANDIR)/man$(MANSECTION)/$(MANFILE).gz ; \
+ fi
+
+.PHONY: clean install
+
+clean:
+ rm -rf $(TARGET) $(TARGET:.ko=.o) $(TARGET:.ko=.mod.c) $(TARGET:.ko=.mod.o) $(CFILES:.c=.o) $(MANFILE).gz .*cmd .tmp_versions
diff --git a/test/Makefile-24 b/test/Makefile-24
new file mode 100644
index 0000000..51f01af
--- /dev/null
+++ b/test/Makefile-24
@@ -0,0 +1,63 @@
+#
+# Makefile for building the dopanic module on Linux 2.4
+#
+
+MOD=dopanic
+MOD_CONF= $(MOD:%=%.conf)
+RHVER=RH7.1
+KVER=2.6.0
+KTAG=
+KSRC=/usr/src/linux
+# Note: /usr/src/linux should point to /usr/src/linux-$(KVER)$(KTAG).
+# The KVER is only used here for "make install".
+
+CC=gcc
+#Use the cflags that shows all warnings or the one that doesn't.
+#CFLAGS = -O2 -Wall -DLINUX_DEBUG
+CFLAGS = -O2
+
+#Note: Use the following to build a driver with no versioning.
+#K_CFLAGS = -D__KERNEL__ -DMODULE -D__SMP__ -DCONFIG_X86_LOCAL_APIC -D__NO_VERSION__
+#
+#The K_CFLAGS is used to build on all RedHat systems.
+#ADDK_CFLAGS is used only when building on pre RedHat 7.0 systems.
+#
+K_CFLAGS = -D__KERNEL__ -DMODULE -D__SMP__ -DCONFIG_X86_LOCAL_APIC -DMODULES
+ADDK_CFLAGS = -DMODVERSIONS -include /usr/include/linux/modversions.h
+
+CPPFLAGS = -I. -DLINUX -I/usr/src/linux/include
+
+K_VERSION:=$(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
+ifeq ($(K_VERSION), 2.6)
+ TARGET = dopanic.ko
+ # CFILES = dopanic.c
+ # dopanic-objs := $(CFILES:.c=.o)
+ obj-m += dopanic.o
+ make -C $(KSRC) V=1 SUBDIRS=$(shell pwd) modules
+endif
+
+#List all the relevant files here
+OBJS = dopanic.o
+
+all: $(MOD)
+
+$(MOD): $(OBJS)
+ $(LD) -r -o $(MOD) $(OBJS)
+
+%.o: %.c
+ if [ "$(RHVER)" = "PRE-7.0" ]; \
+ then \
+ $(CC) -c $(CFLAGS) $(CPPFLAGS) $(K_CFLAGS) $(ADDK_CFLAGS) -o $@ $< ; \
+ else \
+ $(CC) -c $(CFLAGS) $(CPPFLAGS) $(K_CFLAGS) -o $@ $< ; \
+ fi
+
+install: $(MOD)
+ cp $(MOD) /lib/modules/$(KVER)$(KTAG)/kernel/arch/i386/kernel
+
+clean:
+ rm -f $(OBJS) $(MOD)
+
+clobber:
+ rm -f $(OBJS) $(MOD)
+
diff --git a/test/Makefile-26 b/test/Makefile-26
new file mode 100644
index 0000000..e682f1a
--- /dev/null
+++ b/test/Makefile-26
@@ -0,0 +1,9 @@
+#
+# Makefile for the dopanic module.
+#
+
+TARGET = dopanic.ko
+
+CONFIG_DOPANIC=m
+
+obj-$(CONFIG_DOPANIC) += dopanic.o
diff --git a/test/dopanic.8 b/test/dopanic.8
new file mode 100644
index 0000000..edc1725
--- /dev/null
+++ b/test/dopanic.8
@@ -0,0 +1,33 @@
+.TH DOPANIC 8 "Version 1.0: 28 Feb 2007"
+.SH NAME
+dopanic \- kernel module to cause a panic
+.SH SYNOPSIS
+.B "insmod ./dopanic.ko"
+
+.SH DESCRIPTION
+dopanic is a Linux kernel module that calls panic when it is loaded.
+
+This can be used to test the CONFIG_IPMI_PANIC_STRING feature in
+the OpenIPMI driver.
+
+.SH "SEE ALSO"
+pefconfig(8) showsel(8)
+
+.SH WARNINGS
+Be sure to sync your filesystem before using this module.
+See http://ipmiutil.sourceforge.net/ for the latest version and any bug fix list.
+
+.SH COPYRIGHT
+Copyright (C) 2007 Intel Corp.
+.PP
+See the file COPYING in the distribution for more details
+regarding redistribution.
+.PP
+This utility is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY.
+
+.SH AUTHOR
+.PP
+Andy Cress <arcress at users.sourceforge.net>
+.br
+
diff --git a/test/dopanic_drv.c b/test/dopanic_drv.c
new file mode 100644
index 0000000..a8540ff
--- /dev/null
+++ b/test/dopanic_drv.c
@@ -0,0 +1,51 @@
+/* dopanic.c
+ *
+ * Cause a panic in a loadable driver.
+ */
+#include <linux/kernel.h> /* We're doing kernel work */
+#include <linux/module.h> /* Specifically, a module */
+
+static int device_open(void *inode,
+ void *file)
+{
+ printk (KERN_DEBUG "device_open(%p,%p)\n", inode, file);
+ return 0;
+}
+
+static int device_release(void *inode,
+ void *file)
+{
+ printk ("device_release(%p,%p)\n", inode, file);
+ return 0;
+}
+
+
+static int device_read(void *file,
+ char *buffer, /* The buffer to fill with data */
+ int length, /* The length of the buffer */
+ int *offset) /* Our offset in the file */
+{
+ return 0;
+}
+
+static int device_write(void *file,
+ const char *buffer, /* The buffer */
+ int length, /* The length of the buffer */
+ int *offset) /* Our offset in the file */
+{
+ return -1;
+}
+
+/* Initialize the module */
+int init_module()
+{
+ panic("dopanic: init_module calls panic");
+ return 0;
+}
+
+
+/* Cleanup - unregister the appropriate file from /proc */
+void cleanup_module()
+{
+}
+
diff --git a/test/ipmievt.sh b/test/ipmievt.sh
new file mode 100755
index 0000000..e61c1d6
--- /dev/null
+++ b/test/ipmievt.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+# ipmievt.sh - generate an IPMI temperature event
+#
+# Baseboard Temp is usually index 0d, 0e or 15, & sensor num 0x30
+# Note that values displayed/used are in hex.
+#
+# sensor |grep -i "Baseboard Temp"
+# 000d SDR Full 01 39 20 a 01 snum 30 Baseboard Temp = 2f OK 47.00 degrees C
+# ^^=ibasetemp ^^=nbasetemp ^^+4=lotemp
+#
+pattn="Temp"
+sensorfil=/var/lib/ipmiutil/sensor_out.txt
+if [ ! -f $sensorfil ]; then
+ sensorfil=/usr/share/ipmiutil/sensor_out.txt
+fi
+# get sensor readings again, since current temp may have changed
+ipmiutil sensor >$sensorfil
+#ibasetemp=0d
+#nbasetemp=30 # usually snum 30 on my test unit
+#lotemp=33
+nbasetemp=`grep -i "$pattn" $sensorfil |head -n1|awk '{print $10}'`
+ibasetemp=`grep "snum $nbasetemp" $sensorfil |awk '{print $1}'`
+curtemp=`grep "snum $nbasetemp" $sensorfil| cut -f2 -d'=' |awk '{print $3}'|cut -f1 -d'.'`
+lotemp=`expr $curtemp + 4`
+hitemp=`expr $curtemp - 4`
+hinorm=`expr $curtemp + 25`
+
+if [ "x$curtemp" = "x" ]; then
+ echo "Cannot find sensor reading for /$pattn/ in $sensorfil"
+ exit 1
+fi
+
+echo "Setting $pattn upper threshold to $hitemp - current temp = $curtemp"
+# cause a crit-hi for Baseboard Temp
+ipmiutil sensor -i $ibasetemp -t -n $nbasetemp -h $hitemp
+
+# give it 2 secs before clearing to OK
+sleep 2
+# put Baseboard Temp back to OK
+ipmiutil sensor -i $ibasetemp -t -n $nbasetemp -h $hinorm
+
+sleep 1
+# show the SEL events
+ipmiutil sel -l6
+
diff --git a/test/make260 b/test/make260
new file mode 100755
index 0000000..7a914b0
--- /dev/null
+++ b/test/make260
@@ -0,0 +1,17 @@
+# build dopanic as a linux 2.6 module
+#
+kdir=/usr/src/linux
+basename=dopanic
+
+# gcc -Wp,-MD,${basename}.o.d -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=pentium3 -I$kdir/include/asm-i386/mach-default -D__KERNEL__ -I$kdir/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=pentium3 -I$kdir/include/asm-i386/mach-default -fomit-frame-pointer -DMODULE -c -o ${basename}.o ${basename}.c
+# gcc -Wp,-MD,${basename}.mod.o.d -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=pentium3 -I$kdir/include/asm-i386/mach-default -D__KERNEL__ -I$kdir/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=pentium3 -I$kdir/include/asm-i386/mach-default -fomit-frame-pointer -DMODULE -c -o ${basename}.mod.o ${basename}.mod.c
+# ld -m elf_i386 -r -o ${basename}.ko ${basename}.o ${basename}.mod.o
+
+mkdir -p $kdir/drivers/char/dopanic
+cp dopanic.c $kdir/drivers/char/dopanic
+cp Kconfig $kdir/drivers/char/dopanic
+cp Makefile-26 $kdir/drivers/char/dopanic/Makefile
+make -C $kdir V=1 SUBDIRS=drivers/char/dopanic modules
+
+ls -l $kdir/drivers/char/dopanic/dopanic.ko
+
diff --git a/test/panicsel-c.sh b/test/panicsel-c.sh
new file mode 100755
index 0000000..c668be8
--- /dev/null
+++ b/test/panicsel-c.sh
@@ -0,0 +1,19 @@
+# ABAT test for panicsel component utilities
+# tag: rh71__build
+# util=/usr/share/panicsel/showsel
+util=/usr/sbin/isel
+echo "panicsel component, basic acceptance test"
+if [ ! -f $util ]
+then
+ echo "%%FAILURE%%"
+ exit 1
+fi
+$util >/dev/null 2>&1
+if [ $? -eq 0 ]
+then
+ echo "%%SUCCESS%%"
+ exit 0
+else
+ echo "%%FAILURE%%"
+ exit 1
+fi
diff --git a/test/panicsel-k.sh b/test/panicsel-k.sh
new file mode 100755
index 0000000..6737698
--- /dev/null
+++ b/test/panicsel-k.sh
@@ -0,0 +1,13 @@
+# ABAT test for panicsel kernel patch
+# tag: panicsel__build
+echo "panicsel kernel patch (BMC_PANIC), basic acceptance test"
+# dmesg |grep "BMC IPMI" >/dev/null 2>&1
+dmesg |grep bmc_panic >/dev/null 2>&1
+if [ $? -eq 0 ]
+then
+ echo "%%SUCCESS%%"
+ exit 0
+else
+ echo "%%FAILURE%%"
+ exit 1
+fi
diff --git a/test/panicsel_apptool_test.sh b/test/panicsel_apptool_test.sh
new file mode 100644
index 0000000..475f305
--- /dev/null
+++ b/test/panicsel_apptool_test.sh
@@ -0,0 +1,550 @@
+#!/bin/sh
+linux_type="redhat"
+# pkg=panicsel
+# isel=showsel
+# ipef=pefconfig
+# iserial=tmconfig
+pkg=ipmiutil
+isel=isel
+ipef=ilan
+iserial=iserial
+iselout=/tmp/isel.out
+ipefout=/tmp/pefconfigoutput
+
+basic_test()
+{
+ $isel > /dev/null 2>&1
+ if [ "$?" -eq 0 ];then
+ echo "PASS_BASIC: The $isel tool can run correctly"
+ return 0
+ else
+ echo "FAIL_BASIC: The $isel tool can not run correctly"
+ return 1
+ fi
+}
+showsel_ov()
+{
+ $isel -v|grep version|grep -v BMC > /dev/null
+ if [ "$?" -eq "0" ];then
+ $isel -v|grep "Free" > /dev/null 2>&1
+ if [ "$?" -eq 0 ];then
+ echo "PASS: $isel option -v testing"
+ return 0
+ else
+ echo "FAIL: $isel testing -v fail"
+ fi
+ else
+ echo "FAIL: $isel testing -v fail"
+ return 1
+ fi
+}
+
+showsel_oc()
+{
+ message_original=`$isel|wc -l`
+ $isel -c > /dev/null 2>&1
+ message_now=`$isel|wc -l`
+ if [ "$message_original" -ge "$message_now" ];then
+ echo "PASS: $isel option -c testing"
+ return 0
+ else
+ echo "FAIL: $isel option -c testing"
+ return 1
+ fi
+}
+
+check_os()
+{
+ if [ -d "/usr/src/redhat" ];then
+ linux_type="redhat"
+ fi
+ if [ -d "/usr/src/hardhat" ];then
+ linux_type="hardhat"
+ fi
+}
+
+check_driver()
+{
+ lsmod|grep "ipmi_comb" > /dev/null 2>&1
+ if [ $? -eq 0 ];then
+ echo "The ipmi_comb driver has been inserted already"
+ Major=`cat /proc/devices|grep imb|awk '{print $1}'`
+ if [ ! -c /dev/imb ];then
+ mknod /dev/imb c $Major 0
+ fi
+ return 1
+ fi
+ modprobe "ipmi_comb" > /dev/null 2>&1
+ if [ $? -eq 0 ];then
+ echo "The ipmi_comb driver be inserted corretly"
+ else
+ # echo "There are no ipmi driver or ipmi driver can not be inserted correctly"
+ return 1
+ fi
+
+ lsmod|grep "ipmi_comb" > /dev/null 2>&1
+ if [ $? -eq 0 ];then
+ Major=`cat /proc/devices|grep imb|awk '{print $1}'`
+ if [ ! -c /dev/imb ];then
+ mknod /dev/imb c $Major 0
+ fi
+ fi
+
+}
+showsel_ow()
+{
+ cp -f /var/log/messages /tmp/tempbackup
+ if [ ! -d /usr/share/$pkg ];then
+ mkdir /usr/share/$pkg
+ fi
+ if [ -f /usr/share/$pkg/sel.idx ];then
+ rm -f sel.idx
+ fi
+ $isel -w > /dev/null 2>&1
+ idx=`cat /usr/share/$pkg/sel.idx |awk '{ print $2}'`
+ diff /var/log/messages /tmp/tempbackup > /tmp/diff_log
+ log=`cat /tmp/diff_log|grep $idx`
+ if [ -n "$idx" -a -n "$log" ];then
+ echo "PASS: $isel option w"
+ else
+ echo "FAIL: $isel option w"
+ fi
+
+}
+###########################################
+#test show OS critical message correctly###
+###########################################
+showsel_os()
+{
+ $isel > $iselout
+ osnumber=`grep "OS Critical Stop" $iselout|wc -l`
+ if [ $osnumber -eq 0 ];then
+ echo "SKIP: $isel option s - no OS critical messages"
+ return 1
+ fi
+ $isel -s >$iselout
+ osnumber=`grep "OS Critical Stop" $iselout|wc -l`
+ if [ $? -eq 0 -a $osnumber -gt 0 ];then
+ echo " PASS: $isel option s "
+ return 0
+ else
+ echo "FAIL: $isel option s"
+ return 1
+ fi
+
+}
+showsel_test()
+{
+ check_os
+ check_driver
+ basic_test
+ if [ "$?" -eq 0 ];then
+ showsel_ov
+ showsel_oc
+ showsel_ow
+ showsel_os
+ fi
+}
+#####################################################################
+#test pefconfig can read PEF entry ###
+#####################################################################
+pefconfig_basic()
+{
+ if [ -f $ipefout ];then
+ rm -rf $ipefout
+ fi;
+ $ipef -r > $ipefout 2>&1
+ pefnumber=`grep PEFilter $ipefout|wc -l`
+ lannumber=`grep Lan $ipefout|wc -l`
+ if [ $pefnumber -ge 12 ];then
+ echo "PASS: $ipef basic requirement "
+ return 0
+ else
+ echo "FAIL: $ipef basic requirement"
+ return 1
+ fi;
+ if [ -f $ipefout ];then
+ rm -rf $ipefout
+ fi;
+}
+
+#####################################################################
+#test pefconfig can enable or disable the new PEF 0x20 events ###
+#####################################################################
+pefconfig_od()
+{
+ ipefdout=/tmp/pefconfigoutputd
+ if [ -f $ipefdout ];then
+ rm $ipefdout
+ fi
+ $ipef -d > $ipefdout 2>&1
+ disable=`cat $ipefdout|grep "Access = Disabled"`
+ if [ -n "$disable" ];then
+ echo "PASS: pefconfig disable OS critical Event "
+ return 0
+ else
+ echo "FAIL: pefconfig disable OS critical Event "
+ return 1
+ fi
+}
+
+#####################################################################
+#test pefconfig can write new entry at different offset than 12 ###
+#####################################################################
+ts_pefconfign()
+{
+total=`$ipef -r | grep PEFilter | wc -l`
+total=`echo $((total))`
+PASS="PASS"
+tmp_num=$1
+num=`echo $((tmp_num))`
+peftmp=/tmp/ipefn
+if [ "$num" -le "$total" ];then
+ $ipef -n $num |grep PEFilter|tail -n $num > ${peftmp}_$num
+ $ipef -r |grep PEFilter|head -n $num > ${peftmp}_r$num
+ dif=`diff ${peftmp}_$num ${peftmp}_r$num`
+ if [ -n "$dif" ];then
+ PASS="FAIL"
+ fi
+ rm -f ${peftmp}_$num
+ rm -f ${peftmp}_r$num
+else
+ succnum=`$ipef e -x -n $num |grep SetPefEntry|awk '{print $2}'|grep "successful"|wc -l`
+ succnum=`echo $((succnum))`
+ eqnum=`expr $num \* 2 - 1`
+ if [ "$succnum" -eq "$eqnum" ];then
+ lastrecord=`$ipef -n 15 |grep PEFilter|tail -n 1|awk '{print $3}'`
+ if [ $lastrecord -ne "80" ];then
+ PASS="FAIL"
+ fi
+ fi
+fi
+ if [ $PASS == "$FAIL" ];then
+ echo "FAIL: $ipef -n" $1
+ else
+ echo "PASS: $ipef -n" $1
+ fi
+}
+#####################################################################
+#test pefconfig can output more debug information ###
+#####################################################################
+ts_pefconfigx()
+{
+ ipefxout=/tmp/pefconfigoutputx
+ if [ -f $ipefout ];then
+ rm -rf $ipefout
+ fi
+ if [ -f $ipefxout ];then
+ rm -rf $ipefxout
+ fi
+ $ipef -x >> $ipefxout
+ test=`grep "PEF record" $ipefxout`
+ if [ ! -z test ];then
+ echo "PASS: $ipef parameter x "
+ return 0
+ else
+ echo "FAIL: $ipef parameter x"
+ return 1
+ fi
+ if [ -f $ipefxout ];then
+ rm -rf $ipefxout
+ fi
+
+}
+##############################################################
+#Basic function for testing pefconfig configuration
+################################################################
+get_host_ip_address()
+{
+ ifconfig|grep "inet addr"|grep -v "127.0.0.1"|awk '{print $2}'|cut -d: -f2
+}
+get_host_mac_address()
+{
+ ifconfig|grep eth0|awk '{print $5}'
+}
+get_route_ip_address()
+{
+ netstat -rn|grep eth0|grep UG|awk '{print $2}'
+ #cat /proc/net/arp|grep -v "HW"|awk '{print $1}'
+}
+get_route_mac_address()
+{
+ routeip=`get_route_ip_address`
+ cat /proc/net/arp|grep -v "HW"|grep $routeip|awk '{print $4}'
+}
+get_subnet_mask_address()
+{
+ ifconfig|grep Mask|grep -v "127.0.0.1"|awk '{print $4}'|cut -d: -f2
+}
+get_alert_ip_address()
+{
+ cat /etc/snmp/snmpd.conf|grep trapsink|cut -f2 -d' '
+}
+get_alert_mac_address()
+{
+ routip=get_route_ip_address
+ arping -c 1 $routeip > /dev/null 2>&1
+ arping -c 2 $1|grep reply|tail -1|awk '{print $5}'|cut -c2-18
+}
+
+get_pef_ip_address()
+{
+ cat $1|grep $2|grep -v "Param"|awk '{print $2}'|cut -d= -f2
+}
+get_pef_mac_address()
+{
+ cat $1|grep $2|grep -v "Param"|awk '{print $3}'|cut -d= -f2
+}
+check_pef()
+{
+ cat $1|grep "SetLanEntry"|grep "($2"|awk '{print $4}'
+}
+upper()
+{
+ echo $1|tr 'a-z' 'A-Z'
+}
+####################################################
+#Test pefconfig set host ip and mac addresses
+###################################################
+
+ts_pefconfig_sethost()
+{
+ rm /tmp/pefconfig_host
+ ip=`get_host_ip_address`
+ mac=`get_host_mac_address`
+ ip=192.168.2.222
+ # $ipef -I $ip -M $mac > /tmp/pefconfig_host 2>&1
+ $ipef -e -I $ip > /tmp/pefconfig_host 2>&1
+ setip=`get_pef_ip_address /tmp/pefconfig_host eth0`
+ setmac=`get_pef_mac_address /tmp/pefconfig_host eth0`
+ setmac=`upper $setmac`
+ isip=`check_pef /tmp/pefconfig_host 3`
+ ismac=`check_pef /tmp/pefconfig_host 4`
+ # if [ $mac == $setmac ] && [ $ismac -eq 0 ]; then
+ if [ $ip == $setip ] && [ $isip -eq 0 ] ; then
+ echo "PASS: $ipef Set host ip address to $ip"
+ return 0
+ else
+ echo "FAIL: $ipef Set host ip address"
+ return 1
+ fi
+}
+###############################################################
+##Test pefconfig set route ip and mac addresses
+###############################################################
+ts_pefconfig_setroute()
+{
+ ip=`get_route_ip_address`
+ count=`get_route_ip_address`
+ mac=`get_route_mac_address`
+ $ipef -e -G $ip -H $mac > /tmp/pefconfig_route 2>&1
+ setip=`get_pef_ip_address /tmp/pefconfig_route gateway`
+ setmac=`get_pef_mac_address /tmp/pefconfig_route gateway`
+ setmac=`upper $setmac`
+ isip=`check_pef /tmp/pefconfig_route 12`
+ ismac=`check_pef /tmp/pefconfig_route 13`
+ if [ $ip == $setip ] && [ $mac == $setmac ] \
+ && [ $isip -eq 0 ] && [ $ismac -eq 0 ];then
+ echo "PASS: $ipef Set route ip $ip and mac address"
+ return 0
+ else
+ echo "FAIL: $ipef Set route ip and mac address"
+ return 1
+ fi
+}
+get_alert_setip_address()
+{
+ cat $1|grep $2|awk '{print $3}'|cut -d= -f2
+}
+get_alert_setmac_address()
+{
+ cat $1|grep $2|awk '{print $4}'|cut -d= -f2
+}
+ps_pefconfig_setalert()
+{
+ rm -f /tmp/pefconfig_alert > /dev/null 2>&1
+ ip=`get_host_ip_address`
+ mac=`get_host_mac_address`
+ $ipef -A $ip -B $mac > /tmp/pefconfig_alert 2>&1
+ setip=`get_alert_setip_address /tmp/pefconfig_alert alert`
+ setmac=`get_alert_setmac_address /tmp/pefconfig_alert alert`
+ setmac=`upper $setmac`
+ isip=`check_pef /tmp/pefconfig_alert 18`
+ ismac=`check_pef /tmp/pefconfig_alert 19`
+ if [ $ip == $setip ] && [ $mac == $setmac ] \
+ && [ $isip -eq 0 ] && [ $ismac -eq 0 ];then
+ echo "PASS: $ipef Set alert"
+ return 0
+ else
+ echo "FAIL: $ipef Set Alert"
+ return 1
+ fi
+}
+###########################################################
+#Test pefconfig set community
+###########################################################
+ts_pefconfig_setcommunity()
+{
+ rm -f /tmp/pefconfig_comm
+ $ipef -A 127.0.0.1 -C private > /tmp/pefconfig_comm 2>&1
+ pef_comm=`cat /tmp/pefconfig_comm|grep Community|awk '{print $5}'`
+ if [ $pef_comm == "private" ];then
+ echo "PASS: $ipef set community"
+ return 0
+ else
+ echo "FAIL: $ipef set community"
+ return 1
+ fi
+}
+get_pef_subnet()
+{
+ a=`cat $1|grep Subnet|awk '{print $5}'`
+ b=`cat $1|grep Subnet|awk '{print $6}'`
+ c=`cat $1|grep Subnet|awk '{print $7}'`
+ d=`cat $1|grep Subnet|awk '{print $8}'`
+ echo $a.$b.$c.$d
+}
+##############################################################
+#Test pefconfig set subnet mask
+###############################################################
+ts_pefconfig_setsubnet()
+{
+
+ subnet=`get_subnet_mask_address`;
+ $ipef -S $subnet > /tmp/pefconfig_subnet 2>&1
+ pef_subnet=`get_pef_subnet /tmp/pefconfig_subnet`
+ if [ $subnet == $pef_subnet ];then
+ echo "PASS: $ipef get sub net mask address"
+ return 0
+ else
+ echo "FAIL: $ipef get sub net mask address"
+ return 1
+ fi
+}
+
+pefconfig_test()
+{
+ pefconfig_basic
+ if [ "$?" -eq 0 ];then
+ ts_pefconfign 9
+ ts_pefconfign 12
+ ts_pefconfign 16
+ ts_pefconfigx
+ ts_pefconfig_sethost
+ ts_pefconfig_setroute
+ ts_pefconfig_setsubnet
+ else
+ echo "System does not support pefconfig function"
+ fi
+}
+#*****************************************************/
+#Test the tmconfig util******************************/
+#*****************************************************/
+EntryTest()
+{
+ which $iserial > /dev/null 2>&1
+ if [ $? -ne 0 ];then
+ if [ -f /usr/share/$pkg/$iserial ];then
+ cp -f /usr/share/$pkg/$iserial /usr/sbin
+ else
+ echo "$iserial: there is no $iserial util"
+ exit 1
+ fi
+ fi
+}
+TestPara()
+{
+ result=`cat $1|grep $2|awk '{print $4}'|cut -d , -f 1`
+ if [ "x$result" = "x" ]; then
+ echo "FAIL: $iserial $2, no result"
+ return 1
+ fi
+ if [ $result -eq 0 ];then
+ echo "PASS: $iserial $2"
+ return 0
+ else
+ echo "FAIL: $iserial $2"
+ return 1
+ fi
+
+}
+ts_tmconfigr()
+{
+ infoline="$iserial Test parameter r"
+ EntryTest
+ $iserial -r > /dev/null 2>&1
+ if [ $? -eq 0 ];then
+ echo "PASS: $infoline"
+ return 0
+ else
+ echo "FAIL: $infoline"
+ return 1
+ fi
+}
+
+ts_tmconfigs()
+{
+ infoline="$iserial Test parameter n"
+ EntryTest
+ $iserial -s > /tmp/tmconfigs 2>&1
+ TestPara /tmp/tmconfigs "SetChanAcc(ser)" $infoline
+}
+ts_tmconfigup()
+{
+ infoline="$iserial Test parameter u and p"
+ EntryTest
+ $iserial -u root -p password >/dev/null 2>&1
+ if [ $? -eq 0 ];then
+ echo PASS: $infoline
+ else
+ echo FAIL: $infoline
+ fi
+}
+LanTest()
+{
+ infoline="$iserial Test parameter l"
+ $iserial -l > /tmp/tmconfigl
+ line=`cat /tmp/tmconfigl|grep "Lan Param"|wc -l`
+ if [ $line -ge 22 ];then
+ echo "PASS: $infoline"
+ else
+ echo "FAIL: $infoline"
+ fi
+}
+ts_tmconfigl()
+{
+ EntryTest
+ LanTest
+}
+
+ts_tmconfign()
+{
+ infoline="$iserial Test parameter m0"
+ EntryTest
+ $iserial -m0 >/tmp/tmconfign 2>&1
+ TestPara /tmp/tmconfign "SetSerialMux(System)" $infoline
+}
+ts_tmconfigt()
+{
+ infoline="$iserial Test parameter m1"
+ EntryTest
+ $iserial -m1 >/tmp/tmconfigt 2>&1
+ TestPara /tmp/tmconfigt "SetSerialMux(BMC)" $infoline
+}
+
+tmconfig_test()
+{
+ ts_tmconfigr
+ if [ $? -eq 0 ];then
+ ts_tmconfigs
+ ts_tmconfigl
+ ts_tmconfign
+ ts_tmconfigup
+ ts_tmconfigt
+ else
+ echo "FAIL:Basic tmconfig testing"
+ fi
+}
+showsel_test
+pefconfig_test
+tmconfig_test
diff --git a/test/panicsel_test_needreboot.sh b/test/panicsel_test_needreboot.sh
new file mode 100644
index 0000000..61a183f
--- /dev/null
+++ b/test/panicsel_test_needreboot.sh
@@ -0,0 +1,162 @@
+#!/bin/sh
+# pkg=panicsel
+# isel=showsel
+# ipef=pefconfig
+# ireset=hwreset
+pkg=ipmiutil
+isel=isel
+ipef=ilan
+ireset=ireset
+env()
+{
+ if [ -x /usr/local/bin/$isel ];then
+ PATH_EXEC="/usr/local/bin"
+ fi
+ if [ -x /usr/sbin/$isel ];then
+ PATH_EXEC="/usr/sbin"
+ fi
+}
+check_os()
+{
+ if [ -d "/etc/redhat-release" ];then
+ linux_type="redhat"
+ fi
+ if [ -d "/etc/SuSE-release" ];then
+ linux_type="suse"
+ fi
+ if [ -d "/usr/src/hardhat" ];then
+ linux_type="hardhat"
+ fi
+}
+
+check_driver()
+{
+ lsmod|grep "ipmi_comb" > /dev/null 2>&1
+ if [ $? -eq 0 ];then
+ echo "The ipmi_comb driver has been inserted already"
+ Major=`cat /proc/devices|grep imb|awk '{print $1}'`
+ if [ ! -c /dev/imb ];then
+ mknod /dev/imb c $Major 0
+ return 0
+ fi
+ fi
+
+ modprobe "ipmi_comb" > /dev/null 2>&1
+ if [ $? -eq 0 ];then
+ echo "The ipmi_comb driver be inserted corretly"
+ else
+ # echo "There are no ipmi driver or ipmi driver can not be inserted correctly"
+ return 0
+ fi
+
+ lsmod|grep "ipmi_comb" > /dev/null 2>&1
+ if [ $? -eq 0 ];then
+ Major=`cat /proc/devices|grep imb|awk '{print $1}'`
+ if [ ! -c /dev/imb ];then
+ mknod /dev/imb c $Major 0
+ fi
+ fi
+
+}
+
+prepare()
+{
+ env
+ # check_driver
+}
+Test_kernelpatch()
+{
+ oldnum=0
+ newnum=0
+ prepare
+ DIR=`pwd`
+ if [ -f /tmp/mark ];then
+ MARK=`cat /tmp/mark`
+ else
+ MARK=0
+ fi
+ $PATH_EXEC/$ipef -A $1 -C public
+ if [ $? -ne 0 ];then
+ echo "Pefconfig incorrectly,pls check your machine"
+ exit 1
+ fi
+ cd /usr/share/$pkg
+ if [ "$MARK" -ne "1" ];then
+ cd $DIR
+ cp -f ./dopanic /usr/share/$pkg/
+ echo "Init a panic for $pkg..."
+ $PATH_EXEC/$isel -s|grep -c "OS Critical Stop" > /tmp/ocs_num
+ sync
+ sleep 2
+ echo 1 > /tmp/mark
+ cd /usr/share/$pkg
+ insmod -f ./dopanic
+ fi
+ echo "check the result for $pkg..."
+ read oldnum < /tmp/ocs_num
+ $PATH_EXEC/$isel -s |grep -c "OS Critical Stop" > /tmp/ocs_num
+ read newnum < /tmp/ocs_num
+ let oldnum=oldnum+1
+ if [ $newnum -eq $oldnum ]
+ then
+ echo "PASS:KernelPactch:Panic sel insert record"
+ return 0
+ else
+ echo "FAIL: Kernel PatchPanic sel insert record"
+ return 1
+ fi
+ rm -f /tmp/mark
+
+}
+ts_hwresetr()
+{
+ prepare
+ if [ -f /tmp/count ];then
+ COUNT=`cat /tmp/count`
+ else
+ COUNT=0
+ fi
+ if [ "$COUNT" -ne "1" ];then
+ $PATH_EXEC/$isel -c >/dev/null 2>&1
+ echo 1 > /tmp/count
+ $PATH_EXEC/$ireset #reset the system
+ fi
+ $PATH_EXEC/$isel > /tmp/hwreset 2>&1
+ isevent=`cat /tmp/hwreset|grep "System Event"`
+ isboot=`cat /tmp/hwreset|grep "System Boot"`
+ if [ -n "$isevent" ] && [ -n "$isboot" ];then
+ echo "PASS: $pkg power reset"
+ return 0
+ else
+ echo "FAIL: $pkg power reset"
+ return 1
+ fi
+ rm -f /tmp/count
+}
+
+ts_hwresetc()
+{
+ prepare
+ if [ -f /tmp/hwresetc ];then
+ MARK=`cat /tmp/hwresetc`
+ else
+ MARK=0
+ fi
+ if [ "$MARK" -ne "1" ];then
+ $PATH_EXEC/$isel -c >/dev/null 2>&1
+ echo 1 > /tmp/hwresetc
+ $PATH_EXEC/$ireset -c #reset the system
+ fi
+
+ $PATH_EXEC/$isel >/tmp/hwresetc 2>&1
+ power=`cat /tmp/hwresetc|grep "Power Off/Down"`
+ if [ -n "$power" ];then
+ echo "PASS: $pkg power cycle"
+ return 0
+ else
+ echo "FAIL: $pkg power cycle"
+ return 1
+ fi
+ rm -f /tmp/hwresetc
+}
+
diff --git a/test/retro.sh b/test/retro.sh
new file mode 100755
index 0000000..42a60a9
--- /dev/null
+++ b/test/retro.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# retro.sh
+#
+# retrofit ipmiutil subcommand naming for pre-2.6.0 scripts.
+#
+# old new full command
+#alarms ialarms (ipmiutil alarms)
+#bmcconfig iconfig (ipmiutil config)
+#bmchealth ihealth (ipmiutil health)
+#fruconfig ifru (ipmiutil fru)
+#getevent igetevent (ipmiutil getevent)
+#hwreset ireset (ipmiutil reset)
+#icmd icmd (ipmiutil cmd)
+#idiscover idiscover (ipmiutil discover)
+#ievents ievents (ipmiutil events)
+#isolconsole isol (ipmiutil sol)
+#pefconfig ilan (ipmiutil lan)
+#sensor isensor (ipmiutil sensor)
+#showsel isel (ipmiutil sel)
+#tmconfig iserial (ipmiutil serial)
+#wdt iwdt (ipmiutil wdt)
+
+mydir=`pwd`
+
+cd /usr/sbin
+ln ialarms alarms
+ln iconfig bmcconfig
+ln ihealth bmchealth
+ln ifru fruconfig
+ln igetevent getevent
+ln ireset hwreset
+ln isol isolconsole
+ln ilan pefconfig
+ln isensor sensor
+ln iserial tmconfig
+ln iwdt wdt
+cd $mydir
diff --git a/test/sensor-CG2100.txt b/test/sensor-CG2100.txt
new file mode 100644
index 0000000..0545fec
--- /dev/null
+++ b/test/sensor-CG2100.txt
@@ -0,0 +1,148 @@
+ipmiutil ver 2.53
+sensor: version 2.53
+-- BMC version 0.48, IPMI version 2.0
+_ID_ SDR_Type_xx ET Own Typ S_Num Sens_Description Hex & Interp Reading
+0001 SDR Full 01 01 20 a 02 snum 10 BB +1.1V IOH = e9 OK 1.09 Volts
+0002 SDR Full 01 01 20 a 02 snum 11 BB +1.1V P1 Vccp = a1 OK 0.99 Volts
+0003 SDR Full 01 01 20 a 02 snum 12 BB +1.1V P2 Vccp = a2 OK 0.99 Volts
+0004 SDR Full 01 01 20 a 02 snum 13 BB +1.5V P1 DDR3 = ec OK 1.53 Volts
+0005 SDR Full 01 01 20 a 02 snum 14 BB +1.5V P2 DDR3 = eb OK 1.52 Volts
+0006 SDR Full 01 01 20 a 02 snum 15 BB +1.8V AUX = e8 OK 1.77 Volts
+0007 SDR Full 01 01 20 a 02 snum 16 BB +3.3V = e8 OK 3.34 Volts
+0008 SDR Full 01 01 20 a 02 snum 17 BB +3.3V STBY = e6 OK 3.31 Volts
+0009 SDR Full 01 01 20 a 02 snum 18 BB +3.3V Vbat = e7 OK 3.01 Volts
+000a SDR Full 01 01 20 a 02 snum 19 BB +5.0V = e0 OK 4.90 Volts
+000b SDR Full 01 01 20 a 02 snum 1a BB +5.0V STBY = e8 OK 5.08 Volts
+000c SDR Full 01 01 20 a 02 snum 1b BB +12.0V = e3 OK 11.99 Volts
+000d SDR Full 01 01 20 a 02 snum 1c BB -12.0V = be OK -11.59 Volts
+000e SDR Full 01 01 20 a 01 snum 20 Baseboard Temp = 1d OK 29.00 degrees C
+000f SDR Full 01 01 20 a 01 snum 21 Front Panel Temp = 18 OK 24.00 degrees C
+0010 SDR Full 01 01 20 a 01 snum 22 IOH Therm Margin = cf OK -49.00 degrees C
+0011 SDR Full 01 01 20 a 01 snum 23 Mem P1 Thrm Mrgn = d8 OK -40.00 degrees C
+0012 SDR Full 01 01 20 a 01 snum 24 Mem P2 Thrm Mrgn = d6 OK -42.00 degrees C
+0013 SDR Full 01 01 20 m 04 snum 30 System Fan 1 = 66 OK 4590.00 RPM
+0014 SDR Full 01 01 20 m 04 snum 31 System Fan 2 = 65 OK 4545.00 RPM
+0015 SDR Full 01 01 20 m 04 snum 32 System Fan 3 = 67 OK 4635.00 RPM
+0016 SDR Full 01 01 20 m 04 snum 33 System Fan 4 = 65 OK 4545.00 RPM
+0017 SDR Full 01 01 20 m 04 snum 38 System Fan 5 = 72 OK 5700.00 RPM
+0018 SDR Full 01 01 20 m 04 snum 39 System Fan 6 = 72 OK 5700.00 RPM
+0019 SDR Full 01 01 20 a 0b snum 52 PS1 Power In = 2a OK 168.00 Watts
+001a SDR Full 01 01 20 a 03 snum 54 PS1 Curr Out % = 14 OK 20.00 unspecified
+001b SDR Full 01 01 20 a 01 snum 56 PS1 Temperature = 1b OK 27.00 degrees C
+001c SDR Full 01 01 20 a 01 snum 62 P1 Therm Margin = b9 OK -71.00 degrees C
+001d SDR Full 01 01 20 a 01 snum 63 P2 Therm Margin = b8 OK -72.00 degrees C
+001e SDR Full 01 01 20 a 01 snum 64 P1 Therm Ctrl % = 00 OK 0.00 unspecified
+001f SDR Full 01 01 20 a 01 snum 65 P2 Therm Ctrl % = 00 OK 0.00 unspecified
+0020 SDR Full 01 01 c0 a 01 snum 01 HSBP Temperature = 19 OK* 25.00 degrees C
+0021 SDR Comp 02 6f 20 a 09 snum 01 Power Unit Stat = 00 c0 00 00 Enabled
+0022 SDR Comp 02 6f 20 a 23 snum 03 IPMI Watchdog = 00 c0 00 00 OK
+0023 SDR Comp 02 6f 20 a 05 snum 04 Physical Scrty = 00 c0 01 00 ChassisIntrus
+0024 SDR Comp 02 6f 20 a 13 snum 05 FP NMI Diag Int = 00 c0 00 00 OK
+0025 SDR Comp 02 03 20 a f3 snum 06 SMI Timeout = 00 c0 00 00 Disabled
+0026 SDR Comp 02 6f 20 a 10 snum 07 System Event Log = 00 c0 00 00 MemLogDisab
+0027 SDR Comp 02 6f 20 a 12 snum 08 System Event = 00 c0 00 00 OK
+0028 SDR Comp 02 6f 20 a 14 snum 09 Button = 00 c0 00 00 OK
+0029 SDR Comp 02 08 20 a 04 snum 40 Fan 1 Present = 00 c0 02 00 Present
+002a SDR Comp 02 08 20 a 04 snum 41 Fan 2 Present = 00 c0 02 00 Present
+002b SDR Comp 02 08 20 a 04 snum 42 Fan 3 Present = 00 c0 02 00 Present
+002c SDR Comp 02 08 20 a 04 snum 43 Fan 4 Present = 00 c0 02 00 Present
+002d SDR Comp 02 08 20 a 04 snum 44 Fan 5 Present = 00 c0 02 00 Present
+002e SDR Comp 02 08 20 a 04 snum 45 Fan 6 Present = 00 c0 02 00 Present
+002f SDR Comp 02 0b 20 a 04 snum 46 Fan Redundancy = 00 c0 01 00 Redundant
+0030 SDR Comp 02 6f 20 a 08 snum 50 PS1 Status = 00 c0 01 00 Present
+0031 SDR Comp 02 6f 20 m 07 snum 60 P1 Status = 00 c0 80 00 ProcPresent
+0032 SDR Comp 02 6f 20 m 07 snum 61 P2 Status = 00 c0 80 00 ProcPresent
+0033 SDR Comp 02 05 20 m 01 snum 66 P1 VRD Hot = 00 c0 00 00 OK
+0034 SDR Comp 02 05 20 m 01 snum 67 P2 VRD Hot = 00 c0 00 00 OK
+0035 SDR Comp 02 03 20 m 07 snum 68 CATERR = 00 c0 00 00 OK
+0036 SDR Comp 02 03 20 m 07 snum 69 CPU Missing = 00 c0 00 00 OK
+0037 SDR Comp 02 03 20 m 01 snum 6a IOH Therm Trip = 00 c0 00 00 OK
+0038 SDR Comp 02 74 2c a dc snum 1a NM Capabilities = 00 00 00 00 NotAvailable
+0039 SDR Comp 02 6f c0 a 0d snum 02 Drv 0 Stat = 00 c0 00 8e Ready
+003a SDR Comp 02 6f c0 a 0d snum 03 Drv 1 Stat = 00 c0 00 80 Unused
+003b SDR Comp 02 6f c0 a 0d snum 04 Drv 2 Stat = 00 c0 00 80 Unused
+003c SDR Comp 02 6f c0 a 0d snum 05 Drv 3 Stat = 00 c0 00 80 Unused
+003d SDR Comp 02 6f c0 a 0d snum 06 Drv 4 Stat = 00 c0 00 80 Unused
+003e SDR Comp 02 6f c0 a 0d snum 07 Drv 5 Stat = 00 c0 00 80 Unused
+003f SDR Comp 02 08 c0 a 0d snum 09 Drv 0 Pres = 00 c0 02 80 Present
+0040 SDR Comp 02 08 c0 a 0d snum 0a Drv 1 Pres = 00 c0 00 80 Unused
+0041 SDR Comp 02 08 c0 a 0d snum 0b Drv 2 Pres = 00 c0 00 80 Unused
+0042 SDR Comp 02 08 c0 a 0d snum 0c Drv 3 Pres = 00 c0 00 80 Unused
+0043 SDR Comp 02 08 c0 a 0d snum 0d Drv 4 Pres = 00 c0 00 80 Unused
+0044 SDR Comp 02 08 c0 a 0d snum 0e Drv 5 Pres = 00 c0 00 80 Unused
+0045 SDR EvtO 03 19 2c 00 snum 17 SPS FW Health = 00 00 00 00 OK
+0046 SDR EvtO 03 18 2c 00 snum 18 NM Exception = 00 00 00 00 OK
+0047 SDR EvtO 03 15 2c 00 snum 19 NM Health = 00 00 00 00 OK
+0048 SDR EvtO 03 18 2c 00 snum 1b NM Threshold = 00 00 00 00 OK
+0049 SDR EvtO 03 1b 33 01 snum 01 Mem Mirr Sensor = 00 00 00 00 OK
+004a SDR EvtO 03 1b 33 01 snum 02 Mmry ECC Sensor = 00 00 00 00 OK
+004b SDR EvtO 03 1b 33 01 snum 03 PCI Lgcy Sensor = 00 00 00 00 OK
+004c SDR EvtO 03 1b 33 01 snum 04 PCIe Fat Sensor = 00 00 00 00 OK
+004d SDR EvtO 03 1b 33 01 snum 05 PCIe Cor Sensor = 00 00 00 00 OK
+004e SDR EvtO 03 1b 33 01 snum 06 QPI Corr Sensor = 00 00 00 00 OK
+004f SDR EvtO 03 1b 33 01 snum 07 QPI NonF Sensor = 00 00 00 00 OK
+0050 SDR EvtO 03 1b 33 01 snum 11 Mem Spar Sensor = 00 00 00 00 OK
+0051 SDR EvtO 03 1b 33 01 snum 12 Mirr Mod Sensor = 00 00 00 00 OK
+0052 SDR EvtO 03 1b 33 01 snum 13 Spar Mod Sensor = 00 00 00 00 OK
+0053 SDR EvtO 03 1b 33 01 snum 14 Mem Parity Snsr = 00 00 00 00 OK
+0054 SDR EvtO 03 1b 33 01 snum 17 QPI Fatl Sensor = 00 00 00 00 OK
+0055 SDR EvtO 03 1b 33 01 snum 18 QPI Fatl Sensor = 00 00 00 00 OK
+0056 SDR EvtO 03 1b 01 01 snum 83 BIOS Evt Sensor = 00 00 00 00 OK
+0057 SDR FRU 11 14 dev: 20 00 80 00 07 01 Baseboard
+0058 SDR FRU 11 1b dev: 20 01 80 00 15 01 Power Dist Board
+0059 SDR FRU 11 1b dev: 20 02 80 00 0a 01 Pwr Supply 1 FRU
+005a SDR IPMB 12 1b dev: 20 00 bf 07 01 Basbrd Mgmt Ctlr
+005b SDR IPMB 12 17 dev: c0 00 29 0f 01 HotSwap Ctlr
+005c SDR IPMB 12 0d dev: 2c 06 21 2e 01 ME
+005d SDR OEM c0 0b Intel: 0d 01 2c 60 19 18 1a 1b
+005e SDR OEM c0 15 Intel: 05 46 00 04 04 01 30 40 31 41 32 42 33 43 38 44 39 45
+005f SDR OEM c0 32 Intel: 09 0f 10 54 14 11 88 0f 12 88 0f 13 a5 0e 14 a5 0e 15 73 0c 16 b6 0a 17 b6 0a 18 d5 09 19 bb 0a 1a bb 0a 1b d5 0a 1c 39 1e 1d 44 10 1e 44 10
+0060 SDR OEM c0 1e Intel: 0a 00 00 50 2d 50 2d 50 2d 50 2d 00 01 00 01 00 01 00 01 c8 32 c8 32 00 01 00 01
+0061 SDR OEM c0 0e Intel: 0b 01 01 23 07 10 21 90 01 01 08
+0062 SDR OEM c0 0e Intel: 0b 01 02 23 07 10 21 90 01 01 08
+0063 SDR OEM c0 0e Intel: 0b 01 04 23 07 10 21 90 01 01 08
+0064 SDR OEM c0 0e Intel: 0b 01 08 23 07 10 21 90 01 01 08
+0065 SDR OEM c0 0e Intel: 0b 01 10 23 07 10 21 90 01 01 08
+0066 SDR OEM c0 0e Intel: 0b 01 20 23 07 10 21 90 01 01 08
+0067 SDR OEM c0 0e Intel: 0b 01 40 23 07 10 21 90 01 01 08
+0068 SDR OEM c0 0e Intel: 0b 01 80 23 07 10 21 90 01 01 08
+0069 SDR OEM c0 0e Intel: 0b 02 ff 23 07 10 21 90 01 03 08
+006a SDR OEM c0 1a Intel: 0c 01 00 19 ff 01 02 03 20 21 64 00 41 10 04 14 26 19 2a 1e 31 23 38
+006b SDR OEM c0 1a Intel: 0c 01 00 19 ff 01 02 0c 20 21 64 00 41 10 04 14 28 19 2d 1e 35 23 3e
+006c SDR OEM c0 1a Intel: 0c 01 00 19 ff 01 02 30 20 21 64 00 41 10 04 14 2e 19 31 1e 3b 23 41
+006d SDR OEM c0 1a Intel: 0c 01 00 19 ff 01 02 c0 20 21 64 00 41 10 04 14 39 19 3c 1e 48 23 50
+006e SDR OEM c0 1a Intel: 0c 01 00 19 ff 01 02 03 20 21 64 00 41 50 04 14 32 19 37 1e 3f 23 4b
+006f SDR OEM c0 1a Intel: 0c 01 00 19 ff 01 02 0c 20 21 64 00 41 50 04 14 32 19 37 1e 41 23 55
+0070 SDR OEM c0 1a Intel: 0c 01 00 19 ff 01 02 30 20 21 64 00 41 50 04 14 37 00 37 1e 41 23 55
+0071 SDR OEM c0 1a Intel: 0c 01 00 19 ff 01 02 c0 20 21 64 00 41 50 04 14 46 00 37 1e 41 23 55
+0072 SDR OEM c0 15 Intel: 0c 01 00 19 ff 01 02 ff 20 63 64 00 42 28 40 00 00 11
+0073 SDR OEM c0 15 Intel: 0c 01 00 19 ff 01 02 ff 20 23 64 00 42 38 10 00 fc 00
+0074 SDR OEM c0 10 Intel: 0c 01 00 14 ff 01 02 ff ff 64 64 ff 00
+0075 SDR OEM c0 0e Intel: 0c 01 00 14 ff 01 02 ff fd 01 04
+0076 SDR OEM c0 1a Intel: 0c 01 01 19 ff 01 02 03 20 21 64 00 41 10 04 14 26 19 2a 1e 31 23 38
+0077 SDR OEM c0 1a Intel: 0c 01 01 19 ff 01 02 0c 20 21 64 00 41 10 04 14 28 19 2d 1e 35 23 3e
+0078 SDR OEM c0 1a Intel: 0c 01 01 19 ff 01 02 30 20 21 64 00 41 10 04 14 2e 19 31 1e 3b 23 41
+0079 SDR OEM c0 1a Intel: 0c 01 01 19 ff 01 02 c0 20 21 64 00 41 10 04 14 39 19 3c 1e 48 23 50
+007a SDR OEM c0 1a Intel: 0c 01 01 19 ff 01 02 03 20 21 64 00 41 50 04 14 32 19 37 1e 3f 23 4b
+007b SDR OEM c0 1a Intel: 0c 01 01 19 ff 01 02 0c 20 21 64 00 41 50 04 14 32 19 37 1e 41 23 55
+007c SDR OEM c0 1a Intel: 0c 01 01 19 ff 01 02 30 20 21 64 00 41 50 04 14 37 19 41 1e 55 23 64
+007d SDR OEM c0 1a Intel: 0c 01 01 19 ff 01 02 c0 20 21 64 00 41 50 04 14 46 19 50 1e 5a 23 64
+007e SDR OEM c0 15 Intel: 0c 01 01 19 ff 01 02 ff 20 62 64 00 42 28 40 00 00 01
+007f SDR OEM c0 15 Intel: 0c 01 01 19 ff 01 02 ff 20 24 64 00 42 38 10 00 fc 10
+0080 SDR OEM c0 10 Intel: 0c 01 01 14 ff 01 02 ff ff 64 64 ff 00
+0081 SDR OEM c0 0e Intel: 0c 01 01 14 ff 01 02 ff fd 01 04
+0082 SDR OEM c0 1a Intel: 0c 01 02 19 ff 01 02 03 20 21 64 00 41 10 04 14 26 19 2a 1e 31 23 38
+0083 SDR OEM c0 1a Intel: 0c 01 02 19 ff 01 02 0c 20 21 64 00 41 10 04 14 28 19 2d 1e 35 23 3e
+0084 SDR OEM c0 1a Intel: 0c 01 02 19 ff 01 02 30 20 21 64 00 41 10 04 14 2e 19 31 1e 3b 23 41
+0085 SDR OEM c0 1a Intel: 0c 01 02 19 ff 01 02 c0 20 21 64 00 41 10 04 14 39 19 3c 1e 48 23 50
+0086 SDR OEM c0 1a Intel: 0c 01 02 19 ff 01 02 03 20 21 64 00 41 50 04 14 32 19 37 1e 3f 23 4b
+0087 SDR OEM c0 1a Intel: 0c 01 02 19 ff 01 02 0c 20 21 64 00 41 50 04 14 32 19 37 1e 41 23 55
+0088 SDR OEM c0 1a Intel: 0c 01 02 19 ff 01 02 30 20 21 64 00 41 50 04 14 37 19 41 1e 55 23 64
+0089 SDR OEM c0 1a Intel: 0c 01 02 19 ff 01 02 c0 20 21 64 00 41 50 04 14 46 19 50 1e 5a 23 64
+008a SDR OEM c0 15 Intel: 0c 01 02 19 ff 01 02 ff 20 22 64 00 42 38 00 01 fb 00
+008b SDR OEM c0 10 Intel: 0c 01 02 14 ff 01 02 ff ff 64 64 ff 00
+008c SDR OEM c0 0e Intel: 0c 01 02 14 ff 01 02 ff fd 01 04
+008d SDR OEM c0 14 Intel: 0e 01 07 01 06 30 2a 31 2b 32 34 33 35 38 36 39 37
+008e GetSDR error 0xca Cannot return requested number of data bytes, rlen=0
+ SDR IPMI sensor: Power On Hours = 255 hours
+sensor Cannot return requested number of data bytes
diff --git a/test/sensor-TIGW1U.txt b/test/sensor-TIGW1U.txt
new file mode 100644
index 0000000..4426d2e
--- /dev/null
+++ b/test/sensor-TIGW1U.txt
@@ -0,0 +1,106 @@
+sensor: version 2.3
+-- BMC version 0.16, IPMI version 2.0
+_ID_ SDR_Type_xx Sz Own Typ S_Num Sens_Description Hex & Interp Reading
+0001 SDR Full 01 37 20 a 02 snum 10 BB +1.2V Vtt = be OK 1.20 Volts
+0002 SDR Full 01 3b 20 a 02 snum 11 BB+1.9V NIC Core = cb OK 1.91 Volts
+0003 SDR Full 01 37 20 a 02 snum 12 BB +1.5V AUX = bd OK 1.47 Volts
+0004 SDR Full 01 33 20 a 02 snum 13 BB +1.5V = 75 OK 1.52 Volts
+0005 SDR Full 01 33 20 a 02 snum 14 BB +1.8V = af OK 1.78 Volts
+0006 SDR Full 01 33 20 a 02 snum 15 BB +3.3V = c1 OK 3.32 Volts
+0007 SDR Full 01 37 20 a 02 snum 16 BB +3.3V STB = be OK 3.27 Volts
+0008 SDR Full 01 37 20 a 02 snum 17 BB +1.5V ESB = be OK 1.48 Volts
+0009 SDR Full 01 31 20 a 02 snum 18 BB +5V = c3 OK 5.07 Volts
+000a SDR Full 01 37 20 a 02 snum 19 BB +1.2V NIC = ed OK 1.21 Volts
+000b SDR Full 01 36 20 a 02 snum 1a BB +12V AUX = c1 OK 11.97 Volts
+000c SDR Full 01 33 20 a 02 snum 1b BB +0.9V = ba OK 0.89 Volts
+000d SDR Full 01 39 20 a 01 snum 30 Baseboard Temp = 30 OK 48.00 degrees C
+000e SDR Full 01 3b 20 a 01 snum 32 Front Panel Temp = 1a OK 26.00 degrees C
+000f SDR Full 01 31 20 m 04 snum 50 Fan 1A = 6f OK 7659.00 RPM
+0010 SDR Full 01 31 20 m 04 snum 51 Fan 1B = 6c OK 5508.00 RPM
+0011 SDR Full 01 31 20 m 04 snum 52 Fan 2A = 68 OK 7176.00 RPM
+0012 SDR Full 01 31 20 m 04 snum 53 Fan 2B = 6b OK 5457.00 RPM
+0013 SDR Full 01 31 20 m 04 snum 54 Fan 3A = 6c OK 7452.00 RPM
+0014 SDR Full 01 31 20 m 04 snum 55 Fan 3B = 6b OK 5457.00 RPM
+0015 SDR Full 01 31 20 m 04 snum 56 Fan 4A = 6f OK 7659.00 RPM
+0016 SDR Full 01 31 20 m 04 snum 57 Fan 4B = 69 OK 5355.00 RPM
+0017 SDR Full 01 30 20 m 04 snum 58 Fan 5 = 63 OK 6534.00 RPM
+0018 SDR Full 01 39 20 a 03 snum 78 PS1 AC Current = 05 OK 0.62 Amps
+0019 SDR Full 01 39 20 a 03 snum 79 PS2 AC Current = 16 OK 2.75 Amps
+001a SDR Full 01 3b 20 a 03 snum 7a PS1 +12V Current = 01 OK 0.50 Amps
+001b SDR Full 01 3b 20 a 03 snum 7b PS2 +12V Current = 11 OK 8.50 Amps
+001c SDR Full 01 39 20 a 0b snum 7c PS1 +12V Power = 01 OK 4.00 Watts
+001d SDR Full 01 39 20 a 0b snum 7d PS2 +12V Power = 19 OK 100.00 Watts
+001e SDR Full 01 3a 20 a 01 snum 99 P1 Therm Margin = c9 OK -55.00 degrees C
+001f SDR Full 01 3a 20 m 01 snum c0 P1 Therm Ctrl % = 00 OK 0.00 unspecified
+0020 SDR Full 01 36 20 a 02 snum d0 Proc 1 Vccp = c3 OK 1.21 Volts
+0021 SDR Full 01 38 c0 a 01 snum 01 SAS HSBP Temp = 1d OK* 29.00 degrees C
+0022 SDR Comp 02 25 20 a 09 snum 01 Power Unit = 00 c0 00 00 Enabled
+0023 SDR Comp 02 2b 20 a 09 snum 02 Power Redundancy = 00 c0 01 00 Redundant
+0024 SDR Comp 02 27 20 a 23 snum 03 BMC Watchdog = 00 c0 00 00 OK
+0025 SDR Comp 02 2a 20 a 06 snum 04 Scrty Violation = 00 c0 00 00 OK
+0026 SDR Comp 02 27 20 a 13 snum 07 FP Interrupt = 00 c0 00 00 OK
+0027 SDR Comp 02 2a 20 a 10 snum 09 Event Log Clear = 00 c0 00 00 OK
+0028 SDR Comp 02 28 20 a 2a snum 0a Session Audit = 00 c0 00 00 Activated
+0029 SDR Comp 02 27 20 a 12 snum 0b System Event = 00 c0 00 00 OK
+002a SDR Comp 02 22 20 a 29 snum 1e BB Vbat = 00 c0 00 00 OK*
+002b SDR Comp 02 25 20 a 08 snum 70 PS1 Status = 00 c0 01 00 Present
+002c SDR Comp 02 25 20 a 08 snum 71 PS2 Status = 00 c0 01 00 Present
+002d SDR Comp 02 25 20 a 22 snum 82 ACPI State = 00 c0 01 00 Working
+002e SDR Comp 02 21 20 a 14 snum 84 Button = 00 c0 00 00 OK
+002f SDR Comp 02 26 20 a f3 snum 85 SMI Timeout = 00 c0 01 00 Enabled
+0030 SDR Comp 02 24 20 a c0 snum 87 NMI State = 00 c0 01 00 Enabled
+0031 SDR Comp 02 24 20 a c0 snum 88 SMI State = 00 80 01 00 Enabled
+0032 SDR Comp 02 2b 20 m 07 snum 90 Processor 1 Stat = 00 c0 80 00 OK*
+0033 SDR Comp 02 25 20 a 13 snum a0 PCIe Link0 = 00 c0 00 00 OK
+0034 SDR Comp 02 25 20 a 13 snum a1 PCIe Link1 = 00 c0 00 00 OK
+0035 SDR Comp 02 25 20 a 13 snum a2 PCIe Link2 = 00 c0 00 00 OK
+0036 SDR Comp 02 25 20 a 13 snum a3 PCIe Link3 = 00 c0 00 00 OK
+0037 SDR Comp 02 25 20 a 13 snum a4 PCIe Link4 = 00 c0 00 00 OK
+0038 SDR Comp 02 25 20 a 13 snum a5 PCIe Link5 = 00 c0 00 00 OK
+0039 SDR Comp 02 25 20 a 13 snum a6 PCIe Link6 = 00 c0 00 00 OK
+003a SDR Comp 02 25 20 a 13 snum a7 PCIe Link7 = 00 c0 00 00 OK
+003b SDR Comp 02 25 20 a 13 snum a8 PCIe Link8 = 00 c0 00 00 OK
+003c SDR Comp 02 28 20 m 01 snum c8 CPU1 VRD Temp = 00 c0 00 00 OK*
+003d SDR Comp 02 27 20 a 02 snum d2 CPU1 Vcc OOR = 00 c0 00 00 OK
+003e SDR Comp 02 2a 20 a 07 snum d8 CPU Popul Error = 00 c0 00 00 OK
+003f SDR Comp 02 22 20 a 21 snum e0 DIMM 1A = 00 c0 04 00 Present
+0040 SDR Comp 02 22 20 a 21 snum e1 DIMM 2A = 00 e0 00 00 NotAvailable
+0041 SDR Comp 02 22 20 a 21 snum e2 DIMM 3A = 00 e0 00 00 NotAvailable
+0042 SDR Comp 02 22 20 a 21 snum e3 DIMM 1B = 00 c0 04 00 Present
+0043 SDR Comp 02 22 20 a 21 snum e4 DIMM 2B = 00 e0 00 00 NotAvailable
+0044 SDR Comp 02 22 20 a 21 snum e5 DIMM 3B = 00 e0 00 00 NotAvailable
+0045 SDR Comp 02 26 20 a 0c snum ec Mem A Error = 00 c0 00 00 OK
+0046 SDR Comp 02 26 20 a 0c snum ed Mem B Error = 00 c0 00 00 OK
+0047 SDR Comp 02 29 20 a 25 snum f0 DIMM Spare Enb = 00 e0 00 00 NotAvailable
+0048 SDR Comp 02 2a 20 a 0c snum f1 DIMM Spare Redu = 00 e0 00 00 NotAvailable
+0049 SDR Comp 02 29 c0 a 0d snum 02 SAS Drv 1 Stat = 00 d0 00 8e Ready
+004a SDR Comp 02 29 c0 a 0d snum 03 SAS Drv 2 Stat = 00 d0 00 8e Ready
+004b SDR Comp 02 29 c0 a 0d snum 04 SAS Drv 3 Stat = 00 d0 00 80 Unused
+004c SDR Comp 02 29 c0 a 0d snum 09 SAS Drv 1 Pres = 00 d0 02 80 Present
+004d SDR Comp 02 29 c0 a 0d snum 0a SAS Drv 2 Pres = 00 d0 02 80 Present
+004e SDR Comp 02 29 c0 a 0d snum 0b SAS Drv 3 Pres = 00 d0 00 80 Unused
+004f SDR FRU 11 18 dev: 20 00 80 00 0c 01 Baseboard FRU
+0050 SDR FRU 11 19 dev: 20 02 80 00 15 01 Power Dist FRU
+0051 SDR FRU 11 1b dev: 20 03 80 00 0a 01 Pwr Supply 1 FRU
+0052 SDR FRU 11 1b dev: 20 04 80 00 0a 02 Pwr Supply 2 FRU
+0053 SDR IPMB 12 1b dev: 20 00 bf 07 01 Basbrd Mgmt Ctlr
+0054 SDR IPMB 12 1b dev: c0 00 29 0f 01 SFP HotSwap Ctlr
+0055 SDR OEM c0 09 Intel: 02 02 00 01 70 71
+0056 SDR OEM c0 05 Intel: 06 01
+0057 SDR OEM c0 18 Intel: 0b 01 01 32 14 f0 0a a4 01 96 00 61 00 07 0a 64 05 00 00 00 00
+0058 SDR OEM c0 2c Intel: 0c 01 30 64 64 01 02 01 30 20 32 64 01 90 0d 00 2b 20 30 21 35 22 3a 23 3f 24 43 25 47 26 4c 27 51 28 56 29 5b 2a 60 2b 64
+0059 SDR OEM c0 2c Intel: 0c 02 30 64 64 01 02 01 30 20 32 64 01 90 0d 00 2b 20 30 21 35 22 3a 23 3f 24 43 25 47 26 4c 27 51 28 56 29 5b 2a 60 2b 64
+005a SDR OEM c0 2c Intel: 0c 03 30 64 64 01 02 01 30 20 32 64 01 90 0d 00 2b 20 30 21 35 22 3a 23 3f 24 43 25 47 26 4c 27 51 28 56 29 5b 2a 60 2b 64
+005b SDR OEM c0 15 Intel: 0c 01 64 64 64 01 02 01 00 20 99 64 02 90 01 06 00 11
+005c SDR OEM c0 15 Intel: 0c 02 64 64 64 01 02 01 00 20 99 64 02 90 01 06 00 11
+005d SDR OEM c0 15 Intel: 0c 03 64 64 64 01 02 01 00 20 30 64 02 90 01 02 3c 00
+005e SDR OEM c0 0e Intel: 08 00 00 45 88 45 88 45 88 45 88
+005f SDR OEM c0 16 Intel: 09 00 00 90 33 90 33 90 33 90 33 90 33 90 33 68 42 68 42
+0060 SDR OEM c0 08 Intel: BMC_TAM0 60 01 03 02 20 nrec=4 cfg=02
+0061 SDR OEM c0 31 Intel: BMC_TAM1 60 01 13 00 20 41 01 01 01 23 71 93 41 02 01 02 24 72 94 41 03 01 02 24 72 94 21 04 01 01 23 11 02 05 14 31 29 6f 01 13 23 21 09 0b 14 34
+0062 SDR OEM c0 31 Intel: BMC_TAM2 60 01 23 00 20 71 07 6f 03 13 23 33 43 55 83 11 08 6f 14 21 09 6f 54 64 20 7c 01 72 94 20 7d 01 72 94 11 21 6f 03 53 23 6f 05 15 25 35 85
+0063 SDR OEM c0 17 Intel: BMC_TAM3 60 01 33 00 c0 22 02 00 03 51 22 03 00 03 51 22 04 00 03 51
+0064 SDR OEM c0 0e Intel: SDR File 12
+0065 SDR OEM c0 11 Intel: SDR Package 12
+ SDR IPMI sensor: Power On Hours = 1014 hours
+sensor: completed successfully
diff --git a/test/testipmi.sh b/test/testipmi.sh
new file mode 100755
index 0000000..798705a
--- /dev/null
+++ b/test/testipmi.sh
@@ -0,0 +1,400 @@
+#!/bin/sh
+# testipmi.sh [node_ip]
+# Main test script for ipmiutil functions
+# Other files used:
+# ./ipmievt.sh
+# ./sensor-TIGW1U.txt
+# ./sensor-CG2100.txt
+#
+# If a remote node is specified as the target, it must be confiugred for
+# IPMI LAN and should have the ipmiutil_asy service running.
+#
+outf=/tmp/testipmi.out
+remote=0
+dosol=0
+# default remote node for SOL test
+node=192.168.1.154
+# use canned username and password, edit as needed.
+user=admin
+pswd=password
+mydir=`pwd`
+indir=`dirname $0`
+c1=`echo $indir |cut -c1`
+if [ "$c1" = "/" ]; then
+ testdir=$indir
+else
+ testdir=$mydir/$indir
+fi
+# datadir=/usr/share/ipmiutil
+datadir=/var/lib/ipmiutil
+# sfil is used only to read from with events -p -s below
+# normally, sfil=$datadir/sensor-out.txt
+sfil=${testdir}/sensor-TIGW1U.txt
+sfil2=${testdir}/sensor-CG2100.txt
+evtsh=${testdir}/ipmievt.sh
+tmpc=/tmp/cfg.tmp
+tmpin=/tmp/sol.in
+npass=0
+nfail=0
+# march=`rpmbuild --showrc |grep " _target_cpu" | head -n1 |awk '{print $3}'`
+uarch=`uname -m`
+LANPARAMS=
+os=`uname -s`
+if [ "$os" = "SunOS" ];then
+TAIL="tail -1"
+TAIL2="tail -2"
+else
+TAIL="tail -n1"
+TAIL2="tail -n2"
+fi
+
+errexit() {
+ rv=$1
+ echo "FAIL $rv"
+ nfail=`expr $nfail + 1`
+ echo "## Passed=$npass, Failed=$nfail, see $outf for detailed results"
+ exit $rv
+}
+
+waitready() {
+ i=0
+ while [ 1 ]; do
+ if [ $i -gt 15 ]; then
+ return 1
+ fi
+ echo "wait for ready: loop $i ..."
+ ipmiutil wdt $LANPARAMS
+ if [ $? -eq 0 ]; then
+ return 0
+ else
+ sleep 1
+ fi
+ i=`expr $i + 1`
+ done
+}
+
+runcmd() {
+ # runcmd checks for the tag 'successful' in the output and exits otherwise.
+ CMD="$*"
+ TAG=`echo $CMD |cut -f1-3 -d' '`
+ tmpcmd=/tmp/cmdout.$$
+ echo -n "$TAG ... "
+ echo "# $CMD" > $tmpcmd
+ $CMD >>$tmpcmd 2>&1
+ rv=$?
+ $TAIL $tmpcmd | grep successful >/dev/null
+ success=$?
+ cat $tmpcmd >>$outf
+ if [ $success -ne 0 ]; then
+ if [ $rv -eq 0 ]; then
+ rv=1
+ fi
+ echo "FAIL $rv"
+ echo "=== $CMD FAIL $rv" >>$outf
+ nfail=`expr $nfail + 1`
+ else
+ echo "PASS"
+ echo "=== $CMD PASS" >>$outf
+ npass=`expr $npass + 1`
+ fi
+ return $rv
+}
+
+runcmdr() {
+ # runcmdr checks only the return value for 0, and exits otherwise.
+ CMD="$*"
+ TAG=`echo $CMD |cut -f1-3 -d' '`
+ tmpcmd=/tmp/cmdoutr.$$
+ echo -n "$TAG ... "
+ echo "# $CMD" > $tmpcmd
+ $CMD >>$tmpcmd 2>&1
+ rv=$?
+ cat $tmpcmd >>$outf
+ if [ $rv -ne 0 ]; then
+ echo "FAIL $rv"
+ echo "=== $CMD FAIL $rv" >>$outf
+ nfail=`expr $nfail + 1`
+ else
+ echo "PASS"
+ echo "=== $CMD PASS" >>$outf
+ npass=`expr $npass + 1`
+ fi
+ return $rv
+}
+
+if [ $# -ge 1 ];then
+ node=$1
+ LANPARAMS="-N $node -U $user -P $pswd"
+ remote=1
+ dosol=1
+fi
+
+>$outf
+pushd /tmp
+
+echo "## testipmi.sh $LANPARAMS" | tee -a $outf
+if [ ! -f $sfil ]; then
+ echo "Cannot find required file $sfil"
+ echo "Make sure that $sfil, $sfil2, and $evtsh are present."
+ exit 1
+fi
+if [ ! -f $sfil2 ]; then
+ echo "Cannot find required file $sfil2"
+ echo "Make sure that $sfil, $sfil2, and $evtsh are present."
+ exit 1
+fi
+if [ ! -x $evtsh ]; then
+ echo "Cannot find required file $evtsh"
+ echo "Make sure that $sfil, $sfil2, and $evtsh are present."
+ exit 1
+fi
+
+runcmd "ipmiutil health $LANPARAMS"
+runcmd "ipmiutil health -x $LANPARAMS"
+runcmd "ipmiutil health -c $LANPARAMS"
+runcmd "ipmiutil health -f -g -h -s -c $LANPARAMS"
+
+runcmd "ipmiutil cmd -x $LANPARAMS 00 20 18 01 "
+runcmdr "ipmiutil cmd -q $LANPARAMS 00 20 18 01 "
+
+runcmd "ipmiutil fru -b $LANPARAMS"
+MODEL=`grep "Chassis OEM Field" $outf| cut -f2 -d':'| awk '{ print $1 }'`
+ASSET=`grep "Product Asset Tag" $outf| cut -f2 -d':'| awk '{ print $1 }'`
+runcmd "ipmiutil fru $LANPARAMS"
+runcmd "ipmiutil fru -c $LANPARAMS"
+runcmd "ipmiutil fru -i 00 -m 002000s $LANPARAMS"
+runcmd "ipmiutil fru -a test_asset $LANPARAMS" -V4
+runcmd "ipmiutil fru -a ${ASSET} $LANPARAMS" -V4
+
+runcmd "ipmiutil config $LANPARAMS -s $tmpc"
+
+runcmd "ipmiutil lan -c $LANPARAMS "
+IPADDR=`grep "IP address" $outf| tail -n1|cut -f2 -d'|'| awk '{ print $1 }'`
+if [ "x$IPADDR" = "x0.0.0.0" ]; then
+ # if not already configured, use value from node variable.
+ IPADDR=$node
+fi
+if [ $remote -eq 0 ]; then
+ runcmd "ipmiutil lan -e -I $IPADDR -u $user -p $pswd $LANPARAMS "
+fi
+runcmd "ipmiutil lan $LANPARAMS "
+if [ $remote -eq 0 ]; then
+ # restore previous IPMI LAN settings
+ runcmd "ipmiutil config $LANPARAMS -r $tmpc"
+fi
+
+ipmiutil serial | grep "No serial channel" >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+ runcmd "ipmiutil serial $LANPARAMS"
+ runcmd "ipmiutil serial -c $LANPARAMS"
+fi
+
+tmpsel=/tmp/selout.$$
+runcmd "ipmiutil sel $LANPARAMS"
+runcmd "ipmiutil sel -e $LANPARAMS"
+runcmd "ipmiutil sel -v $LANPARAMS"
+runcmd "ipmiutil sel -l5 $LANPARAMS"
+echo -n "ipmiutil sel -r"
+ipmiutil sel -r -l20 $LANPARAMS >$tmpsel
+if [ $? -ne 0 ]; then
+ echo "... FAIL $rv" |tee -a $outf
+ nfail=`expr $nfail + 1`
+fi
+echo " ... PASS" |tee -a $outf
+npass=`expr $npass + 1`
+runcmd "ipmiutil sel -f $tmpsel $LANPARAMS "
+
+runcmd "ipmiutil sensor $LANPARAMS"
+runcmd "ipmiutil sensor -v $LANPARAMS"
+runcmd "ipmiutil sensor -g temp,fan,voltage $LANPARAMS"
+runcmd "ipmiutil sensor -c $LANPARAMS"
+if [ $remote -eq 0 ]; then
+ runcmd "$evtsh"
+fi
+
+# Test getevt SEL method
+runcmdr "ipmiutil getevt -s $LANPARAMS -t 3 "
+if [ $remote -eq 0 ]; then
+ # if local, also test getevt MessageBuffer method
+ runcmdr "ipmiutil getevt $LANPARAMS -t 3 "
+fi
+
+# Do not run SOL test if no remote server is configured for SOL.
+if [ $dosol -eq 1 ]; then
+ # runcmd "ipmiutil sol -d $LANPARAMS " (do not check success)
+ echo -n "ipmiutil sol -d ... "
+ echo "# ipmiutil sol -d $LANPARAMS " >> $outf
+ ipmiutil sol -d $LANPARAMS >>$outf 2>&1
+ if [ $? -eq -3 ]; then
+ echo "FAIL"
+ echo "=== ipmiutil sol -d FAIL" >>$outf
+ nfail=`expr $nfail + 1`
+ else
+ echo "PASS"
+ echo "=== ipmiutil sol -d PASS" >>$outf
+ npass=`expr $npass + 1`
+ fi
+
+ cat - <<%%% >$tmpin
+
+root
+password
+ls
+pwd
+echo success
+exit
+~.
+%%%
+ runcmd "ipmiutil sol -a $LANPARAMS -i $tmpin"
+fi
+
+
+runcmd "ipmiutil wdt $LANPARAMS"
+runcmd "ipmiutil wdt -e -a0 -t 5 -p 2 $LANPARAMS"
+runcmd "ipmiutil wdt -c $LANPARAMS"
+runcmd "ipmiutil wdt -r $LANPARAMS"
+sleep 5
+runcmd "ipmiutil wdt -d $LANPARAMS"
+runcmd "ipmiutil sel -l5 $LANPARAMS"
+
+runcmdr "ipmiutil discover -a"
+
+CMD="ipmiutil events 18 00 02 02 00 00 00 20 00 04 09 01 6f 44 0f ff"
+echo -n "ipmiutil events (AC Lost)"
+echo "# $CMD" >>$outf
+$CMD >>$outf
+$TAIL2 $outf |grep "AC Lost" >/dev/null
+if [ $? -ne 0 ]; then
+ echo " ... FAIL 1" |tee -a $outf
+ nfail=`expr $nfail + 1`
+fi
+echo " ... PASS" |tee -a $outf
+npass=`expr $npass + 1`
+
+CMD="ievents -p -s $sfil B3 E8 00 0E 0C C7 1B A0 11 08 12 7F 10 90 FF FF 20 20 00 20 02 15 01 41 0F FF"
+echo -n "ievents -p (Redundancy Lost)"
+echo "# $CMD" >>$outf
+$CMD >>$outf
+$TAIL2 $outf |grep "Redundancy Lost" >/dev/null
+if [ $? -ne 0 ]; then
+ echo " ... FAIL 1" |tee -a $outf
+ nfail=`expr $nfail + 1`
+fi
+echo " ... PASS" |tee -a $outf
+npass=`expr $npass + 1`
+
+CMD="ipmiutil events -s $sfil2 -p B5 19 00 15 17 C6 C9 D0 00 02 B2 76 C1 16 FF FF 20 20 10 20 20 00 00 52 1D 20 00 00 00 00 00 00 00 00 00 00 00 00 C1 00 00 00 00 00 00 00 00 00 00"
+echo -n "ipmiutil events -p (Lo Crit)"
+echo "# $CMD" >>$outf
+$CMD >>$outf
+$TAIL2 $outf |grep "Lo Crit thresh" >/dev/null
+if [ $? -ne 0 ]; then
+ echo " ... FAIL 1" |tee -a $outf
+ nfail=`expr $nfail + 1`
+fi
+echo " ... PASS" |tee -a $outf
+npass=`expr $npass + 1`
+
+# The alarms command will fail on systems without an alarm panel.
+echo "MODEL=$MODEL" >> $outf
+case "$MODEL" in
+ TIGW1U) tamok=1
+ ;;
+ TIGH2U) tamok=1
+ ;;
+ TIGI2U) tamok=1
+ ;;
+ TIGPR2U) tamok=1
+ ;;
+ TIGPT1U) tamok=1
+ ;;
+ TSRLT2) tamok=1
+ ;;
+ TSRMT2) tamok=1
+ ;;
+ CG2100) tamok=1
+ ;;
+ *) tamok=0
+ ;;
+esac
+if [ $tamok -eq 1 ]; then
+ picmg=0
+ runcmd "ipmiutil alarms $LANPARAMS"
+ runcmdr "ipmiutil alarms -m1 -n1 $LANPARAMS"
+ runcmdr "ipmiutil alarms -o $LANPARAMS"
+fi
+runcmd "ipmiutil alarms -i10 $LANPARAMS"
+
+# The rackmount servers with TAM are not PICMG,
+# so if the have TAM, skip the PICMG test.
+# otherwise try a PICMG test.
+if [ $tamok -eq 0 ]; then
+ picmg=1
+ CMD="ipmiutil picmg $LANPARAMS properties"
+ echo -n "$CMD"
+ echo "# $CMD" >>$outf
+ $CMD >>$outf
+ rv=$?
+ if [ $rv -eq 193 ]; then
+ echo " ... N/A"
+ picmg=0
+ elif [ $? -ne 0 ]; then
+ echo " ... FAIL $rv" |tee -a $outf
+ nfail=`expr $nfail + 1`
+ else
+ echo " ... PASS" |tee -a $outf
+ npass=`expr $npass + 1`
+ fi
+fi
+
+# The firmware firewall feature is only for PICMG
+if [ $picmg -eq 1 ]; then
+ CMD="ipmiutil firewall $LANPARAMS info"
+ echo -n "$CMD"
+ echo "# $CMD" >>$outf
+ $CMD >>$outf
+ rv=$?
+ if [ $rv -ne 0 ]; then
+ echo " ... FAIL $rv" |tee -a $outf
+ nfail=`expr $nfail + 1`
+ else
+ echo " ... PASS" |tee -a $outf
+ npass=`expr $npass + 1`
+ fi
+fi
+
+if [ "$uarch" = "ia64" ]
+then
+ # Note that ireset -n (NMI) causes a full reset on ia64
+ echo "ia64, so skip ipmiutil reset -n" |tee -a $outf
+else
+ # Use hwreset -n to send an NMI.
+ runcmd "ipmiutil reset -n $LANPARAMS "
+fi
+if [ $remote -eq 1 ]; then
+ # reset if the system is remote
+ runcmd "ipmiutil reset -o $LANPARAMS "
+ # after soft-reboot, could do waitready here instead
+ sleep 80
+ runcmd "ipmiutil reset -r -w $LANPARAMS "
+ sleep 1
+ runcmd "ipmiutil reset -c -w $LANPARAMS "
+ sleep 1
+ runcmd "ipmiutil reset -d -w $LANPARAMS "
+ sleep 1
+ runcmd "ipmiutil reset -w -u $LANPARAMS "
+ # if the system isn't fully down yet, the up request may be ignored.
+ sleep 1
+ runcmd "ipmiutil reset -u $LANPARAMS "
+ # wait for init to complete
+ sleep 80
+ # Should be up now, but some systems take a bit longer for
+ # everything to come back up. So we do this last.
+fi
+
+echo "## Passed=$npass, Failed=$nfail, see $outf for detailed results"
+# remove temp files (tmpcmdr=/tmp/cmdoutr.$$ tmpcmd=/tmp/cmdout.$$)
+rm -f $tmpc $tmpin /tmp/cmdout* /tmp/selout*
+popd
+exit 0
+
diff --git a/test/unittest.cmd b/test/unittest.cmd
new file mode 100644
index 0000000..fcee7da
--- /dev/null
+++ b/test/unittest.cmd
@@ -0,0 +1,125 @@
+@echo off
+REM #!/bin/sh
+REM # unittest.cmd
+REM # Basic unit test for ipmiutil functions
+REM #
+REM # default remote node for SOL test
+set node=192.168.134.52
+set testdir=c:\temp
+set LANPARAMS=-N %node% -U ADMIN -P ADMIN
+REM set LANPARAMS=
+REM # datadir=/usr/share/ipmiutil
+REM # sfil is used only to read from with events -p -s below
+REM # normally, sfil=%datadir%/sensor-out.txt
+set outf=%testdir%\unittest.out
+set sfil=%testdir%\sensor-TIGW1U.txt
+set sfil2=%testdir%\sensor-CG2100.txt
+set tmpc=%testdir%\cfg.tmp
+set tmpin=%testdir%\sol.in
+
+echo "# ipmiutil health %LANPARAMS%" > %outf%
+ipmiutil health %LANPARAMS% >> %outf%
+ findstr /C:"health, completed successfully" %outf%
+
+echo "# ipmiutil cmd %LANPARAMS% -x 00 20 18 01 " >> %outf%
+ipmiutil cmd %LANPARAMS% -x 00 20 18 01 >> %outf%
+ findstr /C:"cmd, completed successfully" %outf%
+
+echo "# ipmiutil fru %LANPARAMS%" >> %outf%
+ipmiutil fru %LANPARAMS% >> %outf%
+ findstr /C:"fru, completed successfully" %outf%
+
+echo "# ipmiutil config %LANPARAMS% -s %tmpc%" >> %outf%
+ipmiutil config %LANPARAMS% -s %tmpc% >> %outf%
+ findstr /C:"config, completed successfully" %outf%
+
+echo "# ipmiutil lan %LANPARAMS% " >> %outf%
+ipmiutil lan %LANPARAMS% >> %outf%
+ findstr /C:"lan, completed successfully" %outf%
+
+echo "# ipmiutil sel %LANPARAMS%" >> %outf%
+ipmiutil sel %LANPARAMS% >> %outf%
+ findstr /C:"sel, completed successfully" %outf%
+
+echo "# ipmiutil sel -e %LANPARAMS%" >> %outf%
+ipmiutil sel -e %LANPARAMS% >> %outf%
+ findstr /C:"sel, completed successfully" %outf%
+
+echo "# ipmiutil sensor %LANPARAMS%" >> %outf%
+ipmiutil sensor %LANPARAMS% >> %outf%
+ findstr /C:"sensor, completed successfully" %outf%
+
+REM # ipmiutil discover -a -b 10.243.42.255 >> %outf%
+echo "# ipmiutil discover -a" >> %outf%
+ipmiutil discover -a >> %outf%
+ findstr /C:"responses" %outf%
+
+REM # Test getevt SEL method
+echo "# ipmiutil getevt -s %LANPARAMS% -t 3 " >> %outf%
+ipmiutil getevt -s %LANPARAMS% -t 3 >> %outf%
+echo "getevt -s errorlevel %errorlevel%" >> %outf%
+REM if errorlevel
+
+REM # if local, also test getevt MessageBuffer method
+echo "# ipmiutil getevt %LANPARAMS% -t 3 " >> %outf%
+ipmiutil getevt %LANPARAMS% -t 3 >> %outf%
+echo "getevt errorlevel %errorlevel%" >> %outf%
+REM if errorlevel
+
+ REM # Use hwreset -n to send an NMI.
+ echo "# ipmiutil reset %LANPARAMS% -n" >> %outf%
+ ipmiutil reset %LANPARAMS% -n >> %outf%
+ findstr /C:"reset, completed successfully" %outf%
+
+REM # Might skip SOL test if no remote server is configured for SOL.
+ echo "# ipmiutil sol -d %LANPARAMS% " >> %outf%
+ ipmiutil sol -d %LANPARAMS% >> %outf%
+
+ echo " " >%tmpin%
+ echo "root" >>%tmpin%
+ echo "password" >>%tmpin%
+ echo "ls" >>%tmpin%
+ echo "pwd" >>%tmpin%
+ echo "exit" >>%tmpin%
+ echo "~." >>%tmpin%
+ echo "# ipmiutil sol -a %LANPARAMS% -i %tmpin%" >> %outf%
+ ipmiutil sol -a %LANPARAMS% -i %tmpin% >> %outf%
+ findstr /C:"sol, completed successfully" %outf%
+
+echo "# ipmiutil events 18 00 02 02 00 00 00 20 00 04 09 01 6f 44 0f ff " >> %outf%
+ipmiutil events 18 00 02 02 00 00 00 20 00 04 09 01 6f 44 0f ff >> %outf%
+ findstr /C:"AC Lost" %outf%
+
+echo "# ievents -p -s %sfil% B3 E8 00 0E 0C C7 1B A0 11 08 12 7F 10 90 FF FF 20 20 00 20 02 15 01 41 0F FF " >> %outf%
+ievents -p -s %sfil% B3 E8 00 0E 0C C7 1B A0 11 08 12 7F 10 90 FF FF 20 20 00 20 02 15 01 41 0F FF >> %outf%
+ findstr /C:"Redundancy Lost" %outf%
+
+echo "# ipmiutil events -s %sfil2% -p B5 19 00 15 17 C6 C9 D0 00 02 B2 76 C1 16 FF FF 20 20 10 20 20 00 00 52 1D 20 00 00 00 00 00 00 00 00 00 00 00 00 C1 00 00 00 00 00 00 00 00 00 00" >> %outf%
+ipmiutil events -s %sfil2% -p B5 19 00 15 17 C6 C9 D0 00 02 B2 76 C1 16 FF FF 20 20 10 20 20 00 00 52 1D 20 00 00 00 00 00 00 00 00 00 00 00 00 C1 00 00 00 00 00 00 00 00 00 00 >> %outf%
+ findstr /C:"Lo Crit thresh" %outf%
+
+echo "# ievents 40 78 02 37 86 41 4e 20 00 04 0c 08 6f 20 ff 04" >> %outf%
+ievents 40 78 02 37 86 41 4e 20 00 04 0c 08 6f 20 ff 04 >> %outf%
+ findstr /C:"DIMM" %outf%
+
+echo "# ipmiutil events -d 40 78 02 37 86 41 4e 20 00 04 0c 08 6f 20 ff 04" >> %outf%
+ipmiutil events -d 40 78 02 37 86 41 4e 20 00 04 0c 08 6f 20 ff 04 >> %outf%
+ findstr /C:"DIMM" %outf%
+
+echo "# ipmiutil wdt %LANPARAMS%" >> %outf%
+ipmiutil wdt %LANPARAMS% >> %outf%
+ findstr /C:"wdt, completed successfully" %outf%
+
+REM # some platforms do not support IPMI serial channels
+ echo "# ipmiutil serial %LANPARAMS%" >> %outf%
+ ipmiutil serial %LANPARAMS% >> %outf%
+ findstr /C:"serial, completed successfully" %outf%
+
+REM # The model can be used to detect if the chassis has an alarm panel.
+REM echo "MODEL=%MODEL%" >> %outf%
+REM # Run it anyway, the alarms command has better detection now.
+
+ echo "# ipmiutil alarms %LANPARAMS%" >> %outf%
+ ipmiutil alarms %LANPARAMS% >> %outf%
+ findstr /C:"alarms, completed successfully" %outf%
+
diff --git a/test/unittest.sh b/test/unittest.sh
new file mode 100755
index 0000000..f1ac9ab
--- /dev/null
+++ b/test/unittest.sh
@@ -0,0 +1,254 @@
+#!/bin/sh
+# unittest.sh [node_ip]
+# Basic unit test for ipmiutil functions
+#
+dosol=0
+doserial=0
+outf=/tmp/unittest.out
+# default remote node for SOL test
+node=192.168.1.154
+mydir=`pwd`
+indir=`dirname $0`
+c1=`echo $indir |cut -c1`
+if [ "$c1" = "/" ]; then
+ testdir=$indir
+else
+ testdir=$mydir/$indir
+fi
+# datadir=/usr/share/ipmiutil
+datadir=/var/lib/ipmiutil
+# sfil is used only to read from with events -p -s below
+# normally, sfil=$datadir/sensor-out.txt
+sfil=${testdir}/sensor-TIGW1U.txt
+sfil2=${testdir}/sensor-CG2100.txt
+tmpc=/tmp/cfg.tmp
+tmpin=/tmp/sol.in
+# march=`rpmbuild --showrc |grep " _target_cpu" | head -n1 |awk '{print $3}'`
+uarch=`uname -m`
+LANPARAMS=
+os=`uname -s`
+if [ "$os" = "SunOS" ];then
+TAIL="tail -1"
+TAIL2="tail -2"
+else
+TAIL="tail -n1"
+TAIL2="tail -n2"
+fi
+
+if [ $# -ge 1 ];then
+ node=$1
+ # use canned username and password, edit as needed.
+ LANPARAMS="-N $node -U admin -P password"
+fi
+
+>$outf
+cd /tmp
+echo "# ipmiutil sel -v $LANPARAMS" |tee -a $outf
+ipmiutil sel -v $LANPARAMS >>$outf 2>&1
+if [ $? -ne 0 ]; then
+ echo "No IPMI support detected"
+ exit 1
+fi
+
+echo "# ipmiutil health $LANPARAMS" |tee -a $outf
+ipmiutil health $LANPARAMS |tee -a $outf
+$TAIL $outf |grep successful >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+echo "# ipmiutil cmd $LANPARAMS -x 00 20 18 01 " |tee -a $outf
+ipmiutil cmd $LANPARAMS -x 00 20 18 01 2>&1 |tee -a $outf
+$TAIL $outf |grep successful >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+echo "# ipmiutil fru $LANPARAMS" |tee -a $outf
+ipmiutil fru $LANPARAMS 2>&1 |tee -a $outf
+$TAIL $outf |grep successful >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+MODEL=`grep "Chassis OEM Field" $outf| cut -f2 -d':'| awk '{ print $1 }'`
+echo "# ipmiutil config $LANPARAMS -s $tmpc" |tee -a $outf
+ipmiutil config $LANPARAMS -s $tmpc 2>&1 |tee -a $outf
+$TAIL $outf |grep successful >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+echo "# ipmiutil lan $LANPARAMS " |tee -a $outf
+ipmiutil lan $LANPARAMS 2>&1 |tee -a $outf
+$TAIL $outf |grep successful >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+echo "# ipmiutil sel $LANPARAMS" |tee -a $outf
+ipmiutil sel $LANPARAMS 2>&1 |tee -a $outf
+$TAIL $outf |grep successful >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+echo "# ipmiutil sel -e $LANPARAMS" |tee -a $outf
+ipmiutil sel -e $LANPARAMS 2>&1 |tee -a $outf
+$TAIL $outf |grep successful >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+echo "# ipmiutil sensor $LANPARAMS" |tee -a $outf
+ipmiutil sensor $LANPARAMS 2>&1 |tee -a $outf
+$TAIL $outf |grep successful >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+# ipmiutil discover -a -b 10.243.42.255 |tee -a $outf
+echo "# ipmiutil discover -a" |tee -a $outf
+ipmiutil discover -a 2>&1 |tee -a $outf
+$TAIL2 $outf |grep responses >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+# Test getevt SEL method
+echo "# ipmiutil getevt -s $LANPARAMS -t 3 " |tee -a $outf
+ipmiutil getevt -s $LANPARAMS -t 3 2>&1 |tee -a $outf
+rv=$?
+# $TAIL $outf |grep successful >/dev/null
+if [ $rv -ne 0 ]; then
+ echo "igetevt error $rv"
+ exit 1
+fi
+
+if [ "x$LANPARAMS" = "x" ]; then
+# if local, also test getevt MessageBuffer method
+echo "# ipmiutil getevt $LANPARAMS -t 3 " |tee -a $outf
+ipmiutil getevt $LANPARAMS -t 3 2>&1 |tee -a $outf
+rv=$?
+# $TAIL $outf |grep successful >/dev/null
+if [ $rv -ne 0 ]; then
+ echo "igetevt error $rv"
+ exit 1
+fi
+fi
+
+if [ "$uarch" = "ia64" ]
+then
+ # Note that ireset -n causes a real reset on ia64 (?)
+ echo "skipping ia64 ipmiutil reset" |tee -a $outf
+else
+ # Use hwreset -n to send an NMI.
+ echo "# ipmiutil reset $LANPARAMS -n" |tee -a $outf
+ ipmiutil reset $LANPARAMS -n 2>&1 |tee -a $outf
+ $TAIL $outf |grep successful >/dev/null
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+# Might not do SOL test if no remote server is configured for SOL.
+if [ $dosol -eq 1 ]; then
+ echo "# ipmiutil sol -d -N $node " |tee -a $outf
+ ipmiutil sol -d -N $node 2>&1 |tee -a $outf
+ cat - <<%%% >$tmpin
+
+root
+password
+ls
+pwd
+echo success
+exit
+~.
+%%%
+ echo "# ipmiutil sol -a -N $node -i $tmpin " |tee -a $outf
+ ipmiutil sol -a -N $node -i $tmpin 2>&1 |tee -a $outf
+ $TAIL $outf |grep successful >/dev/null
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+echo "# ipmiutil events 18 00 02 02 00 00 00 20 00 04 09 01 6f 44 0f ff " |tee -a $outf
+ipmiutil events 18 00 02 02 00 00 00 20 00 04 09 01 6f 44 0f ff |tee -a $outf
+$TAIL2 $outf |grep "AC Lost" >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+
+echo "# ievents -p -s $sfil B3 E8 00 0E 0C C7 1B A0 11 08 12 7F 10 90 FF FF 20 20 00 20 02 15 01 41 0F FF " |tee -a $outf
+ievents -p -s $sfil B3 E8 00 0E 0C C7 1B A0 11 08 12 7F 10 90 FF FF 20 20 00 20 02 15 01 41 0F FF |tee -a $outf
+$TAIL2 $outf |grep "Redundancy Lost" >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+
+echo "# ipmiutil events -s $sfil2 -p B5 19 00 15 17 C6 C9 D0 00 02 B2 76 C1 16 FF FF 20 20 10 20 20 00 00 52 1D 20 00 00 00 00 00 00 00 00 00 00 00 00 C1 00 00 00 00 00 00 00 00 00 00" |tee -a $outf
+ipmiutil events -s $sfil2 -p B5 19 00 15 17 C6 C9 D0 00 02 B2 76 C1 16 FF FF 20 20 10 20 20 00 00 52 1D 20 00 00 00 00 00 00 00 00 00 00 00 00 C1 00 00 00 00 00 00 00 00 00 00 |tee -a $outf
+$TAIL2 $outf |grep "Lo Crit thresh" >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+
+echo "# ievents 40 78 02 37 86 41 4e 20 00 04 0c 08 6f 20 ff 04" |tee -a $outf
+ievents 40 78 02 37 86 41 4e 20 00 04 0c 08 6f 20 ff 04 |tee -a $outf
+$TAIL2 $outf |grep DIMM >/dev/null
+if [ $? -ne 0 ]; then
+ echo "DIMM event FAIL"
+ exit 1
+fi
+
+echo "# ipmiutil events -d 40 78 02 37 86 41 4e 20 00 04 0c 08 6f 20 ff 04" |tee -a $outf
+ipmiutil events -d 40 78 02 37 86 41 4e 20 00 04 0c 08 6f 20 ff 04 |tee -a $outf
+$TAIL2 $outf |grep DIMM >/dev/null
+if [ $? -ne 0 ]; then
+ echo "DIMM event FAIL"
+ exit 1
+fi
+
+echo "# ipmiutil wdt $LANPARAMS" |tee -a $outf
+ipmiutil wdt $LANPARAMS 2>&1 |tee -a $outf
+$TAIL $outf |grep successful >/dev/null
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+
+if [ $doserial -eq 1 ]; then
+ # some platforms do not support IPMI serial channels
+ echo "# ipmiutil serial $LANPARAMS" |tee -a $outf
+ ipmiutil serial $LANPARAMS 2>&1 |tee -a $outf
+ $TAIL $outf |grep successful >/dev/null
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+# The model can be used to detect if the chassis has an alarm panel.
+echo "MODEL=$MODEL" |tee -a $outf
+case "$MODEL" in
+ TIGW1U) tamok=1
+ ;;
+ TIGH2U) tamok=1
+ ;;
+ TIGI2U) tamok=1
+ ;;
+ TIGPR2U) tamok=1
+ ;;
+ TIGPT1U) tamok=1
+ ;;
+ TSRLT2) tamok=1
+ ;;
+ TSRMT2) tamok=1
+ ;;
+ CG2100) tamok=1
+ ;;
+ *) tamok=0
+ ;;
+esac
+# Run it anyway, the alarms command has better detection now.
+tamok=1
+if [ $tamok -eq 1 ]; then
+ echo "# ipmiutil alarms $LANPARAMS" |tee -a $outf
+ ipmiutil alarms $LANPARAMS 2>&1 |tee -a $outf
+ $TAIL $outf |grep successful >/dev/null
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+cd $mydir
+