Project

General

Profile

Actions

Feature #14460

closed

pcieadm show-devs should warn on unused filters

Added by Robert Mustacchi 6 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

The other day, I ran pcieadm show-devs specifying something that wasn't there on the filter list, e.g. the following:

$ pfexec /usr/lib/pci/pcieadm show-devs igb pcib
BDF     TYPE           DRIVER         DEVICE
41/0/0  PCIe Gen 2x4   igb0           I350 Gigabit Network Connection
41/0/1  PCIe Gen 2x4   igb1           I350 Gigabit Network Connection
$ echo $?

This isn't very helpful behavior. Today this works by just seeing if we printed at least one item, but not if all filters were matched. Instead we should basically verify that all filters were actually used and use that as part of determining our exit status, the same way that we do in show-cfgspace. We would still retain the exit failure if there are no devices printed, but we also would warn on unused filters. The above instead becomes something like:

$ pfexec ./pcieadm show-devs igb pcib
BDF     TYPE           DRIVER         DEVICE
41/0/0  PCIe Gen 2x4   igb0           I350 Gigabit Network Connection
41/0/1  PCIe Gen 2x4   igb1           I350 Gigabit Network Connection
pcieadm: filter 'pcib' did not match any devices
$ echo $?
1

This was tested manually by using a number of different filters that both matched and didn't match and observing the exit values were as expected. For example:

$ pfexec ./pcieadm show-devs igb; echo $?
BDF     TYPE           DRIVER         DEVICE
41/0/0  PCIe Gen 2x4   igb0           I350 Gigabit Network Connection
41/0/1  PCIe Gen 2x4   igb1           I350 Gigabit Network Connection
0
$ pfexec ./pcieadm show-devs nvme0; echo $?
BDF     TYPE           DRIVER         DEVICE
1/0/0   PCIe Gen 3x4   nvme0          SSD 660P Series
0
rm@beowulf:/ws/rm/pcieadm/projects/illumos/usr/src/cmd/pcieadm$ pfexec ./pcieadm show-devs nvme01; echo $?
pcieadm: filter 'nvme01' did not match any devices
1
$ pfexec ./pcieadm show-devs nvme1; echo $?
pcieadm: filter 'nvme1' did not match any devices
1
$ pfexec ./pcieadm show-devs foo; echo $?
pcieadm: filter 'foo' did not match any devices
1
$ pfexec ./pcieadm show-devs foo igb0 blah; echo $?
BDF     TYPE           DRIVER         DEVICE
41/0/0  PCIe Gen 2x4   igb0           I350 Gigabit Network Connection
pcieadm: filter 'foo' did not match any devices
pcieadm: filter 'blah' did not match any devices
1

Finally, I also ran the pcieadm test suite as part of the util tests:

rm@beowulf:~$ pfexec /opt/util-tests/bin/utiltest
Test: /opt/util-tests/tests/allowed-ips (run as root)             [00:00] [PASS]
Test: /opt/util-tests/tests/ar/artest (run as root)               [00:00] [PASS]
Test: /opt/util-tests/tests/chown_test (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/date_test (run as root)               [00:00] [PASS]
Test: /opt/util-tests/tests/find/findtest (run as root)           [00:00] [PASS]
Test: /opt/util-tests/tests/grep_test (run as root)               [00:02] [PASS]
Test: /opt/util-tests/tests/head/head_test (run as root)          [00:00] [PASS]
Test: /opt/util-tests/tests/libjedec_test (run as root)           [00:00] [PASS]
Test: /opt/util-tests/tests/libsff/libsff (run as root)           [00:00] [PASS]
Test: /opt/util-tests/tests/make_test (run as root)               [00:00] [PASS]
Test: /opt/util-tests/tests/mdb/mdbtest (run as root)             [00:01] [PASS]
Test: /opt/util-tests/tests/mergeq/mqt (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/mergeq/wqt (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/pcidbtest (run as root)               [00:01] [PASS]
Test: /opt/util-tests/tests/pcieadm-priv (run as root)            [00:01] [PASS]
Test: /opt/util-tests/tests/pcieadmtest (run as root)             [00:03] [PASS]
Test: /opt/util-tests/tests/printf_test (run as root)             [00:00] [PASS]
Test: /opt/util-tests/tests/set-linkprop (run as root)            [00:00] [PASS]
Test: /opt/util-tests/tests/sleep/sleeptest (run as root)         [00:18] [PASS]
Test: /opt/util-tests/tests/smbios (run as root)                  [00:00] [PASS]
Test: /opt/util-tests/tests/svr4pkg_test (run as root)            [00:00] [PASS]
Test: /opt/util-tests/tests/xargs_test (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/awk/runtests.sh (run as nobody)       [02:51] [PASS]
Test: /opt/util-tests/tests/ctf/precheck (run as root)            [00:00] [PASS]
Test: /opt/util-tests/tests/ctf/ctftest (run as root)             [00:05] [PASS]
Test: /opt/util-tests/tests/demangle/afl-fast (run as root)       [00:01] [PASS]
Test: /opt/util-tests/tests/demangle/gcc-libstdc++ (run as root)  [00:00] [PASS]
Test: /opt/util-tests/tests/demangle/llvm-stdcxxabi (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libcustr/custr_remove (run as root)   [00:00] [PASS]
Test: /opt/util-tests/tests/libcustr/custr_trunc (run as root)    [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_00_blank (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_01_boolean (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_02_numbers (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_03_empty_arrays (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_04_number_arrays (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_05_strings (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_06_nested (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_07_nested_arrays (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/sed/sed_addr (run as root)            [00:00] [PASS]
Test: /opt/util-tests/tests/sed/multi_test (run as root)          [00:00] [PASS]

Results Summary
PASS      40

Running Time:   00:03:32
Percent passed: 100.0%
Log directory:  /var/tmp/test_results/20220129T191306
Actions #1

Updated by Electric Monk 6 months ago

  • Gerrit CR set to 1989
Actions #2

Updated by Electric Monk 6 months ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit 92f11af9ee66cf1fac02dc46553e805de69f204c

commit  92f11af9ee66cf1fac02dc46553e805de69f204c
Author: Robert Mustacchi <rm@fingolfin.org>
Date:   2022-02-08T15:12:38.000Z

    14460 pcieadm show-devs should warn on unused filters
    14459 pcieadm show-cfgspace sometimes confuses hex and strings
    14461 pcieadm-priv tests fail in the face of duplicate /devices paths
    Reviewed by: Gordon Ross <Gordon.W.Ross@gmail.com>
    Reviewed by: Andy Fiddaman <andy@omnios.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF