diff options
| author | Alexander Potapenko <glider@google.com> | 2025-10-23 17:30:56 +0200 |
|---|---|---|
| committer | Alexander Potapenko <glider@google.com> | 2025-10-27 09:00:11 +0000 |
| commit | ba25b32a0b180fd14ddd74eef6445839e8208871 (patch) | |
| tree | d12ee9966897efee003e8f568e37c5b919eb2770 | |
| parent | 7dc1cb33ae76d43d894dd96c2c4435a6a26b963d (diff) | |
pkg/csource: remove include guards from reproducers
Drop all lines matching `#define [A-Z0-9_]*_H` from the reproducers
| -rw-r--r-- | pkg/csource/csource.go | 3 | ||||
| -rw-r--r-- | pkg/csource/csource_test.go | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index ecfca80ea..acbb33ff8 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -685,6 +685,9 @@ func (ctx *context) postProcess(result []byte) []byte { result = regexp.MustCompile(`\t*exitf\((.*\n)*?.*\);\n`).ReplaceAll(result, []byte("\texit(1);\n")) result = regexp.MustCompile(`\t*fail(msg)?\((.*\n)*?.*\);\n`).ReplaceAll(result, []byte("\texit(1);\n")) + // Remove executor include guards. + result = regexp.MustCompile(`#define\s+[A-Z0-9_]*_H\s*\n`).ReplaceAll(result, nil) + result = ctx.hoistIncludes(result) result = ctx.removeEmptyLines(result) return result diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index 15dad5f34..1dae0202d 100644 --- a/pkg/csource/csource_test.go +++ b/pkg/csource/csource_test.go @@ -140,6 +140,11 @@ func testOne(t *testing.T, p *prog.Prog, opts Options) { t.Logf("opts: %+v\nprogram:\n%s", opts, p.Serialize()) t.Fatalf("%v", err) } + // Executor headers are embedded into the C source. Make sure there are no leftover include guards. + if matches := regexp.MustCompile(`(?m)^#define\s+\S+_H\s*\n`).FindAllString(string(src), -1); len(matches) > 0 { + t.Fatalf("source contains leftover include guards: %v\nopts: %+v\nprogram:\n%s", + matches, opts, p.Serialize()) + } bin, err := Build(p.Target, src) if err != nil { if atomic.AddUint32(&failedTests, 1) > maxFailures { |
