Skip to content

Commit 1e61119

Browse files
author
Ethan Graham
committed
kfuzztest: address minor nits
1 parent 01eb916 commit 1e61119

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

pkg/kcov/kcov.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import (
1010
"golang.org/x/sys/unix"
1111
)
1212

13-
const kcovPath string = "/sys/kernel/debug/kcov"
14-
1513
const (
16-
kcovCoverSize = 64 << 10
14+
kcovPath string = "/sys/kernel/debug/kcov"
15+
kcovCoverSize = 64 << 10
1716
)
1817

1918
// Holds resources for a single traced thread.

prog/kfuzztest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func kFuzzTestExpandRegion(reg Arg) ([]byte, []kFuzzTestRelocation) {
211211
// given pointee is allocated only once.
212212
//
213213
// For a concrete example of the final binary layout, see the test cases for this
214-
// function in `prog/encodingexec_test.go`.
214+
// function in `prog/kfuzztest_test.go`.
215215
func MarshallKFuzztestArg(topLevel Arg) []byte {
216216
regions := []kFuzzTestRegion{}
217217
allRelocations := []kFuzzTestRelocation{}

syz-kfuzztest/main.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package main
55
import (
66
"context"
77
"flag"
8+
"fmt"
89
"os"
910
"os/signal"
1011
"syscall"
@@ -13,16 +14,28 @@ import (
1314
)
1415

1516
var (
16-
flagVmlinux = flag.String("vmlinux", "", "Path to vmlinux binary")
17+
flagVmlinux = flag.String("vmlinux", "vmlinux", "Path to vmlinux binary")
1718
flagTimeout = flag.Int("timeout", 0, "Timeout in milliseconds")
18-
flagThreads = flag.Int("threads", 1, "Number of threads")
19+
flagThreads = flag.Int("threads", 2, "Number of threads")
1920
flagDisplayInterval = flag.Int("display", 5, "Display interval")
20-
flagDisplayProgs = flag.Bool("display-progs", false, "Display last executed prog for each target")
21+
flagDisplayProgs = flag.Bool("display-progs", false, "If enabled, display the last executed prog for each target")
2122
)
2223

2324
func main() {
24-
flag.Parse()
25+
usage := func() {
26+
w := flag.CommandLine.Output()
27+
fmt.Fprintf(w, "usage: %s [flags] [enabled targets]\n\n", os.Args[0])
28+
fmt.Fprintln(w, `Args:
29+
One fuzz test name per enabled fuzz test arg. If empty, defaults to
30+
all discovered targets.`)
31+
fmt.Fprintln(w, `Example:
32+
./syz-kfuzztest -vmlinux ~/kernel/vmlinux fuzz_target_0 fuzz_target_1`)
33+
fmt.Fprintln(w, "Flags:")
34+
flag.PrintDefaults()
35+
}
36+
flag.Usage = usage
2537
enabledTargets := flag.Args()
38+
flag.Parse()
2639

2740
cfg := config{
2841
vmlinuxPath: *flagVmlinux,

0 commit comments

Comments
 (0)