| 1 |
#!/bin/bash |
| 2 |
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k |
| 3 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 4 |
# |
| 5 |
# runtest.sh of /kernel/hwdata/Sanity/ids-files |
| 6 |
# Description: compares upstream ID files with our ID files |
| 7 |
# Author: Milos Malik <[email protected]> |
| 8 |
# |
| 9 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 |
# |
| 11 |
# Copyright (c) 2009 Red Hat, Inc. All rights reserved. |
| 12 |
# |
| 13 |
# This copyrighted material is made available to anyone wishing |
| 14 |
# to use, modify, copy, or redistribute it subject to the terms |
| 15 |
# and conditions of the GNU General Public License version 2. |
| 16 |
# |
| 17 |
# This program is distributed in the hope that it will be |
| 18 |
# useful, but WITHOUT ANY WARRANTY; without even the implied |
| 19 |
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 |
# PURPOSE. See the GNU General Public License for more details. |
| 21 |
# |
| 22 |
# You should have received a copy of the GNU General Public |
| 23 |
# License along with this program; if not, write to the Free |
| 24 |
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 25 |
# Boston, MA 02110-1301, USA. |
| 26 |
# |
| 27 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 28 |
|
| 29 |
# Include rhts environment |
| 30 |
. /usr/share/beakerlib/beakerlib.sh || exit 1 |
| 31 |
|
| 32 |
PACKAGE="hwdata" |
| 33 |
HWDATA_DIR="/usr/share/hwdata" |
| 34 |
PCI_IDS_FILE="pci.ids" |
| 35 |
PCI_IDS_URL="https://raw.githubusercontent.com/pciutils/pciids/master/pci.ids" |
| 36 |
USB_IDS_FILE="usb.ids" |
| 37 |
USB_IDS_URL="http://www.linux-usb.org/usb.ids" |
| 38 |
|
| 39 |
rlJournalStart |
| 40 |
rlPhaseStartSetup |
| 41 |
rlAssertRpm ${PACKAGE} |
| 42 |
rlIsFedora ">39" && rlAssertRpm wget2 || rlAssertRpm wget |
| 43 |
rlAssertExists ${HWDATA_DIR}/${PCI_IDS_FILE} |
| 44 |
rlAssertExists ${HWDATA_DIR}/${USB_IDS_FILE} |
| 45 |
rlPhaseEnd |
| 46 |
|
| 47 |
rlPhaseStartTest |
| 48 |
rlRun "wget -q -t 4 ${PCI_IDS_URL}" |
| 49 |
rlAssertExists ${PCI_IDS_FILE} |
| 50 |
echo "Lines in upstream file: "`wc -l < ${PCI_IDS_FILE}` |
| 51 |
echo "Lines in our file: "`wc -l < ${HWDATA_DIR}/${PCI_IDS_FILE}` |
| 52 |
echo "Common lines: "`comm -1 -2 ${PCI_IDS_FILE} ${HWDATA_DIR}/${PCI_IDS_FILE} | wc -l` |
| 53 |
echo "Different lines in upstream file: "`comm -2 -3 ${PCI_IDS_FILE} ${HWDATA_DIR}/${PCI_IDS_FILE} | wc -l` |
| 54 |
echo "Different lines in our file: "`comm -1 -3 ${PCI_IDS_FILE} ${HWDATA_DIR}/${PCI_IDS_FILE} | wc -l` |
| 55 |
|
| 56 |
rlRun "wget -q -t 4 ${USB_IDS_URL}" |
| 57 |
rlAssertExists ${USB_IDS_FILE} |
| 58 |
echo "Lines in upstream file: "`wc -l < ${USB_IDS_FILE}` |
| 59 |
echo "Lines in our file: "`wc -l < ${HWDATA_DIR}/${USB_IDS_FILE}` |
| 60 |
echo "Common lines: "`comm -1 -2 ${USB_IDS_FILE} ${HWDATA_DIR}/${USB_IDS_FILE} | wc -l` |
| 61 |
echo "Different lines in upstream file: "`comm -2 -3 ${USB_IDS_FILE} ${HWDATA_DIR}/${USB_IDS_FILE} | wc -l` |
| 62 |
echo "Different lines in our file: "`comm -1 -3 ${USB_IDS_FILE} ${HWDATA_DIR}/${USB_IDS_FILE} | wc -l` |
| 63 |
rlPhaseEnd |
| 64 |
|
| 65 |
rlPhaseStartCleanup |
| 66 |
rlRun "rm -f ${PCI_IDS_FILE}" |
| 67 |
rlRun "rm -f ${USB_IDS_FILE}" |
| 68 |
rlPhaseEnd |
| 69 |
rlJournalPrintText |
| 70 |
rlJournalEnd |
| 71 |
|