#1 Initial commit for hwdata sanity tests
Merged 8 months ago by vcrhonek. Opened 8 months ago by rasibley.
rpms/ rasibley/hwdata hwdata-sanity-tests  into  master

@@ -0,0 +1,65 @@ 

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Makefile of /kernel/hwdata/Sanity/ids-files

+ #   Description: compares upstream ID files with our ID files

+ #   Author: Milos Malik <mmalik@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2009 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.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ export TEST=/kernel/hwdata/Sanity/ids-files

+ export TESTVERSION=1.0

+ 

+ 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

+ 	chcon -t bin_t runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ include /usr/share/rhts/lib/rhts-make.include

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:           Milos Malik <mmalik@redhat.com>" > $(METADATA)

+ 	@echo "Name:            $(TEST)" >> $(METADATA)

+ 	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)

+ 	@echo "Path:            $(TEST_DIR)" >> $(METADATA)

+ 	@echo "Description:     compares upstream ID files with our ID files" >> $(METADATA)

+ 	@echo "Type:            Sanity" >> $(METADATA)

+ 	@echo "TestTime:        5m" >> $(METADATA)

+ 	@echo "RunFor:          hwdata" >> $(METADATA)

+ 	@echo "Requires:        hwdata" >> $(METADATA)

+ 	@echo "Requires:        wget" >> $(METADATA)

+ 	@echo "Priority:        Normal" >> $(METADATA)

+ 	@echo "License:         GPLv2" >> $(METADATA)

+ 	@echo "Confidential:    no" >> $(METADATA)

+ 	@echo "Destructive:     no" >> $(METADATA)

+ 

+ 	rhts-lint $(METADATA)

+ 

@@ -0,0 +1,6 @@ 

+ PURPOSE of /kernel/hwdata/Sanity/ids-files

+ 

+ Description: compares upstream ID files with our ID files

+ 

+ Author: Milos Malik <mmalik@redhat.com>

+ 

@@ -0,0 +1,91 @@ 

+ #!/bin/bash

+ # vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /kernel/hwdata/Sanity/ids-files

+ #   Description: compares upstream ID files with our ID files

+ #   Author: Milos Malik <mmalik@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2009 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 rhts environment

+ . /usr/bin/rhts-environment.sh

+ . /usr/lib/beakerlib/beakerlib.sh

+ 

+ PACKAGE="hwdata"

+ HWDATA_DIR="/usr/share/hwdata"

+ PCI_IDS_FILE="pci.ids"

+ PCI_IDS_URL="http://pci-ids.ucw.cz/v2.2/pci.ids"

+ USB_IDS_FILE="usb.ids"

+ USB_IDS_URL="http://www.linux-usb.org/usb.ids"

+ MONITORS_FILE="MonitorsDB"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm ${PACKAGE}

+         rlAssertRpm wget

+         rlAssertExists ${HWDATA_DIR}/${PCI_IDS_FILE}

+         rlAssertExists ${HWDATA_DIR}/${USB_IDS_FILE}

+         if rlIsRHEL 6 ; then

+             rlAssertExists ${HWDATA_DIR}/${MONITORS_FILE}

+         fi

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         rlRun "wget -q -t 4 ${PCI_IDS_URL}"

+         rlAssertExists ${PCI_IDS_FILE}

+         echo "Lines in upstream file: "`wc -l < ${PCI_IDS_FILE}`

+         echo "Lines in our file: "`wc -l < ${HWDATA_DIR}/${PCI_IDS_FILE}`

+         echo "Common lines: "`comm -1 -2 ${PCI_IDS_FILE} ${HWDATA_DIR}/${PCI_IDS_FILE} | wc -l`

+         echo "Different lines in upstream file: "`comm -2 -3 ${PCI_IDS_FILE} ${HWDATA_DIR}/${PCI_IDS_FILE} | wc -l`

+         echo "Different lines in our file: "`comm -1 -3 ${PCI_IDS_FILE} ${HWDATA_DIR}/${PCI_IDS_FILE} | wc -l`

+ 

+         rlRun "wget -q -t 4 ${USB_IDS_URL}"

+         rlAssertExists ${USB_IDS_FILE}

+         echo "Lines in upstream file: "`wc -l < ${USB_IDS_FILE}`

+         echo "Lines in our file: "`wc -l < ${HWDATA_DIR}/${USB_IDS_FILE}`

+         echo "Common lines: "`comm -1 -2 ${USB_IDS_FILE} ${HWDATA_DIR}/${USB_IDS_FILE} | wc -l`

+         echo "Different lines in upstream file: "`comm -2 -3 ${USB_IDS_FILE} ${HWDATA_DIR}/${USB_IDS_FILE} | wc -l`

+         echo "Different lines in our file: "`comm -1 -3 ${USB_IDS_FILE} ${HWDATA_DIR}/${USB_IDS_FILE} | wc -l`

+ 

+         if ! rlIsRHEL 7 ; then

+             rlLog "Checking the format of ${HWDATA_DIR}/${MONITORS_FILE}"

+         fi

+         LINE=0

+         while read ; do

+             let "LINE += 1"

+             if echo ${REPLY} | grep -e '^#' -e '^ *$' >& /dev/null ; then

+                 continue

+             fi

+             COUNT=`echo ${REPLY} | tr ';' '\n' | wc -l`

