#!/bin/bash # vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # runtest.sh of /CoreOS/lshw/sanity/check-output # Description: Install version of lshw that matches the installed distro. # Author: Mike Gahagan # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # Copyright (c) 2015 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 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 # Set constants TESTNAME=$(basename $TEST) OUTPUTDIR=/mnt/testarea/$TESTNAME log_dir=$OUTPUTDIR/logs PACKAGE="lshw" rlJournalStart rlPhaseStartSetup rlGetDistroRelease rlGetDistroVariant rlShowRunningKernel rlGetPrimaryArch rlGetSecondaryArch rlRun "mkdir -p $log_dir" 0 "Making output directories" [ $? -eq 0 ] || rlDie "Cannot make output directories!... aborting.." if [ -x /usr/bin/sqlite3 ]; then my_sqlite=sqlite3 elif [ -x /usr/bin/sqlite ]; then my_sqlite=sqlite else rlRun "which sqlite" 0 "output of which sqlite" rlDie "sqlite does not appear to be installed properly" fi rlIsRHEL 8 if [[ $? -eq 0 ]] ; then PYTHON_BIN="python3" else PYTHON_BIN="python" fi rlPhaseEnd rlPhaseStartTest rlCheckRpm $PACKAGE RC=$? if [ $RC -ne 0 ]; then rlDie "Please make sure $PACKAGE is installed before running this test" fi rlRun -c "rpm -q lshw | grep -qv beaker" 0 "Check to see if beaker $PACKAGE is not installed" rlRun "lshw -version" 0 "Getting lshw version information" rlRun "lshw -help" 0 "Getting lshw command line help information" rlRun "lshw > $log_dir/lshw.out" 0 "Running lshw with no options and logging output" rlRun "lshw -sanitize > $log_dir/lshw.out.sanitized" 0 "Running lshw and logging sanitized output" rlRun -c "grep -q \[REMOVED\] $log_dir/lshw.out.sanitized" 0 "Checking that sensitive information is removed from sanitized output" rlRun "diff -uNr $log_dir/lshw.out $log_dir/lshw.out.sanitized > $log_dir/lshw.out.diff" 0,1 "Generating diff of unsanitized and sanitized output" rlRun "lshw -html > $log_dir/lshw.out.html" 0 "Running lshw and logging html output" rlRun -c "xmllint --html --noout $log_dir/lshw.out.html" 0 "Validating html output" rlRun "lshw -xml > $log_dir/lshw.out.xml" 0 "running lshw and logging xml output" rlRun -c "xmllint --noout $log_dir/lshw.out.xml" 0 "Validating xml output" # rlRun "lshw -json > $log_dir/lshw.out.json" 0 "Running lshw and logging json output" # rlRun -c "${PYTHON_BIN} -m json.tool < $log_dir/lshw.out.json > /dev/null" 0 "Validating json output" rlRun "lshw -dump $log_dir/lshw.out.sql > /dev/null" 0 "Running lshw and logging sql output" rlRun -c "${my_sqlite} $log_dir/lshw.out.sql \"PRAGMA integrity_check\"" 0 "Validating sql output" rlPhaseEnd rlPhaseStartCleanup for f in $log_dir/*; do if [ -f $f ] ; then rlFileSubmit $f fi done rlPhaseEnd rlJournalPrintText rlJournalEnd