github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/pkg/pci/lookup_test.go (about)

     1  // Copyright 2012-2017 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package pci
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  func TestLookup(t *testing.T) {
    12  	for _, tt := range []struct {
    13  		name           string
    14  		pci            PCI
    15  		VendorNameWant string
    16  		DeviceNameWant string
    17  	}{
    18  		{
    19  			name: "Lookup Using ID 1055 Device e420",
    20  			pci: PCI{
    21  				Vendor: 0x1055,
    22  				Device: 0xe420,
    23  			},
    24  			VendorNameWant: "Efar Microsystems",
    25  			DeviceNameWant: "LAN9420/LAN9420i",
    26  		},
    27  		{
    28  			name: "Lookup Using ID 8086 Device 1237",
    29  			pci: PCI{
    30  				Vendor: 0x8086,
    31  				Device: 0x1237,
    32  			},
    33  			VendorNameWant: "Intel Corporation",
    34  			DeviceNameWant: "440FX - 82441FX PMC [Natoma]",
    35  		},
    36  		{
    37  			name: "Lookup Using ID 8086 Device 7000",
    38  			pci: PCI{
    39  				Vendor: 0x8086,
    40  				Device: 0x7000,
    41  			},
    42  			VendorNameWant: "Intel Corporation",
    43  			DeviceNameWant: "82371SB PIIX3 ISA [Natoma/Triton II]",
    44  		},
    45  		{
    46  			name: "Lookup Using ID 8086 Device 7111",
    47  			pci: PCI{
    48  				Vendor: 0x8086,
    49  				Device: 0x7111,
    50  			},
    51  			VendorNameWant: "Intel Corporation",
    52  			DeviceNameWant: "82371AB/EB/MB PIIX4 IDE",
    53  		},
    54  		{
    55  			name: "Lookup Using ID 80ee Device beef",
    56  			pci: PCI{
    57  				Vendor: 0x80ee,
    58  				Device: 0xbeef,
    59  			},
    60  			VendorNameWant: "InnoTek Systemberatung GmbH",
    61  			DeviceNameWant: "VirtualBox Graphics Adapter",
    62  		},
    63  		{
    64  			name: "Lookup Using ID 8086 Device 100e",
    65  			pci: PCI{
    66  				Vendor: 0x8086,
    67  				Device: 0x100e,
    68  			},
    69  			VendorNameWant: "Intel Corporation",
    70  			DeviceNameWant: "82540EM Gigabit Ethernet Controller",
    71  		},
    72  		{
    73  			name: "Lookup Using ID 80ee Device cafe",
    74  			pci: PCI{
    75  				Vendor: 0x80ee,
    76  				Device: 0xcafe,
    77  			},
    78  			VendorNameWant: "InnoTek Systemberatung GmbH",
    79  			DeviceNameWant: "VirtualBox Guest Service",
    80  		},
    81  		{
    82  			name: "Lookup Using ID 8086 Device 2415",
    83  			pci: PCI{
    84  				Vendor: 0x8086,
    85  				Device: 0x2415,
    86  			},
    87  			VendorNameWant: "Intel Corporation",
    88  			DeviceNameWant: "82801AA AC'97 Audio Controller",
    89  		},
    90  		{
    91  			name: "Lookup Using ID 8086 Device 7113",
    92  			pci: PCI{
    93  				Vendor: 0x8086,
    94  				Device: 0x7113,
    95  			},
    96  			VendorNameWant: "Intel Corporation",
    97  			DeviceNameWant: "82371AB/EB/MB PIIX4 ACPI",
    98  		},
    99  		{
   100  			name: "Lookup Using ID 8086 Device 100f",
   101  			pci: PCI{
   102  				Vendor: 0x8086,
   103  				Device: 0x100f,
   104  			},
   105  			VendorNameWant: "Intel Corporation",
   106  			DeviceNameWant: "82545EM Gigabit Ethernet Controller (Copper)",
   107  		},
   108  	} {
   109  		t.Run(tt.name, func(t *testing.T) {
   110  			tt.pci.SetVendorDeviceName()
   111  			VendorNameGot, DeviceNameGot := tt.pci.VendorName, tt.pci.DeviceName
   112  			if VendorNameGot != tt.VendorNameWant {
   113  				t.Errorf("Vendor mismatch, got: '%s', want: '%s'\n", VendorNameGot, tt.VendorNameWant)
   114  			}
   115  			if DeviceNameGot != tt.DeviceNameWant {
   116  				t.Errorf("Device mismatch, got: '%s', want: '%s'\n", DeviceNameGot, tt.DeviceNameWant)
   117  			}
   118  
   119  		})
   120  	}
   121  }