From ca13dd2ab5a486a0ab0bf5825bae9a087d854412 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 14 Nov 2019 18:36:26 +0100 Subject: pkg/csoruce: test that executor does not mis-spell any of the SYZ_* macros --- pkg/csource/csource_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'pkg/csource/csource_test.go') diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index 64fd1e936..914ecaa71 100644 --- a/pkg/csource/csource_test.go +++ b/pkg/csource/csource_test.go @@ -10,6 +10,7 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "runtime" "strings" "testing" @@ -160,3 +161,23 @@ func TestSysTests(t *testing.T) { }) } } + +func TestExecutorMacros(t *testing.T) { + // Ensure that executor does not mis-spell any of the SYZ_* macros. + target, _ := prog.GetTarget("test", "64") + p := target.Generate(rand.NewSource(0), 1, nil) + expected := commonDefines(p, Options{}) + expected["SYZ_EXECUTOR"] = true + expected["SYZ_HAVE_SETUP_LOOP"] = true + expected["SYZ_HAVE_RESET_LOOP"] = true + expected["SYZ_HAVE_SETUP_TEST"] = true + macros := regexp.MustCompile("SYZ_[A-Za-z0-9_]+").FindAllString(commonHeader, -1) + for _, macro := range macros { + if strings.HasPrefix(macro, "SYZ_HAVE_") { + continue + } + if _, ok := expected[macro]; !ok { + t.Errorf("unexpected macro: %v", macro) + } + } +} -- cgit mrf-deployment