diff --git a/.gitignore b/.gitignore index f79098b..4fcf09c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ -SOURCES/lshw-B.02.19.2.tar.gz +lshw-B.02.14.tar.gz +/lshw-B.02.15.tar.gz +/lshw-B.02.16.tar.gz +/lshw-B.02.17.tar.gz +/lshw-B.02.18.tar.gz /lshw-B.02.19.2.tar.gz diff --git a/tests/selftest/Makefile b/tests/selftest/Makefile new file mode 100644 index 0000000..c1f4f2e --- /dev/null +++ b/tests/selftest/Makefile @@ -0,0 +1,52 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/lshw/sanity/check-output +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Author, maintainer and description of the test +AUTHOR=Mike Gahagan +DESCRIPTION=Install version of lshw that matches the installed distro. +PACKAGE=lshw + +# The name of the test. +export TEST=/CoreOS/lshw/sanity/check-output + +# Version of the test. Used with make tag. +export TESTVERSION=1.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) + +# 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: 5m" >> $(METADATA) + @echo "RunFor: $(PACKAGE)" >> $(METADATA) +# @echo "Releases: RHELServer5 RHEL6" >> $(METADATA) + @echo "Type: Functional" >> $(METADATA) + @echo "Requires: $(PACKAGE)" >> $(METADATA) + @echo "Requires: sqlite sqlite3 python3 libxml2" >> $(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/selftest/PURPOSE b/tests/selftest/PURPOSE new file mode 100644 index 0000000..5b829c5 --- /dev/null +++ b/tests/selftest/PURPOSE @@ -0,0 +1,26 @@ +Purpose of /CoreOS/lshw/sanity/check-output + +Perform basic validation of text based output of the lshw tool + +-version + -- log the output of 'lshw -version' + +-help + -- log the output of 'lshw -help' + +default options + -- log the output of 'lshw' with no options + +-html + -- log the output of 'lshw -html' and validate using 'xmllint --html' + +-xml + -- log the output of 'lshw -xml' and validate using 'xmllint --xml' + +-dump + -- log the output of 'lshw -dump' and validate using sqlite + +-sanitize + -- log the output of 'lshw -sanitize' and validate by searching for 'serial: [REMOVED]' + + diff --git a/tests/selftest/runtest.sh b/tests/selftest/runtest.sh new file mode 100755 index 0000000..2e74019 --- /dev/null +++ b/tests/selftest/runtest.sh @@ -0,0 +1,94 @@ +#!/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 diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..c7183f5 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,23 @@ +--- +# This first play always runs on the local staging system +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - classic + tests: + - selftest + required_packages: + - cmake + - desktop-file-utils + - gcc + - gcc-c++ + - gettext + - gtk2-devel + - libappstream-glib + - ninja-build + - python36-devel + - hwdata + - polkit + - sqlite + - sqlite-devel