aboutsummaryrefslogtreecommitdiffstats
path: root/syz-ci/config_test.go
blob: 2ea077653ea541a495bea5ddc7fe4d898f543500 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2017 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 main

import (
	"path/filepath"
	"testing"

	"github.com/google/syzkaller/pkg/osutil"
	"github.com/stretchr/testify/assert"
)

func TestLoadConfig(t *testing.T) {
	if _, err := loadConfig("testdata/example.cfg"); err != nil {
		t.Fatalf("failed to load: %v", err)
	}
}

func TestBaselineCanInference(t *testing.T) {
	dir := t.TempDir()
	kernelConfig := filepath.Join(dir, "kernel.config")
	kernelBaseConfig := filepath.Join(dir, "kernel-base.config")
	osutil.WriteFile(kernelConfig, nil)
	osutil.WriteFile(kernelBaseConfig, nil)
	assert.Equal(t, kernelBaseConfig, inferBaselineConfig(kernelConfig))
}

func TestBaselineCannotInference(t *testing.T) {
	dir := t.TempDir()
	kernelConfig := filepath.Join(dir, "kernel.config")
	osutil.WriteFile(kernelConfig, nil)
	assert.Equal(t, "", inferBaselineConfig(kernelConfig))
}