[llvm] [llvm-objcopy] Support SREC output format (PR #75874)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 01:06:01 PST 2024


================
@@ -1,18 +1,6 @@
-# RUN: yaml2obj %p/Inputs/srec-elf-sections.yaml -o %t
+# RUN: yaml2obj %s --docnum=1 -o %t
 # RUN: llvm-objcopy -O srec %t - | FileCheck %s
----------------
jh7370 wrote:

As there are multiple different check patterns in this file, it's generally a little clearer if they all have explicit prefixes.

You probably also want to add `--match-full-lines`, to show that there's no text at the start/end of the line that you're not checking for. Finally, you might want to add `--strict-whitespace`, since the actual file shouldn't have any extra spaces etc in it before or after the line. By using the combination of both options, you'll need to format your checks something like `CHECK:S0123456` (note the lack of space after the colon). In this case, it's fairly common to indent the first `CHECK` (i.e. without `-NEXT`) so that the colon lines up with the following `-NEXT` lines, for ease of reading.

Not a functional issue, but I find it easier to follow tests like this with multiple cases and different patterns where the order goes something like:

```
## A single high-level comment describing the general behaviour this test is testing.

## A case-specific comment describing the purpose of the test case (not always necessary,
## but often useful in a file containing multiple cases, as it helps break things up).
# RUN: ... | FileCheck ... --check-prefix=PREFIX1

# PREFIX1: pattern1
...

## Case 2 comment
# RUN: ... | FileCheck ... --check-prefix=PREFIX2

# PREFIX2: pattern2

...

--- !ELF
yaml doc for the earlier test cases

(repeat for test cases that use a new doc etc).
```

(the key thing being the RUN/CHECK/YAML pattern, with things shared between cases after the group that shares them). This is a bit of a subjective thing though, I'll acknowledge.

https://github.com/llvm/llvm-project/pull/75874


More information about the llvm-commits mailing list