github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/syz-ci/config_test.go (about)

     1  // Copyright 2017 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 main
     5  
     6  import (
     7  	"path/filepath"
     8  	"testing"
     9  
    10  	"github.com/google/syzkaller/pkg/osutil"
    11  	"github.com/stretchr/testify/assert"
    12  )
    13  
    14  func TestLoadConfig(t *testing.T) {
    15  	if _, err := loadConfig("testdata/example.cfg"); err != nil {
    16  		t.Fatalf("failed to load: %v", err)
    17  	}
    18  }
    19  
    20  func TestBaselineCanInference(t *testing.T) {
    21  	dir := t.TempDir()
    22  	kernelConfig := filepath.Join(dir, "kernel.config")
    23  	kernelBaseConfig := filepath.Join(dir, "kernel-base.config")
    24  	osutil.WriteFile(kernelConfig, nil)
    25  	osutil.WriteFile(kernelBaseConfig, nil)
    26  	assert.Equal(t, kernelBaseConfig, inferBaselineConfig(kernelConfig))
    27  }
    28  
    29  func TestBaselineCannotInference(t *testing.T) {
    30  	dir := t.TempDir()
    31  	kernelConfig := filepath.Join(dir, "kernel.config")
    32  	osutil.WriteFile(kernelConfig, nil)
    33  	assert.Equal(t, "", inferBaselineConfig(kernelConfig))
    34  }