From 6dce38a7d3f755cfa88207007c0cb199c4c8a2e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:23:58 +0200 Subject: Adding debian version 0.0~2023.04.11-1. Signed-off-by: Daniel Baumann --- debian/tests/control | 1 + debian/tests/test-db-format | 83 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 debian/tests/control create mode 100755 debian/tests/test-db-format (limited to 'debian/tests') diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..2ee676f --- /dev/null +++ b/debian/tests/control @@ -0,0 +1 @@ +Tests: test-db-format diff --git a/debian/tests/test-db-format b/debian/tests/test-db-format new file mode 100755 index 0000000..70b89e0 --- /dev/null +++ b/debian/tests/test-db-format @@ -0,0 +1,83 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my ($SELF) = $0 =~ m{(?:.*/)?([^/]*)}; +my $DEBUG = defined $ENV{PCI_IDS_DEBUG}; +my $PCIIDS = $ARGV[0] // '/usr/share/misc/pci.ids'; + +sub error +{ + my (@args) = @_; + + die "$SELF: @args: FAIL\n"; +} + +sub debug +{ + my (@args) = @_; + + print "@args\n" if $DEBUG; +} + +sub check +{ + my $fh = shift; + + my ($vendor, $device); + my ($class, $subclass); + + while (<$fh>) { + next if m/^#/; + next if m/^\s*$/; + + s/#.*$//; + + if (m/^([0-9a-fA-F]{4}) (.*)$/) { + debug("Vendor ($1) ($2)"); + $vendor = $1; + $device = undef; + $class = undef; + $subclass = undef; + } elsif (m/^\t([0-9a-fA-F]{4}) (.*)$/) { + if (not defined $vendor) { + error("Device defined not within a Vendor at line $."); + } + debug("Device ($1) ($2)"); + $device = $1; + } elsif (m/^\t\t([0-9a-fA-F]{4}) ([0-9a-fA-F]{4}) (.*)$/) { + if (not defined $device) { + error("SubDevice defined not within a Device at line $."); + } + debug("SubVendor SubDevice ($1 $2) ($2)"); + } elsif (m/^C ([0-9a-fA-F]{2}) (.*)$/) { + debug("Class ($1) ($2)"); + $vendor = undef; + $device = undef; + $class = $1; + $subclass = undef; + } elsif (m/^\t([0-9a-fA-F]{2}) (.*)$/) { + if (not defined $class) { + error("SubClass defined not within a Class at line $."); + } + debug("SubClass ($1) ($2)"); + $subclass = $1; + } elsif (m/^\t\t([0-9a-fA-F]{2}) (.*)$/) { + if (not defined $subclass) { + error("Programming Interface defined not within a SubClass at line $."); + } + debug("ProgIface ($1) ($2)"); + } else { + error("Unknown entry in file at line $."); + } + } +} + +open my $fh, '<', $PCIIDS or error("cannot open $PCIIDS database: $!"); +check($fh); +close $fh; + +print "$SELF: format of $PCIIDS is ok: PASS\n"; + +exit 0; -- cgit v1.2.3