Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Commit

Permalink
Add test for ACPI table
Browse files Browse the repository at this point in the history
  • Loading branch information
ftjahjad authored and veruu committed Feb 12, 2019
1 parent 89421cd commit 9e9bf0d
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 0 deletions.
53 changes: 53 additions & 0 deletions acpi/acpitable/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright (c) 2019 Red Hat, Inc. All rights reserved. This copyrighted material
# is made available to anyone wishing to use, modify, copy, or
# redistribute it subject to the terms and conditions of the GNU General
# Public License v.2.
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Author: Al Stone <ahs3@redhat.com>

TOPLEVEL_NAMESPACE=kernel
PACKAGE_NAME=acpi/acpitable

export TESTVERSION=1.0
export TEST=/$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)

BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE

.PHONY: all install download clean

run: $(FILES) build
./runtest.sh

build: $(BUILT_FILES)
chmod a+x runtest.sh

clean:
rm -f *~ $(BUILT_FILES)

# Include Common Makefile
include /usr/share/rhts/lib/rhts-make.include

# Generate the testinfo.desc here:
$(METADATA): Makefile
@touch $(METADATA)
@echo "Owner: Al Stone <ahs3@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: ACPI table Test Utility" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "RunFor: $(TOPLEVEL_NAMESPACE)" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Requires: acpica-tools" >> $(METADATA)
3 changes: 3 additions & 0 deletions acpi/acpitable/PURPOSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Verify ACPI Table is present in sysfs.
acpidump will try to read files from /sys/firmware/acpi/tables, and capture a copy of the tables.
The test will PASS when ACPI table is readable and can be captured.
11 changes: 11 additions & 0 deletions acpi/acpitable/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ACPI table test suite
Testing ACPI table is present in sysfs. \
Test Maintainer: [Al Stone](mailto:ahs3@redhat.com)

## How to run it
Please refer to the top-level README.md for common dependencies. Test-specific dependencies will automatically be installed when executing 'make run'. For a complete detail, see PURPOSE file.

### Execute the test
```bash
$ make run
```
67 changes: 67 additions & 0 deletions acpi/acpitable/runtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

#--------------------------------------------------------------------------------
# Copyright (c) 2019 Red Hat, Inc. All rights reserved. This copyrighted material
# is made available to anyone wishing to use, modify, copy, or
# redistribute it subject to the terms and conditions of the GNU General
# Public License v.2.
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Author: Al Stone <ahs3@redhat.com>
#---------------------------------------------------------------------------------
#
# Simple test: are ACPI tables present?
#
# There's no foolproof method to know, but we can check to see
# if acpidump can read files from /sys/firmware/acpi/tables. An
# added bonus is that we capture a copy of the tables, too.
#---------------------------------------------------------------------------------

# Source the common test script helpers
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1

# Global variables
ret=0

# make sure acpica-tools are installed
pkg=$(rpm -qa | grep acpica-tools)
if [ -z "$pkg" ] ; then
report_result $TEST WARN
rhts-abort -t recipe
fi

# verify ACPI is enabled in the kernel
msg=$(journalctl -b 0 -o short-monotonic | grep "ACPI: Interpreter enabled")

# no message found, so fail
if [ -z "$msg" ] ; then
ret=1
echo "ACPI: Intepreter disabled in the kernel!" | tee -a $OUTPUTFILE
fi

if [ $ret = 0 ] ; then
# try to read ACPI tables from sysfs
# run acpidump, which should succeed and write tables to stdout
# (requires being run as root)
mkdir -p /mnt/redhat/user/acpi/
acpidump > /mnt/redhat/user/acpi/acpitable.log 2>&1
ret=$?
rhts_submit_log -l /mnt/redhat/user/acpi/acpitable.log
fi

echo "Test finished" | tee -a $OUTPUTFILE

if [ $ret != 0 ] ; then
report_result $TEST FAIL $ret
else
# all is well
report_result $TEST PASS 0
fi

0 comments on commit 9e9bf0d

Please sign in to comment.