Files
RASCSI/go/piscsi-ctrlboard/menu_builder_test.go
Daniel Markstedt 485298ffe5 restore X68000 Host Bridge support
Restore the SCBR device as an X68000 Host Bridge, including the Human68k-compatible host file-system service and the bridge-specific SCSI message handlers. Back its Ethernet path with the TAP driver, derive a stable locally administered MAC address, preserve the driver minimum-frame/FCS expectations, and restrict received traffic to its own unicast frames and broadcasts.

Match the RASCTL/RASETHER/RASDRV bridge protocol that originated in the parent RaSCSI project: dispatch its non-standard message format on READ(10)/WRITE(10) (0x28/0x2a), with type, function, phase, and a three-byte byte count carried in the CDB. Advertise the legacy control channel required by RASCTL, translate its list and device-management commands to PiSCSI operations, and defer stop or system-shutdown requests until after the response is sent, while gating this insecure interface behind a new '-c disabled|media|full' runtime option. Preserve the type-1 Ethernet exchange used by RASETHER and the type-2, phased filesystem exchange used by RASDRV.

Register the device in the factory, protobuf API, controller transfer path, command-line tooling, device listings, and web UI. Share the explicit bridge and proxy-ARP topology workflow with DaynaPort so both adapters validate and use the same mode/interface pair.

Add build support for iconv where needed, extend unit coverage for device creation, RAS* protocol handling, CLI parsing, web attachment, and topology selection, and update the man pages and network-profile documentation for Host Bridge operation and its networking limits.
2026-09-01 00:52:00 +02:00

47 lines
1.5 KiB
Go

package ctrlboard
import (
"context"
"testing"
pb "github.com/piscsi/piscsi/go/proto"
)
type menuClient struct {
result *pb.PbResult
err error
}
func (c menuClient) SendCommand(*pb.PbCommand) (*pb.PbResult, error) { return c.result, c.err }
func TestSCSIMenuBuilderLabelsReservedAndAttachedSlots(t *testing.T) {
builder := NewSCSIMenuBuilder(menuClient{result: &pb.PbResult{Status: true, Result: &pb.PbResult_ServerInfo{ServerInfo: &pb.PbServerInfo{
ReservedIdsInfo: &pb.PbReservedIdsInfo{Ids: []int32{1}},
DevicesInfo: &pb.PbDevicesInfo{Devices: []*pb.PbDevice{{Id: 2, Unit: 0, Type: pb.PbDeviceType_SCHD, File: &pb.PbImageFile{Name: "/images/System.hds"}}}},
}}}}, "")
items, err := builder.Build(context.Background())
if err != nil {
t.Fatal(err)
}
if got, want := items[1].Label, "1: [Reserved]"; got != want {
t.Fatalf("slot 1 = %q, want %q", got, want)
}
if got, want := items[2].Label, "2: System.hds [SCHD]"; got != want {
t.Fatalf("slot 2 = %q, want %q", got, want)
}
if got, want := items[3].Label, "3: (empty)"; got != want {
t.Fatalf("slot 3 = %q, want %q", got, want)
}
}
func TestSlotLabelRecognizesBothNetworkAdapters(t *testing.T) {
for deviceType, want := range map[pb.PbDeviceType]string{
pb.PbDeviceType_SCBR: "2: Host Bridge",
pb.PbDeviceType_SCDP: "2: Daynaport",
} {
if got := slotLabel(SCSISlot{ID: 2, Device: &pb.PbDevice{Type: deviceType}}, 1); got != want {
t.Fatalf("slot label for %s = %q, want %q", deviceType, got, want)
}
}
}