// Copyright 2026 syzkaller project authors. All rights reserved. // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. package mgrconfig import ( "testing" "github.com/google/syzkaller/prog" "github.com/google/syzkaller/sys/targets" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestParseEnabledSyscalls(t *testing.T) { target, err := prog.GetTarget(targets.TestOS, targets.TestArch64) require.NoError(t, err) tests := []struct { name string mode DescriptionsMode enable []string // TODO: add disable tests as well. expectEnabled []string expectDisabled []string }{ { name: "wildcard, no snapshot", mode: ManualDescriptions, enable: []string{"test"}, expectDisabled: []string{"test$snapshot_only"}, }, { name: "wildcard, snapshot", mode: ManualDescriptions | SnapshotDescriptions, enable: []string{"test"}, expectEnabled: []string{"test$snapshot_only"}, }, { name: "no wildcard, no snapshot", mode: ManualDescriptions, enable: []string{"test$snapshot_only"}, expectEnabled: []string{"test$snapshot_only"}, }, { name: "no wildcard, snapshot", mode: ManualDescriptions | SnapshotDescriptions, enable: []string{"test$snapshot_only"}, expectEnabled: []string{"test$snapshot_only"}, }, { name: "automatic allowed", mode: ManualDescriptions | AutoDescriptions, enable: []string{"test"}, expectEnabled: []string{ "test$automatic", "test$automatic_helper", "test$manual", }, }, { name: "manual only", mode: ManualDescriptions, enable: []string{"test"}, expectEnabled: []string{ "test$automatic_helper", "test$manual", }, expectDisabled: []string{ "test$automatic", }, }, { name: "auto only", mode: AutoDescriptions, enable: []string{"test"}, expectEnabled: []string{ "test$automatic", "test$automatic_helper", }, expectDisabled: []string{ "test$manual", }, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { ids, err := ParseEnabledSyscalls(target, test.enable, nil, test.mode) require.NoError(t, err) for _, enabled := range test.expectEnabled { assert.Contains(t, ids, target.SyscallMap[enabled].ID) } for _, disabled := range test.expectDisabled { assert.NotContains(t, ids, target.SyscallMap[disabled].ID) } }) } }