From acc528cbf40c42eb112d2ce66c5f778bd4a397fb Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 16 Apr 2024 16:35:18 +0200 Subject: tools/syz-linter: check t.Logf/Errorf/Fatalf messages Fix checking of Logf, it has string in 0-th arg. Add checking of t.Errorf/Fatalf. --- tools/syz-linter/testdata/src/lintertest/lintertest.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tools/syz-linter/testdata/src') diff --git a/tools/syz-linter/testdata/src/lintertest/lintertest.go b/tools/syz-linter/testdata/src/lintertest/lintertest.go index 51700726e..c6ba8ba8f 100644 --- a/tools/syz-linter/testdata/src/lintertest/lintertest.go +++ b/tools/syz-linter/testdata/src/lintertest/lintertest.go @@ -8,6 +8,7 @@ import ( "fmt" "log" "os" + "testing" ) /* some comment */ // want "Use C-style comments // instead of /* */" @@ -100,6 +101,14 @@ func logErrorMessages() { fmt.Fprintf(os.Stderr, "%v", err) // want "Add \\\\n at the end of printed messages" } +func testMessages(t *testing.T) { + t.Logf("good message %v", 1) + t.Logf("Bad message %v", 1) // want "Don't start log/error messages with a Capital letter" + t.Errorf("bad message %v\n", 1) // want "Don't use \\\\n at the end of log/error messages" + t.Fatalf("Bad message %v", 1) // want "Don't start log/error messages with a Capital letter" + t.Fatalf("PublicFunc is ok %v", 1) +} + func varDecls() { var a int b := 0 -- cgit mrf-deployment