Skip to content

Commit

Permalink
[test] do not parse ls output for file size; NFCI
Browse files Browse the repository at this point in the history
Parsing `ls -l` output to obtain the size of a file is unreliable; the
exact output format is not specified, and some user or group names may
contain multiple words, causing `cut -f5 -d' '` to extract an incorrect
value. `wc -c`, on the other hand, is portable, and there are precendents
of its use in test cases.
  • Loading branch information
bryanpkc committed Dec 30, 2019
1 parent 48e0e68 commit 0c5bee8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-profdata/show-prof-size.test
@@ -1,5 +1,5 @@
; RUN: llvm-profdata merge -sample -extbinary -prof-sym-list=%S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile.proftext -o %t.1.output
; RUN: ls -l %t.1.output |tr -s ' ' |cut -f5 -d ' ' > %t.txt
; RUN: wc -c < %t.1.output > %t.txt
; RUN: llvm-profdata show -sample -show-sec-info-only %t.1.output >> %t.txt
; RUN: FileCheck %s --input-file=%t.txt
; Check llvm-profdata shows the correct file size.
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/yaml2obj/ELF/custom-null-section.yaml
Expand Up @@ -71,8 +71,8 @@ Sections:
## of the first SHT_NULL section.

# RUN: yaml2obj --docnum=4 %s -o %t4
# RUN: ls -l %t3 | tr -s ' ' | cut -d ' ' -f 5 > %t.txt
# RUN: ls -l %t4 | tr -s ' ' | cut -d ' ' -f 5 >> %t.txt
# RUN: wc -c < %t3 > %t.txt
# RUN: wc -c < %t4 >> %t.txt
# RUN: FileCheck %s --input-file=%t.txt --check-prefix=SIZE

# SIZE: [[FILESIZE:.*]]
Expand Down

0 comments on commit 0c5bee8

Please sign in to comment.