@@ -105,7 +105,7 @@ func TestAttachVFIODevice(t *testing.T) {
105
105
}
106
106
tmpDir , err := ioutil .TempDir ("" , "" )
107
107
assert .Nil (t , err )
108
- os .RemoveAll (tmpDir )
108
+ defer os .RemoveAll (tmpDir )
109
109
110
110
testFDIOGroup := "2"
111
111
testDeviceBDFPath := "0000:00:1c.0"
@@ -114,15 +114,27 @@ func TestAttachVFIODevice(t *testing.T) {
114
114
err = os .MkdirAll (devicesDir , dirMode )
115
115
assert .Nil (t , err )
116
116
117
- deviceFile := filepath .Join (devicesDir , testDeviceBDFPath )
118
- _ , err = os .Create (deviceFile )
117
+ deviceBDFDir := filepath .Join (devicesDir , testDeviceBDFPath )
118
+ err = os .MkdirAll (deviceBDFDir , dirMode )
119
+ assert .Nil (t , err )
120
+
121
+ deviceClassFile := filepath .Join (deviceBDFDir , "class" )
122
+ _ , err = os .Create (deviceClassFile )
123
+ assert .Nil (t , err )
124
+
125
+ deviceConfigFile := filepath .Join (deviceBDFDir , "config" )
126
+ _ , err = os .Create (deviceConfigFile )
119
127
assert .Nil (t , err )
120
128
121
129
savedIOMMUPath := config .SysIOMMUPath
122
130
config .SysIOMMUPath = tmpDir
123
131
132
+ savedSysBusPciDevicesPath := config .SysBusPciDevicesPath
133
+ config .SysBusPciDevicesPath = devicesDir
134
+
124
135
defer func () {
125
136
config .SysIOMMUPath = savedIOMMUPath
137
+ config .SysBusPciDevicesPath = savedSysBusPciDevicesPath
126
138
}()
127
139
128
140
path := filepath .Join (vfioPath , testFDIOGroup )
@@ -220,7 +232,7 @@ func TestAttachVhostUserBlkDevice(t *testing.T) {
220
232
vhostUserStorePath : tmpDir ,
221
233
}
222
234
assert .Nil (t , err )
223
- os .RemoveAll (tmpDir )
235
+ defer os .RemoveAll (tmpDir )
224
236
225
237
vhostUserDevNodePath := filepath .Join (tmpDir , "/block/devices/" )
226
238
vhostUserSockPath := filepath .Join (tmpDir , "/block/sockets/" )
0 commit comments