@@ -1160,7 +1160,7 @@ func TestParsePCIDeviceIDs(t *testing.T) {
1160
1160
{
1161
1161
name : "empty string" ,
1162
1162
input : "" ,
1163
- wantError : true ,
1163
+ wantError : false ,
1164
1164
},
1165
1165
{
1166
1166
name : "invalid ID format" ,
@@ -1193,3 +1193,51 @@ func TestParsePCIDeviceIDs(t *testing.T) {
1193
1193
})
1194
1194
}
1195
1195
}
1196
+
1197
+ func TestCheckAllowDenyOptions (t * testing.T ) {
1198
+ tcases := []struct {
1199
+ name string
1200
+ options cliOptions
1201
+ expectReturn bool
1202
+ }{
1203
+ {
1204
+ name : "valid allow IDs" ,
1205
+ options : cliOptions {allowIDs : "0x1234,0x5678" },
1206
+ expectReturn : true ,
1207
+ },
1208
+ {
1209
+ name : "valid deny IDs" ,
1210
+ options : cliOptions {denyIDs : "0x1234,0x5678" },
1211
+ expectReturn : true ,
1212
+ },
1213
+ {
1214
+ name : "both allow and deny IDs" ,
1215
+ options : cliOptions {allowIDs : "0x1234" , denyIDs : "0x5678" },
1216
+ expectReturn : false ,
1217
+ },
1218
+ {
1219
+ name : "invalid allow ID format" ,
1220
+ options : cliOptions {allowIDs : "0x1234,abcd" },
1221
+ expectReturn : false ,
1222
+ },
1223
+ {
1224
+ name : "invalid deny ID format" ,
1225
+ options : cliOptions {denyIDs : "0x1234,abcd" },
1226
+ expectReturn : false ,
1227
+ },
1228
+ {
1229
+ name : "both empty" ,
1230
+ options : cliOptions {allowIDs : "" , denyIDs : "" },
1231
+ expectReturn : true ,
1232
+ },
1233
+ }
1234
+
1235
+ for _ , tc := range tcases {
1236
+ t .Run (tc .name , func (t * testing.T ) {
1237
+ ret := checkAllowDenyOptions (tc .options )
1238
+ if ret != tc .expectReturn {
1239
+ t .Errorf ("checkAllowDenyOptions() return = %v, expected %v" , ret , tc .expectReturn )
1240
+ }
1241
+ })
1242
+ }
1243
+ }
0 commit comments