+             if [ ${COUNT} -lt 5 -o ${COUNT} -gt 6 ] ; then

+                 rlFail "Wrong format on line ${LINE}"

+             fi

+         done < ${HWDATA_DIR}/${MONITORS_FILE}

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "rm -f ${PCI_IDS_FILE}"

+         rlRun "rm -f ${USB_IDS_FILE}"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

@@ -0,0 +1,68 @@ 

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Makefile of /kernel/hwdata/idfiles/syntax

+ #   Description: checks for basic syntax errors

+ #   Author: Milos Malik <mmalik@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2009 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.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ export TEST=/kernel/hwdata/idfiles/syntax

+ export TESTVERSION=1.0

+ 

+ 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 /usr/share/rhts/lib/rhts-make.include

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:           Milos Malik <mmalik@redhat.com>" > $(METADATA)

+ 	@echo "Name:            $(TEST)" >> $(METADATA)

+ 	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)

+ 	@echo "Path:            $(TEST_DIR)" >> $(METADATA)

+ 	@echo "Description:     checks for basic syntax errors" >> $(METADATA)

+ 	@echo "Type:            Sanity" >> $(METADATA)

+ 	@echo "TestTime:        5m" >> $(METADATA)

+ 	@echo "RunFor:          hwdata" >> $(METADATA)

+ 	@echo "Requires:        hwdata" >> $(METADATA)

+ 	@echo "Requires:        pciutils" >> $(METADATA)

+ 	@echo "Requires:        usbutils" >> $(METADATA)

+ 	@echo "Requires:        grep" >> $(METADATA)

+ 	@echo "Requires:        mktemp" >> $(METADATA)

+ 	@echo "Priority:        Normal" >> $(METADATA)

+ 	@echo "License:         GPLv2" >> $(METADATA)

+ 	@echo "Confidential:    no" >> $(METADATA)

+ 	@echo "Destructive:     no" >> $(METADATA)

+ 	@echo "Architectures:   i386 x86_64 ia64" >> $(METADATA)

+ 

+ 	rhts-lint $(METADATA)

+ 

@@ -0,0 +1,6 @@ 

+ PURPOSE of /kernel/hwdata/idfiles/syntax

+ 

+ Description: checks for basic syntax errors

+ 

+ Author: Milos Malik <mmalik@redhat.com>

+ 

@@ -0,0 +1,55 @@ 

+ #!/bin/bash

+ # vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /kernel/hwdata/idfiles/syntax

+ #   Description: checks for basic syntax errors

+ #   Author: Milos Malik <mmalik@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2009 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 rhts environment

+ . /usr/bin/rhts-environment.sh

+ . /usr/lib/beakerlib/beakerlib.sh

+ 

+ PACKAGE="hwdata"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm ${PACKAGE}

+         rlAssertRpm pciutils

+         rlAssertRpm usbutils

+         OUTPUT_FILE=`mktemp`

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         rlRun "lspci >& ${OUTPUT_FILE}"

+         rlRun "grep -i 'unknown line' ${OUTPUT_FILE}" 1

+         rlRun "lsusb >& ${OUTPUT_FILE}" 0,1

+         rlRun "grep -i 'unknown line' ${OUTPUT_FILE}" 1

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rm -f ${OUTPUT_FILE}

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

file added
+18

@@ -0,0 +1,18 @@ 

+ ---

+ # This first play always runs on the local staging system

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - classic

+     tests:

+     - ids-files

+     - syntax

+     required_packages:

+     - hwdata

+     - pciutils

+     - usbutils

+     - grep

+     - mktemp

+     - hwdata

+     - wget

Add downstream tests according to the CI wiki [0] specifically the standard test interface in the spec [1].

The playbook includes Tier1 level test cases that are passing reliably with latest Fedora (classic mode), test logs are stored in the artifacts directory.

# dnf install -y standard-test-roles

# ansible-playbook --tags=classic tests.yml 

PLAY [localhost] **************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [localhost]

...

TASK [standard-test-beakerlib : Run beakerlib tests] ************************************************************************************************************************
changed: [localhost] => (item=ids-files)
changed: [localhost] => (item=syntax)

TASK [standard-test-beakerlib : Make the master tests summary log artifact] *************************************************************************************************
changed: [localhost] => (item=ids-files)
changed: [localhost] => (item=syntax)

TASK [standard-test-beakerlib : Check the results] **************************************************************************************************************************
changed: [localhost]

TASK [standard-test-beakerlib : Set role result] ****************************************************************************************************************************
ok: [localhost]

TASK [include_role : str-common-final] **************************************************************************************************************************************

TASK [str-common-final : Pull out the logs from test environment to test runner] ********************************************************************************************
changed: [localhost]

TASK [str-common-final : Report role result] ********************************************************************************************************************************
ok: [localhost] => {
    "msg": [
        "Tests failed: False", 
        "Tests msg: ", 
        ""
    ]
}

PLAY RECAP **************************************************************************************************************************************
localhost                  : ok=33   changed=12   unreachable=0    failed=0   

The RH QE maintainer contact in case you have questions: rasibley@redhat.com

[0] https://fedoraproject.org/wiki/CI
[1] https://fedoraproject.org/wiki/Changes/InvokingTests

Pull-Request has been merged by vcrhonek

8 months ago