From 8b135f112565de23a5153d9564f6c7377e3bc6e1 Mon Sep 17 00:00:00 2001 From: Lei Xue Date: Thu, 6 Oct 2016 20:01:35 +0800 Subject: [PATCH] add more libiscsi test cases --- .travis.yml | 11 +++++++++-- pkg/apiserver/apiserver.go | 6 ------ pkg/scsi/spc_test.go | 23 ++++++++++------------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a42b39..e4195a6 100644 --- a/.travis.yml +++ b/.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 diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index d4e2619..d758246 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -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) } diff --git a/pkg/scsi/spc_test.go b/pkg/scsi/spc_test.go index 6ef6095..8e5adae 100644 --- a/pkg/scsi/spc_test.go +++ b/pkg/scsi/spc_test.go @@ -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) }