You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
34 lines
1.0 KiB
|
2 months ago
|
package serial
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"path/filepath"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestDeployedFET3568JCMappingMatchesCanonicalPortOrder(t *testing.T) {
|
||
|
|
mappingPath := filepath.Join("..", "..", "deploy", "etc", "tera", "serial-map.json")
|
||
|
|
controller, err := LoadMappingController(mappingPath, "fet3568j-c")
|
||
|
|
if err != nil {
|
||
|
|
t.Fatalf("load deployed mapping: %v", err)
|
||
|
|
}
|
||
|
|
if controller.mapping.MappingVersion != "fet3568j-c-20260721-v1" {
|
||
|
|
t.Fatalf("mapping version = %q", controller.mapping.MappingVersion)
|
||
|
|
}
|
||
|
|
|
||
|
|
for index, item := range controller.ordered {
|
||
|
|
channelNumber := index + 1
|
||
|
|
ttyNumber := channelNumber + 3
|
||
|
|
expectedBDF := "0000:01:00.0"
|
||
|
|
if channelNumber > 24 {
|
||
|
|
ttyNumber = channelNumber + 7
|
||
|
|
expectedBDF = "0002:21:00.0"
|
||
|
|
}
|
||
|
|
expectedChannel := fmt.Sprintf("CH%02d", channelNumber)
|
||
|
|
expectedDevice := fmt.Sprintf("/dev/ttyWCH%d", ttyNumber)
|
||
|
|
if item.Channel != expectedChannel || item.Device != expectedDevice || item.PCIBDF != expectedBDF {
|
||
|
|
t.Fatalf("mapping[%d] = %#v, want %s %s %s", index, item, expectedChannel, expectedDevice, expectedBDF)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|