github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/kconfig/kconfig_test.go (about)

     1  // Copyright 2020 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package kconfig
     5  
     6  import (
     7  	"fmt"
     8  	"testing"
     9  
    10  	"github.com/google/syzkaller/sys/targets"
    11  )
    12  
    13  func TestParseKConfig(t *testing.T) {
    14  	type Test struct {
    15  		in string
    16  	}
    17  	tests := []Test{
    18  		{
    19  			in: `
    20  mainmenu "test"
    21  config FOO
    22  	default "$(shell,$(srctree)/scripts/gcc-plugin.sh "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")" if CC_IS_GCC
    23  `,
    24  		},
    25  	}
    26  	target := targets.Get("linux", "amd64")
    27  	for i, test := range tests {
    28  		t.Run(fmt.Sprint(i), func(t *testing.T) {
    29  			kconf, err := ParseData(target, []byte(test.in), "Kconfig")
    30  			if err != nil {
    31  				t.Fatal(err)
    32  			}
    33  			_ = kconf
    34  		})
    35  	}
    36  }
    37  
    38  func TestFuzzParseKConfig(t *testing.T) {
    39  	for _, data := range []string{
    40  		``,
    41  	} {
    42  		FuzzParseKConfig([]byte(data)[:len(data):len(data)])
    43  	}
    44  }