-
Notifications
You must be signed in to change notification settings - Fork 7
/
initiator_test.go
60 lines (49 loc) · 1.26 KB
/
initiator_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2019 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package iscsinl
/*import (
"fmt"
"log"
"os"
"testing"
"github.com/u-root/u-root/pkg/mount"
"github.com/u-root/u-root/pkg/sh"
"github.com/u-root/u-root/pkg/testutil"
)
func TestMain(m *testing.M) {
if os.Getuid() == 0 {
if err := sh.RunWithLogs("dhclient", "-ipv6=false"); err != nil {
log.Fatalf("could not configure network for tests: %v", err)
}
}
os.Exit(m.Run())
}
func TestMountIscsi(t *testing.T) {
testutil.SkipIfNotRoot(t)
devices, err := MountIscsi(
WithInitiator(os.Getenv("INITIATOR_NAME")),
WithTarget(fmt.Sprintf("%s:%s", os.Getenv("TGT_SERVER"), os.Getenv("TGT_PORT")), os.Getenv("TGT_VOLUME")),
WithDigests("None"),
)
if err != nil {
log.Println(err)
t.Error(err)
}
for _, device := range devices {
// Make the mountpoint, and mount it.
if err := os.MkdirAll("/mp", 0755); err != nil {
t.Fatal(err)
}
mp, err := mount.TryMount(fmt.Sprintf("/dev/%s1", device), "/mp", 0)
if err != nil {
t.Fatal(err)
}
if err := sh.RunWithLogs("ls", "-l", "/mp"); err != nil {
t.Error(err)
}
if err := mp.Unmount(0); err != nil {
t.Error(err)
}
}
}*/