Writing tests with Filecheck without emitting output to stdin

Hello

I have pass operating on bitcode file which produces more than one equivalent representation.

opt --my-pass <%s | Filecheck %s

–my-pass generates files a.rpt b.rpt c.rpt . How do i write test without writing all 3 files to stdin.

I have considered CHECK-LABEL for each. it creates bulky checks.

Thanks

Mahesh

Hi Mahesh,

opt --my-pass <%s | Filecheck %s

--my-pass generates files a.rpt b.rpt c.rpt . How do i write test without
writing all 3 files to stdin.

You can run FileCheck over them on separate RUN lines assuming you
know the filename (which I assume you do since you'd be completely
screwed without it).

; RUN: FileCheck %s --check-prefix=CHECK-A < a.rpt
; RUN: FileCheck %s --check-prefix=CHECK-B < b.rpt
; RUN: FileCheck %s --check-prefix=CHECK-C < c.rpt

Cheers.

Tim.

That works. Thanks.

One more followup question though.

Once i run opt on bitcode, there is not useful output/transform on bitcode. this rpt files are extra.

I am hoping to do something like this,

; RUN: FileCheck --input-file=a.rpt.gold --check-prefix=CHECK-A < a.rpt
; RUN: FileCheck --input-file=b.rpt.gold --check-prefix=CHECK-B < b.rpt

i did not find much examples in tests hence question.
does this have any potential issue in matching.

~Mahesh

Hi Mahesh,

Oops. My bad. I mean to write match-file being my match pattern. and a.rpt being file generated by opt.

;RUN: FileCheck a.rpt.gold --input-file=a.rpt.

mahesh

I still don't get it. FileCheck takes its inputs from 2 sources:

+ The actual command-line filename is where knows what it has to look
for (%s in my original example). This file should contain
"CHECK-WHATEVER" lines
+ Stdin is the data it's trying to verify matches what's expected
(which is redirected from a.rpt in my example).

Its output is an exit status of 0 if the test passes, and hopefully
some useful diagnostic if it fails.

There's no room for a 3rd input like your "a.rpt.gold"; there's
nothing more FileCheck needs to do its job.

Cheers.

Tim.

See: http://llvm.org/docs/CommandGuide/FileCheck.html

It is not required to pipe output to FileCheck; there is the --input-file option, which allows you to run FileCheck on an existing disk file. Something like this:

FileCheck %s --input-file a.rpt --check-prefix=A

FileCheck %s --input-file b.rpt --check-prefix=B

FileCheck %s --input-file c.rpt --check-prefix=C

If there are common parts to each .rpt file that you want to check, you can write those checks with another prefix and use the --check-prefixes option to specify all the ones that are appropriate to each run of FileCheck.

I am sure you can find some existing tests with examples of these patterns to give you ideas how to write your test. If you still have questions please feel free to ask them.

–paulr

Thanks that helps.
I was unclear about term “input-file” used in doc. Now it is clear with ur example.

Mahesh