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
35
36
37
38
39
40
41
42
43
44
45
|
// 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 codesearcher
import (
"path/filepath"
"testing"
"github.com/google/syzkaller/pkg/aflow"
"github.com/google/syzkaller/pkg/codesearch"
)
func TestStructLayout(t *testing.T) {
aflow.TestTool(t, ToolStructLayout,
createIndex(t),
structLayoutArgs{
Name: "struct_in_c_file",
},
structLayoutResult{
Fields: []structLayoutField{
{Name: "X", OffsetBits: 0, SizeBits: 32},
{Name: "by_value", OffsetBits: 32, SizeBits: 64},
},
},
``,
)
}
func TestStructLayoutNonExistent(t *testing.T) {
aflow.TestTool(t, ToolStructLayout,
createIndex(t),
structLayoutArgs{
Name: "non-existent-name",
},
structLayoutResult{},
`requested entity does not exist`,
)
}
func createIndex(t *testing.T) prepareResult {
return prepareResult{
Index: index{codesearch.NewTestIndex(t, filepath.FromSlash("../../../codesearch/testdata"))},
}
}
|