-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguestfs_100_launch_test.go
executable file
·115 lines (101 loc) · 2.37 KB
/
guestfs_100_launch_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// +build appliance
/* libguestfs Go tests
* Copyright (C) 2013 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package guestfs
import (
"testing"
// "sort"
)
func Test100Launch (t *testing.T) {
g, errno := Create ()
if errno != nil {
t.Errorf ("could not create handle: %s", errno)
}
defer g.Close ()
err := g.Add_drive_scratch (500 * 1024 * 1024, nil);
if err != nil {
t.Errorf ("%s", err)
}
err = g.Launch ()
if err != nil {
t.Errorf ("%s", err)
}
err = g.Pvcreate ("/dev/sda")
if err != nil {
t.Errorf ("%s", err)
}
err = g.Vgcreate ("VG", []string{"/dev/sda"})
if err != nil {
t.Errorf ("%s", err)
}
err = g.Lvcreate ("LV1", "VG", 200)
if err != nil {
t.Errorf ("%s", err)
}
err = g.Lvcreate ("LV2", "VG", 200)
if err != nil {
t.Errorf ("%s", err)
}
lvs, err := g.Lvs ()
if err != nil {
t.Errorf ("%s", err)
}
expected := []string{"/dev/VG/LV1", "/dev/VG/LV2"}
if !equal (lvs, expected) {
t.Errorf ("g.Lvs: %s != %s", lvs, expected)
}
err = g.Mkfs ("ext2", "/dev/VG/LV1", nil)
if err != nil {
t.Errorf ("%s", err)
}
err = g.Mount ("/dev/VG/LV1", "/")
if err != nil {
t.Errorf ("%s", err)
}
err = g.Mkdir ("/p")
if err != nil {
t.Errorf ("%s", err)
}
err = g.Touch ("/q")
if err != nil {
t.Errorf ("%s", err)
}
_ /*dirs*/, err = g.Readdir ("/")
if err != nil {
t.Errorf ("%s", err)
}
//sort.Sort (byName (dirs))
// XXX Sort interface is needlessly complicated
err = g.Shutdown ()
if err != nil {
t.Errorf ("%s", err)
}
}
/* - declared in guestfs_900_rstringlist_test.go
func equal (xs []string, ys []string) bool {
if len(xs) != len(ys) {
return false
}
for i, x := range xs {
if x != ys[i] {
return false
}
}
return true
}
*/