@@ -1160,7 +1160,7 @@ func TestParsePCIDeviceIDs(t *testing.T) {
11601160 {
11611161 name : "empty string" ,
11621162 input : "" ,
1163- wantError : true ,
1163+ wantError : false ,
11641164 },
11651165 {
11661166 name : "invalid ID format" ,
@@ -1193,3 +1193,51 @@ func TestParsePCIDeviceIDs(t *testing.T) {
11931193 })
11941194 }
11951195}
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 : false ,
1207+ },
1208+ {
1209+ name : "valid deny IDs" ,
1210+ options : cliOptions {denyIDs : "0x1234,0x5678" },
1211+ expectReturn : false ,
1212+ },
1213+ {
1214+ name : "both allow and deny IDs" ,
1215+ options : cliOptions {allowIDs : "0x1234" , denyIDs : "0x5678" },
1216+ expectReturn : true ,
1217+ },
1218+ {
1219+ name : "invalid allow ID format" ,
1220+ options : cliOptions {allowIDs : "0x1234,abcd" },
1221+ expectReturn : true ,
1222+ },
1223+ {
1224+ name : "invalid deny ID format" ,
1225+ options : cliOptions {denyIDs : "0x1234,abcd" },
1226+ expectReturn : true ,
1227+ },
1228+ {
1229+ name : "both empty" ,
1230+ options : cliOptions {allowIDs : "" , denyIDs : "" },
1231+ expectReturn : false ,
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