Merge pull request #18 from carmark/more_tests
add more libiscsi test cases
This commit is contained in:
11
.travis.yml
11
.travis.yml
@@ -22,6 +22,8 @@ script:
|
||||
- ./configure
|
||||
- make
|
||||
- hack/verify-gofmt.sh
|
||||
- export GOPATH=`pwd`/Godeps/_workspace/:$GOPATH
|
||||
- go test -v ./pkg/...
|
||||
- dd if=/dev/zero of=/var/tmp/disk.img bs=1024 count=10240
|
||||
- mkdir ${HOME}/.gotgt
|
||||
- echo '{"storages":[{"deviceID":1000,"path":"file:/var/tmp/disk.img","online":true}],"targets":{"iqn.2016-09.com.gotgt.gostor:example_tgt_0":{"portals":["127.0.0.1"],"luns":{"0":1000}}}}' > ${HOME}/.gotgt/config.json
|
||||
@@ -34,8 +36,13 @@ script:
|
||||
- ./autogen.sh
|
||||
- ./configure
|
||||
- make
|
||||
- ./test-tool/iscsi-test-cu -d --test=SCSI.Read10.Simple iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
- ./test-tool/iscsi-test-cu -d --test=SCSI.Write10.Simple iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.TestUnitReady iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.ReadCapacity10 iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.ReadCapacity16 iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.Read10.Simple iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.Write10.Simple iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.Read16.Simple iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
- ./test-tool/iscsi-test-cu -d -f --test=SCSI.Write16.Simple iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
- ./utils/iscsi-ls -s iscsi://127.0.0.1:3260/${TARGET}
|
||||
- ./utils/iscsi-inq iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
- ./utils/iscsi-readcapacity16 iscsi://127.0.0.1:3260/${TARGET}/0
|
||||
|
||||
@@ -250,12 +250,6 @@ func (s *Server) newServer(proto, addr string) ([]*HTTPServer, error) {
|
||||
return nil, err
|
||||
}
|
||||
ls = append(ls, l)
|
||||
case "unix":
|
||||
l, err := sockets.NewUnixSocket(addr, s.cfg.SocketGroup)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't create unix socket %s: %v", addr, err)
|
||||
}
|
||||
ls = append(ls, l)
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid protocol format: %q", proto)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2015 The GoStor Authors All rights reserved.
|
||||
Copyright 2016 The GoStor Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -21,23 +21,25 @@ import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"testing"
|
||||
|
||||
"github.com/gostor/gotgt/pkg/api"
|
||||
)
|
||||
|
||||
// Test SPCReportLuns function
|
||||
func TestSPCReportLuns(t *testing.T) {
|
||||
// make a fake REPORT_LUNS command
|
||||
cmd := new(SCSICommand)
|
||||
device := new(SCSILu)
|
||||
cmd := new(api.SCSICommand)
|
||||
device := new(api.SCSILu)
|
||||
cmd.Device = device
|
||||
lu := new(SCSILu)
|
||||
target := new(SCSITarget)
|
||||
target.Devices = append(target.Devices, *lu)
|
||||
lu := new(api.SCSILu)
|
||||
target := new(api.SCSITarget)
|
||||
target.Devices = map[uint64]*api.SCSILu{lu.Lun: lu}
|
||||
cmd.Target = target
|
||||
cmd.SCB = &bytes.Buffer{}
|
||||
cmd.SenseBuffer = &bytes.Buffer{}
|
||||
cmd.InSDBBuffer.Length = 16
|
||||
cmd.InSDBBuffer.Buffer = &bytes.Buffer{}
|
||||
cmd.SCB.WriteByte(byte(REPORT_LUNS))
|
||||
cmd.SCB.WriteByte(byte(api.REPORT_LUNS))
|
||||
for i := 0; i < 5; i++ {
|
||||
cmd.SCB.WriteByte(0x00)
|
||||
}
|
||||
@@ -47,13 +49,8 @@ func TestSPCReportLuns(t *testing.T) {
|
||||
t.Errorf("Expected not error, but got %v", err)
|
||||
}
|
||||
|
||||
cmd.InSDBBuffer.Length = 10
|
||||
if err := SPCReportLuns(0, cmd); err.Err == nil {
|
||||
t.Error("Expected error, but got nothing")
|
||||
}
|
||||
|
||||
cmd.SCB = &bytes.Buffer{}
|
||||
cmd.SCB.WriteByte(byte(REPORT_LUNS))
|
||||
cmd.SCB.WriteByte(byte(api.REPORT_LUNS))
|
||||
for i := 0; i < 5; i++ {
|
||||
cmd.SCB.WriteByte(0x00)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user