-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #259 from bobrik/ivan/pci-lint-fix
Fix new linter issues in pci decoders
- Loading branch information
Showing
9 changed files
with
76 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package decoder | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/cloudflare/ebpf_exporter/v2/config" | ||
) | ||
|
||
func testPCIMissing(t *testing.T, d Decoder, cases [][]byte) { | ||
if pci != nil { | ||
t.Skip("PCI DB is available") | ||
} | ||
|
||
for _, c := range cases { | ||
out, err := d.Decode(c, config.Decoder{}) | ||
if err != nil { | ||
t.Errorf("Error decoding %#v: %v", c, err) | ||
} | ||
|
||
if !bytes.Equal(out, []byte(missingPciIdsText)) { | ||
t.Errorf("Expected %q, got %s", missingPciIdsText, out) | ||
} | ||
} | ||
} | ||
|
||
type pciCase struct { | ||
in []byte | ||
out []byte | ||
} | ||
|
||
func testPCIPresent(t *testing.T, d Decoder, cases []pciCase) { | ||
if pci == nil { | ||
t.Skip("PCI DB is not available") | ||
} | ||
|
||
for _, c := range cases { | ||
out, err := d.Decode(c.in, config.Decoder{}) | ||
if err != nil { | ||
t.Errorf("Error decoding %#v: %v", c.in, err) | ||
} | ||
|
||
if !bytes.Equal(out, c.out) { | ||
t.Errorf("Expected %q, got %q", c.out, out) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.