From e9dea8a3ac12714d2ca6f765a96bbae1216837ff Mon Sep 17 00:00:00 2001 From: Mike Gahagan Date: Fri, 21 Sep 2018 15:08:53 -0400 Subject: [PATCH] Add the dump-tables test - uses acpidump to dump the acpi tables - then uses iasl to attempt to disassemble the dump table files. --- tests/dump-tables/Makefile | 52 +++++++++++++++++++++ tests/dump-tables/PURPOSE | 13 ++++++ tests/dump-tables/runtest.sh | 90 ++++++++++++++++++++++++++++++++++++ tests/test_dump-tables.yml | 12 +++++ tests/tests.yml | 1 + 5 files changed, 168 insertions(+) create mode 100644 tests/dump-tables/Makefile create mode 100644 tests/dump-tables/PURPOSE create mode 100755 tests/dump-tables/runtest.sh create mode 100644 tests/test_dump-tables.yml diff --git a/tests/dump-tables/Makefile b/tests/dump-tables/Makefile new file mode 100644 index 0000000..c465f06 --- /dev/null +++ b/tests/dump-tables/Makefile @@ -0,0 +1,52 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/acpica-tools/dump-tables +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Author, maintainer and description of the test +AUTHOR=Mike Gahagan +DESCRIPTION=Uses the utilities in acpica-tools to dump the ACPI tables on a system and upload to Beaker. +PACKAGE=acpica-tools + +# The name of the test. +export TEST=/CoreOS/acpica-tools/dump-tables + +# Version of the test. Used with make tag. +export TESTVERSION=2.0 + + +# data files, .c files, scripts anything needed to either compile the test and/or run it. +FILES=$(METADATA) runtest.sh PURPOSE Makefile + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) $(FILES) + chmod a+x ./runtest.sh + +clean: + rm -f *~ *.rpm + rm -f $(METADATA) + rm -rf /mnt/testarea/dump-tables + +# Include Common Makefile +include /usr/share/rhts/lib/rhts-make.include + +# Generate the testinfo.desc here: +$(METADATA): Makefile + @touch $(METADATA) + @echo "Owner: $(AUTHOR)" > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Description: $(DESCRIPTION)" >> $(METADATA) + @echo "TestTime: 12m" >> $(METADATA) + @echo "RunFor: $(PACKAGE)" >> $(METADATA) + @echo "Architectures: aarch64 i386 x86_64 ppc64 ppc64le" >> $(METADATA) + @echo "Type: Functional" >> $(METADATA) + @echo "Requires: $(PACKAGE)" >> $(METADATA) + rhts-lint $(METADATA) +# The include package takes care of all the dependencies +# Add any other dependencies there (/kernel/filesystems/xfs/include) diff --git a/tests/dump-tables/PURPOSE b/tests/dump-tables/PURPOSE new file mode 100644 index 0000000..fab29fb --- /dev/null +++ b/tests/dump-tables/PURPOSE @@ -0,0 +1,13 @@ +Uses the utilities in acpica-tools to dump the ACPI tables on a system and upload to Beaker. + The task will do the following: + - Capture the acpi tables currently in use by the running kernel in binary format (acpidump-acpica -b) + - Capture namespace information from the DSDT (acpinames dsdt.dat) + - Capture the acpi tables currently in use by the running kernel hexidecmal encoded (acpidump-acpica -o somefile.hex) + - Decompile the table files from the binary tables and store the resulting source code (iasl -d on each .dat file) + - Archive all of the above and send to Beaker. + +Paramaters: +ACPIDUMP_BIN - Set to path/to/alternate-acpidump-binary to use a different acpidump tool from what acpica-tools provides, + set to "_sys_firmware" to bypass use of acpidump completely and dump from /sys/firmware/acpi/tables/ instead + +note: using the acpidump binary is not supported on all platforms diff --git a/tests/dump-tables/runtest.sh b/tests/dump-tables/runtest.sh new file mode 100755 index 0000000..0e6b824 --- /dev/null +++ b/tests/dump-tables/runtest.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/acpica-tools/dump-tables +# Description: Uses the utilities in acpica-tools to dump the ACPI tables on a system and upload to Beaker. +# Author: Mike Gahagan +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2017 Red Hat, Inc. +# +# 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 version 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh +. /usr/share/beakerlib/beakerlib.sh +TESTNAME=$(basename $TEST) +OUTPUTDIR=/mnt/testarea/$TESTNAME +log_dir=$OUTPUTDIR/logs +# RHEL uses /usr/bin/acpidump-acpica, Fedora uses /usr/bin/acpidump +#ACPIDUMP_BIN="${ACPIDUMP_BIN:-acpidump-acpica}" +ACPIDUMP_BIN="${ACPIDUMP_BIN:-acpidump}" +PACKAGE="acpica-tools" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + [ $? -eq 0 ] || rlDie "$PACKAGE must be installed!... aborting.." + rlGetDistroRelease + rlGetDistroVariant + rlShowRunningKernel + rlGetPrimaryArch + rlGetSecondaryArch + rlRun "mkdir -p $OUTPUTDIR/{bin,logs,asl,hex}" 0 "Making output directories" + [ $? -eq 0 ] || rlDie "Cannot make output directories!... aborting.." + rlLog "Using acpidump binary: $ACPIDUMP_BIN" + rlPhaseEnd + + rlPhaseStartTest + pushd $OUTPUTDIR/bin + if [[ $ACPIDUMP_BIN = "_sys_firmware" ]] ; then + rlLog "Dumping tables from /sys/firmware/acpi/tables..." + find /sys/firmware/acpi/tables/ -type f | while read f ; do + name="$(basename $f | tr '[[:upper:]]' '[[:lower:]]').dat" + cat $f > $name + done + else + rlRun "$ACPIDUMP_BIN -bz" 0 "Dumping binary ACPI info..." + fi + rlRun "acpinames dsdt.dat > ../logs/DSDT-ACPI-namespace.out 2>&1" 0 "Extracting namespace information from DSDT" + rlLog "Decompiling binary files" + for f in $(ls *.dat) ; do + rlRun "iasl -d $f" 0 "Decompiling $f" + done + rlRun "mv *.dsl ../asl" 0 "Moving source files to $OUTPUTDIR/asl" + popd + if [[ $ACPIDUMP_BIN != "_sys_firmware" ]]; then + rlRun "$ACPIDUMP_BIN -o $OUTPUTDIR/hex/$HOSTNAME-ACPI-TABLE.hex" 0 "Dumping hex-encoded ACPI info" + fi + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "tar -Jcf $log_dir/$HOSTNAME-ACPI-TABLE-AML.tar.xz $OUTPUTDIR/bin" 0 "Archiving aml files..." + rlRun "tar -Jcf $log_dir/$HOSTNAME-ACPI-TABLE-ASL.tar.xz $OUTPUTDIR/asl" 0 "Archiving asl files..." + if [ -f $OUTPUTDIR/hex/$HOSTNAME-ACPI-TABLE.hex ]; then + rlRun "cp $OUTPUTDIR/hex/$HOSTNAME-ACPI-TABLE.hex $log_dir" 0 "Copying hex-encoded ACPI info to log directory" + fi + for f in $log_dir/*; do + if [ -f $f ] ; then + rlFileSubmit $f + fi + done + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/test_dump-tables.yml b/tests/test_dump-tables.yml new file mode 100644 index 0000000..4c9c309 --- /dev/null +++ b/tests/test_dump-tables.yml @@ -0,0 +1,12 @@ +# Tests that run in classic and atomic +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - classic + - atomic + tests: + - dump-tables + required_packages: + - acpica-tools + diff --git a/tests/tests.yml b/tests/tests.yml index 4a92e7c..001580a 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -2,3 +2,4 @@ - import_playbook: test_grammar.yml - import_playbook: test_grammar2.yml - import_playbook: test_converterSample.yml +- import_playbook: test_dump-tables.yml