From 66a213261486a81f37517d6c81a6bd62a8188ce0 Mon Sep 17 00:00:00 2001 From: Vitezslav Crhonek Date: Wed, 7 Jun 2023 11:27:41 +0200 Subject: [PATCH] Initial packit configuration Signed-off-by: Vitezslav Crhonek --- .fmf/version | 1 + .packit.yaml | 23 ++++++++ plans/basic.fmf | 9 +++ plans/rpmlint.fmf | 14 +++++ tests/ids-files/Makefile | 65 +++++++++++++++++++++ tests/ids-files/PURPOSE | 6 ++ tests/ids-files/main.fmf | 17 ++++++ tests/ids-files/runtest.sh | 71 +++++++++++++++++++++++ tests/python-hwdata/main.fmf | 2 + tests/python-hwdata/test-python-hwdata.sh | 3 + tests/syntax/Makefile | 68 ++++++++++++++++++++++ tests/syntax/PURPOSE | 6 ++ tests/syntax/main.fmf | 20 +++++++ tests/syntax/runtest.sh | 54 +++++++++++++++++ 14 files changed, 359 insertions(+) create mode 100644 .fmf/version create mode 100644 .packit.yaml create mode 100644 plans/basic.fmf create mode 100644 plans/rpmlint.fmf create mode 100644 tests/ids-files/Makefile create mode 100644 tests/ids-files/PURPOSE create mode 100644 tests/ids-files/main.fmf create mode 100755 tests/ids-files/runtest.sh create mode 100644 tests/python-hwdata/main.fmf create mode 100755 tests/python-hwdata/test-python-hwdata.sh create mode 100644 tests/syntax/Makefile create mode 100644 tests/syntax/PURPOSE create mode 100644 tests/syntax/main.fmf create mode 100755 tests/syntax/runtest.sh diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.packit.yaml b/.packit.yaml new file mode 100644 index 0000000..f7838b5 --- /dev/null +++ b/.packit.yaml @@ -0,0 +1,23 @@ +# See the documentation for more information: +# https://packit.dev/docs/configuration/ + +specfile_path: hwdata.spec + +# name in upstream package repository or registry (e.g. in PyPI) +upstream_package_name: hwdata +upstream_project_url: https://github.com/vcrhonek/hwdata +upstream_tag_template: v{version} +# downstream (Fedora) RPM package name +downstream_package_name: hwdata +#issue_repository: https://src.fedoraproject.org/rpms/hwdata + +jobs: +- job: copr_build + trigger: pull_request + targets: [fedora-all] + owner: vcrhonek + project: hwdata-packit + +- job: tests + trigger: pull_request + targets: [fedora-all] diff --git a/plans/basic.fmf b/plans/basic.fmf new file mode 100644 index 0000000..cd04766 --- /dev/null +++ b/plans/basic.fmf @@ -0,0 +1,9 @@ +summary: + Basic checks +discover: + how: fmf +prepare: + how: shell + script: dnf -y update && dnf -y install usbutils && dnf -y install python3-hwdata --setopt='tsflags=' && dnf clean all +execute: + how: tmt diff --git a/plans/rpmlint.fmf b/plans/rpmlint.fmf new file mode 100644 index 0000000..2b5717e --- /dev/null +++ b/plans/rpmlint.fmf @@ -0,0 +1,14 @@ +summary: + Execute rpmlint on the spec file +discover: + how: shell + tests: + - name: rpmlint + test: rpmlint hwdata.spec +prepare: + - name: packages + how: install + package: + - rpmlint +execute: + how: tmt diff --git a/tests/ids-files/Makefile b/tests/ids-files/Makefile new file mode 100644 index 0000000..8779c9c --- /dev/null +++ b/tests/ids-files/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /kernel/hwdata/Sanity/ids-files +# Description: compares upstream ID files with our ID files +# Author: Milos Malik +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 " > $(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) + diff --git a/tests/ids-files/PURPOSE b/tests/ids-files/PURPOSE new file mode 100644 index 0000000..4a39624 --- /dev/null +++ b/tests/ids-files/PURPOSE @@ -0,0 +1,6 @@ +PURPOSE of /kernel/hwdata/Sanity/ids-files + +Description: compares upstream ID files with our ID files + +Author: Milos Malik + diff --git a/tests/ids-files/main.fmf b/tests/ids-files/main.fmf new file mode 100644 index 0000000..d44e316 --- /dev/null +++ b/tests/ids-files/main.fmf @@ -0,0 +1,17 @@ +summary: compares upstream ID files with our ID files +description: |+ + Description: compares upstream ID files with our ID files + + Author: Milos Malik + +contact: Milos Malik +component: + - hwdata +test: ./runtest.sh +framework: beakerlib +recommend: + - hwdata + - wget +duration: 5m +extra-summary: /kernel/hwdata/Sanity/ids-files +extra-task: /kernel/hwdata/Sanity/ids-files diff --git a/tests/ids-files/runtest.sh b/tests/ids-files/runtest.sh new file mode 100755 index 0000000..8501630 --- /dev/null +++ b/tests/ids-files/runtest.sh @@ -0,0 +1,71 @@ +#!/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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="hwdata" +HWDATA_DIR="/usr/share/hwdata" +PCI_IDS_FILE="pci.ids" +PCI_IDS_URL="https://raw.githubusercontent.com/pciutils/pciids/master/pci.ids" +USB_IDS_FILE="usb.ids" +USB_IDS_URL="http://www.linux-usb.org/usb.ids" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm ${PACKAGE} + rlAssertRpm wget + rlAssertExists ${HWDATA_DIR}/${PCI_IDS_FILE} + rlAssertExists ${HWDATA_DIR}/${USB_IDS_FILE} + 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` + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "rm -f ${PCI_IDS_FILE}" + rlRun "rm -f ${USB_IDS_FILE}" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd + diff --git a/tests/python-hwdata/main.fmf b/tests/python-hwdata/main.fmf new file mode 100644 index 0000000..515241e --- /dev/null +++ b/tests/python-hwdata/main.fmf @@ -0,0 +1,2 @@ +summary: Test using python-hwdata +test: ./test-python-hwdata.sh diff --git a/tests/python-hwdata/test-python-hwdata.sh b/tests/python-hwdata/test-python-hwdata.sh new file mode 100755 index 0000000..b442a93 --- /dev/null +++ b/tests/python-hwdata/test-python-hwdata.sh @@ -0,0 +1,3 @@ +#!/bin/sh -eux + +python3 /usr/share/doc/python3-hwdata/example.py diff --git a/tests/syntax/Makefile b/tests/syntax/Makefile new file mode 100644 index 0000000..a949ef3 --- /dev/null +++ b/tests/syntax/Makefile @@ -0,0 +1,68 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /kernel/hwdata/idfiles/syntax +# Description: checks for basic syntax errors +# Author: Milos Malik +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 " > $(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) + diff --git a/tests/syntax/PURPOSE b/tests/syntax/PURPOSE new file mode 100644 index 0000000..dc2a4b1 --- /dev/null +++ b/tests/syntax/PURPOSE @@ -0,0 +1,6 @@ +PURPOSE of /kernel/hwdata/idfiles/syntax + +Description: checks for basic syntax errors + +Author: Milos Malik + diff --git a/tests/syntax/main.fmf b/tests/syntax/main.fmf new file mode 100644 index 0000000..076240f --- /dev/null +++ b/tests/syntax/main.fmf @@ -0,0 +1,20 @@ +summary: checks for basic syntax errors +description: |+ + Description: checks for basic syntax errors + + Author: Milos Malik + +contact: Milos Malik +component: + - hwdata +test: ./runtest.sh +framework: beakerlib +recommend: + - hwdata + - pciutils + - usbutils + - grep + - mktemp +duration: 5m +extra-summary: /kernel/hwdata/idfiles/syntax +extra-task: /kernel/hwdata/idfiles/syntax diff --git a/tests/syntax/runtest.sh b/tests/syntax/runtest.sh new file mode 100755 index 0000000..a9394e7 --- /dev/null +++ b/tests/syntax/runtest.sh @@ -0,0 +1,54 @@ +#!/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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/share/beakerlib/beakerlib.sh || exit 1 + +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 +