[llvm] 0c5bee8 - [test] do not parse ls output for file size; NFCI
Bryan Chan via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 30 10:35:29 PST 2019
Author: Bryan Chan
Date: 2019-12-30T13:33:20-05:00
New Revision: 0c5bee8fdd40bbbad9d3f5cce06785c72632fbd0
URL: https://github.com/llvm/llvm-project/commit/0c5bee8fdd40bbbad9d3f5cce06785c72632fbd0
DIFF: https://github.com/llvm/llvm-project/commit/0c5bee8fdd40bbbad9d3f5cce06785c72632fbd0.diff
LOG: [test] do not parse ls output for file size; NFCI
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.
Added:
Modified:
llvm/test/tools/llvm-profdata/show-prof-size.test
llvm/test/tools/yaml2obj/ELF/custom-null-section.yaml
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-profdata/show-prof-size.test b/llvm/test/tools/llvm-profdata/show-prof-size.test
index cc9b16aa08cc..a77360c8a673 100644
--- a/llvm/test/tools/llvm-profdata/show-prof-size.test
+++ b/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.
diff --git a/llvm/test/tools/yaml2obj/ELF/custom-null-section.yaml b/llvm/test/tools/yaml2obj/ELF/custom-null-section.yaml
index e8cbb4edb630..93346032b795 100644
--- a/llvm/test/tools/yaml2obj/ELF/custom-null-section.yaml
+++ b/llvm/test/tools/yaml2obj/ELF/custom-null-section.yaml
@@ -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:.*]]
More information about the llvm-commits
mailing list