Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

Commit 6f31f9e

Browse files
authored
Merge pull request #277 from mdlayher/aoe-ata-test
block/aoe: test ATA identify request
2 parents 07bccae + 7e52e6f commit 6f31f9e

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

block/aoe/aoe_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,41 @@ const (
3030
testMTU = 9000
3131
)
3232

33+
func TestServeCommandIssueATACommand(t *testing.T) {
34+
// Request that the server identify its ATA device
35+
req := &aoe.Header{
36+
Version: aoe.Version,
37+
Major: 1,
38+
Minor: 1,
39+
Command: aoe.CommandIssueATACommand,
40+
Tag: [4]byte{0xde, 0xad, 0xbe, 0xef},
41+
Arg: &aoe.ATAArg{
42+
// Must be 1 for identify request
43+
SectorCount: 1,
44+
CmdStatus: aoe.ATACmdStatusIdentify,
45+
},
46+
}
47+
48+
res := testRequest(t, req)
49+
arg, ok := res.Arg.(*aoe.ATAArg)
50+
if !ok {
51+
t.Fatalf("incorrect argument type for configuration request: %T", res.Arg)
52+
}
53+
54+
if want, got := *req, *res; !headersEqual(got, want) {
55+
t.Fatalf("unexpected AoE header:\n - want: %+v\n- got: %+v", want, got)
56+
}
57+
58+
// TODO(mdlayher): do deeper inspection of returned ATA identification data
59+
if want, got := aoe.ATACmdStatusReadyStatus, arg.CmdStatus; want != got {
60+
t.Fatalf("unexpected ATA CmdStatus:\n - want: %v\n- got: %v", want, got)
61+
}
62+
// Expect 512 bytes (1 sector) of data
63+
if want, got := 512, len(arg.Data); want != got {
64+
t.Fatalf("unexpected ATA data length:\n - want: %v\n- got: %v", want, got)
65+
}
66+
}
67+
3368
func TestServeCommandQueryConfigInformation(t *testing.T) {
3469
// Request that the server send its current configuration
3570
req := &aoe.Header{

0 commit comments

Comments
 (0)