[llvm] [llvm-lit][test] Precommit tests for lit's built-in cat command (PR #101530)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 2 14:33:52 PDT 2024
https://github.com/connieyzhu updated https://github.com/llvm/llvm-project/pull/101530
>From dee2254996077ec947ec5255d4364e5ef29170ba Mon Sep 17 00:00:00 2001
From: Connie Zhu <connieyzhu at google.com>
Date: Thu, 1 Aug 2024 17:36:10 +0000
Subject: [PATCH 1/5] [llvm-lit][test] Adding tests for lit's built-in cat
command
This patch creates preliminary checks for lit's built-in cat command.
These tests verify the cat and cat -v functionality, and display
failures with using cat -e which will be implemented in a later patch.
---
.../Inputs/shtest-cat/cat-e-allchars.txt | 19 ++++++++++
.../tests/Inputs/shtest-cat/cat-e-newline.txt | 12 +++++++
.../tests/Inputs/shtest-cat/cat-newline.txt | 12 +++++++
.../Inputs/shtest-cat/cat-v-allchars.txt | 34 ++++++++++++++++++
.../utils/lit/tests/Inputs/shtest-cat/lit.cfg | 8 +++++
.../Inputs/shtest-cat/txt-files/allchars | Bin 0 -> 256 bytes
.../tests/Inputs/shtest-cat/txt-files/newline | 10 ++++++
llvm/utils/lit/tests/shtest-cat.py | 32 +++++++++++++++++
8 files changed, 127 insertions(+)
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-allchars.txt
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-newline.txt
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat-newline.txt
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat-v-allchars.txt
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/lit.cfg
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/allchars
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/newline
create mode 100644 llvm/utils/lit/tests/shtest-cat.py
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-allchars.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-allchars.txt
new file mode 100644
index 0000000000000..6955b796f695a
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-allchars.txt
@@ -0,0 +1,19 @@
+# RUN: cat -e %S/txt-files/allchars | FileCheck %s
+
+# CHECK: ^@^A^B^C^D^E^F^G^H $
+# CHECK: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
+# CHECK-SAME: ^[^\^]^^^_ !"#$%&'()*+,-./
+# CHECK-SAME: 0123456789
+# CHECK-SAME: :;<=>?@
+# CHECK-SAME: ABCDEFGHIJKLMNOPQRSTUVWXYZ
+# CHECK-SAME: [\]^_`
+# CHECK-SAME: abcdefghijklmnopqrstuvwxyz
+# CHECK-SAME: {|}~^?
+# CHECK-SAME: M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^Z
+# CHECK-SAME: M-^[M-^\M-^]M-^^M-^_M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/
+# CHECK-SAME: M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9
+# CHECK-SAME: M-:M-;M-<M-=M->M-?M-@
+# CHECK-SAME: M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-Z
+# CHECK-SAME: M-[M-\M-]M-^M-_M-`
+# CHECK-SAME: M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-z
+# CHECK-SAME: M-{M-|M-}M-~M-^?
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-newline.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-newline.txt
new file mode 100644
index 0000000000000..cd97646461376
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-newline.txt
@@ -0,0 +1,12 @@
+# RUN: cat -e %S/txt-files/newline | FileCheck %s
+
+# CHECK: new
+# CHECK: $
+# CHECK: $
+# CHECK: $
+# CHECK: $
+# CHECK: $
+# CHECK: $
+# CHECK: $
+# CHECK: $
+# CHECK: line
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-newline.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-newline.txt
new file mode 100644
index 0000000000000..de762dc1d639f
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-newline.txt
@@ -0,0 +1,12 @@
+# RUN: cat %S/txt-files/newline | FileCheck %s
+
+# CHECK: new
+# CHECK-EMPTY:
+# CHECK-EMPTY:
+# CHECK-EMPTY:
+# CHECK-EMPTY:
+# CHECK-EMPTY:
+# CHECK-EMPTY:
+# CHECK-EMPTY:
+# CHECK-EMPTY:
+# CHECK: line
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v-allchars.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v-allchars.txt
new file mode 100644
index 0000000000000..70643efd3897a
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v-allchars.txt
@@ -0,0 +1,34 @@
+# C Program to generate all ASCII characters in allchars.txt
+# #include <stdio.h>
+# int main() {
+# FILE *fptr = fopen("allchars.txt", "w");
+# if(fptr == NULL) {
+# return 1;
+# }
+# for(int i = 0; i < 256; i++) {
+# fprintf(fptr, "%c", i);
+# }
+# fclose(fptr);
+# return 0;
+# }
+
+# RUN: cat -v %S/txt-files/allchars | FileCheck %s
+
+# CHECK: ^@^A^B^C^D^E^F^G^H
+# CHECK: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
+# CHECK-SAME: ^[^\^]^^^_
+# CHECK-SAME: !"#$%&'()*+,-./
+# CHECK-SAME: 0123456789
+# CHECK-SAME: :;<=>?@
+# CHECK-SAME: ABCDEFGHIJKLMNOPQRSTUVWXYZ
+# CHECK-SAME: [\]^_`
+# CHECK-SAME: abcdefghijklmnopqrstuvwxyz
+# CHECK-SAME: {|}~^?
+# CHECK-SAME: M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^Z
+# CHECK-SAME: M-^[M-^\M-^]M-^^M-^_M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/
+# CHECK-SAME: M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9
+# CHECK-SAME: M-:M-;M-<M-=M->M-?M-@
+# CHECK-SAME: M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-Z
+# CHECK-SAME: M-[M-\M-]M-^M-_M-`
+# CHECK-SAME: M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-z
+# CHECK-SAME: M-{M-|M-}M-~M-^?
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-cat/lit.cfg
new file mode 100644
index 0000000000000..6b179bf5d4f3b
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/lit.cfg
@@ -0,0 +1,8 @@
+import lit.formats
+
+config.name = "shtest-cat"
+config.suffixes = [".txt"]
+config.test_format = lit.formats.ShTest()
+config.test_source_root = None
+config.test_exec_root = None
+config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/allchars b/llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/allchars
new file mode 100644
index 0000000000000000000000000000000000000000..c86626638e0bc8cf47ca49bb1525b40e9737ee64
GIT binary patch
literal 256
zcmV+b0ssC00RjUA1qKHQ2?`4g4Gs?w5fT#=6&4p585$cL9UdPbAtECrB_<~*DJm;0
zEiNxGF)}kWH8wXmIXXK$Jw87`K|(`BMMg(RNlHshO- at fxQBqS>RaRG6Sz23MU0z>c
zVPa!sWoBn+X=-b1ZEkOHadLBXb#`}nd3t+%eSUv{fr5jCg@%WSiHeJijgF6yk&=^?
zm6n&7nVOrNot~edp`xRtrKYE-sj922t*)=Iv9hzYwYImoxw^Z&y}rM|!NSAD#m2|T
z$;!*j&Cbuz(bCh@)z;V8+1lIO-QM5e;o{@u<>u$;>FVq3?e6dJ@$&QZ_4fDp`TG0(
G{r>;0_J4r@
literal 0
HcmV?d00001
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/newline b/llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/newline
new file mode 100644
index 0000000000000..6702897186ebc
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/newline
@@ -0,0 +1,10 @@
+new
+
+
+
+
+
+
+
+
+line
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/shtest-cat.py b/llvm/utils/lit/tests/shtest-cat.py
new file mode 100644
index 0000000000000..412fccd98c5ac
--- /dev/null
+++ b/llvm/utils/lit/tests/shtest-cat.py
@@ -0,0 +1,32 @@
+# Check the cat command
+
+# RUN: not %{lit} -a -v %{inputs}/shtest-cat \
+# RUN: | FileCheck -match-full-lines %s
+#
+# END.
+
+# CHECK: FAIL: shtest-cat :: cat-e-allchars.txt ({{[^)]*}})
+# CHECK: cat -e {{.+}}/allchars | FileCheck {{.*}}
+# CHECK: # executed command: cat -e {{.*}}
+# CHECK: # | Unsupported: 'cat': option -e not recognized
+# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK: # executed command: FileCheck {{.*}}
+# CHECK: # error: command failed with exit status: {{.*}}
+
+# CHECK: FAIL: shtest-cat :: cat-e-newline.txt ({{[^)]*}})
+# CHECK: cat -e {{.+}}/newline | FileCheck {{.*}}
+# CHECK: # executed command: cat -e {{.*}}
+# CHECK: # | Unsupported: 'cat': option -e not recognized
+# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK: # executed command: FileCheck {{.*}}
+# CHECK: # error: command failed with exit status: {{.*}}
+
+# CHECK: PASS: shtest-cat :: cat-newline.txt ({{[^)]*}})
+# CHECK: cat {{.+}}/newline | FileCheck {{.*}}
+# CHECK: # executed command: cat {{.*}}
+# CHECK: # executed command: FileCheck {{.*}}
+
+# CHECK: PASS: shtest-cat :: cat-v-allchars.txt ({{[^)]*}})
+# CHECK: cat -v {{.+}}/allchars | FileCheck {{.*}}
+# CHECK: # executed command: cat -v {{.*}}
+# CHECK: # executed command: FileCheck {{.*}}
\ No newline at end of file
>From 9c2fb031a520c6addd0128b0078a36d55d1d7451 Mon Sep 17 00:00:00 2001
From: Connie Zhu <connieyzhu at google.com>
Date: Fri, 2 Aug 2024 17:28:09 +0000
Subject: [PATCH 2/5] [llvm-lit] Combined test files to separate by option for
cat
Tests for the same cat options were initially in different files, but
now these tests are condensed into 3 files that contain all tests for
each cat option, which are cat, cat -v, and cat -e. Also made some minor
syntax changes and added clarifying comments.
---
.../Inputs/shtest-cat/cat-e-allchars.txt | 19 -------
.../tests/Inputs/shtest-cat/cat-e-newline.txt | 12 -----
.../lit/tests/Inputs/shtest-cat/cat-e.txt | 33 +++++++++++++
.../tests/Inputs/shtest-cat/cat-newline.txt | 12 -----
.../Inputs/shtest-cat/cat-v-allchars.txt | 34 -------------
.../lit/tests/Inputs/shtest-cat/cat-v.txt | 49 +++++++++++++++++++
.../utils/lit/tests/Inputs/shtest-cat/cat.txt | 14 ++++++
.../tests/Inputs/shtest-cat/txt-files/newline | 4 +-
llvm/utils/lit/tests/shtest-cat.py | 23 ++++-----
9 files changed, 107 insertions(+), 93 deletions(-)
delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-allchars.txt
delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-newline.txt
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt
delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat-newline.txt
delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat-v-allchars.txt
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-allchars.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-allchars.txt
deleted file mode 100644
index 6955b796f695a..0000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-allchars.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# RUN: cat -e %S/txt-files/allchars | FileCheck %s
-
-# CHECK: ^@^A^B^C^D^E^F^G^H $
-# CHECK: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
-# CHECK-SAME: ^[^\^]^^^_ !"#$%&'()*+,-./
-# CHECK-SAME: 0123456789
-# CHECK-SAME: :;<=>?@
-# CHECK-SAME: ABCDEFGHIJKLMNOPQRSTUVWXYZ
-# CHECK-SAME: [\]^_`
-# CHECK-SAME: abcdefghijklmnopqrstuvwxyz
-# CHECK-SAME: {|}~^?
-# CHECK-SAME: M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^Z
-# CHECK-SAME: M-^[M-^\M-^]M-^^M-^_M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/
-# CHECK-SAME: M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9
-# CHECK-SAME: M-:M-;M-<M-=M->M-?M-@
-# CHECK-SAME: M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-Z
-# CHECK-SAME: M-[M-\M-]M-^M-_M-`
-# CHECK-SAME: M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-z
-# CHECK-SAME: M-{M-|M-}M-~M-^?
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-newline.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-newline.txt
deleted file mode 100644
index cd97646461376..0000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e-newline.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-# RUN: cat -e %S/txt-files/newline | FileCheck %s
-
-# CHECK: new
-# CHECK: $
-# CHECK: $
-# CHECK: $
-# CHECK: $
-# CHECK: $
-# CHECK: $
-# CHECK: $
-# CHECK: $
-# CHECK: line
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt
new file mode 100644
index 0000000000000..49c8d267a2e2c
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt
@@ -0,0 +1,33 @@
+## Tests to check cat -e output for ASCII characters and newlines
+
+# RUN: cat -e %S/txt-files/allchars | FileCheck %s --check-prefix=ALLCHARS
+# RUN: cat -e %S/txt-files/newline | FileCheck %s --check-prefix=NEWLINE
+
+# ALLCHARS: ^@^A^B^C^D^E^F^G^H $
+# ALLCHARS: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
+# ALLCHARS-SAME: ^[^\^]^^^_ !"#$%&'()*+,-./
+# ALLCHARS-SAME: 0123456789
+# ALLCHARS-SAME: :;<=>?@
+# ALLCHARS-SAME: ABCDEFGHIJKLMNOPQRSTUVWXYZ
+# ALLCHARS-SAME: [\]^_`
+# ALLCHARS-SAME: abcdefghijklmnopqrstuvwxyz
+# ALLCHARS-SAME: {|}~^?
+# ALLCHARS-SAME: M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^Z
+# ALLCHARS-SAME: M-^[M-^\M-^]M-^^M-^_M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/
+# ALLCHARS-SAME: M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9
+# ALLCHARS-SAME: M-:M-;M-<M-=M->M-?M-@
+# ALLCHARS-SAME: M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-Z
+# ALLCHARS-SAME: M-[M-\M-]M-^M-_M-`
+# ALLCHARS-SAME: M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-z
+# ALLCHARS-SAME: M-{M-|M-}M-~M-^?
+
+# NEWLINE: first
+# NEWLINE: $
+# NEWLINE: $
+# NEWLINE: $
+# NEWLINE: $
+# NEWLINE: $
+# NEWLINE: $
+# NEWLINE: $
+# NEWLINE: $
+# NEWLINE: last
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-newline.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-newline.txt
deleted file mode 100644
index de762dc1d639f..0000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-newline.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-# RUN: cat %S/txt-files/newline | FileCheck %s
-
-# CHECK: new
-# CHECK-EMPTY:
-# CHECK-EMPTY:
-# CHECK-EMPTY:
-# CHECK-EMPTY:
-# CHECK-EMPTY:
-# CHECK-EMPTY:
-# CHECK-EMPTY:
-# CHECK-EMPTY:
-# CHECK: line
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v-allchars.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v-allchars.txt
deleted file mode 100644
index 70643efd3897a..0000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v-allchars.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-# C Program to generate all ASCII characters in allchars.txt
-# #include <stdio.h>
-# int main() {
-# FILE *fptr = fopen("allchars.txt", "w");
-# if(fptr == NULL) {
-# return 1;
-# }
-# for(int i = 0; i < 256; i++) {
-# fprintf(fptr, "%c", i);
-# }
-# fclose(fptr);
-# return 0;
-# }
-
-# RUN: cat -v %S/txt-files/allchars | FileCheck %s
-
-# CHECK: ^@^A^B^C^D^E^F^G^H
-# CHECK: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
-# CHECK-SAME: ^[^\^]^^^_
-# CHECK-SAME: !"#$%&'()*+,-./
-# CHECK-SAME: 0123456789
-# CHECK-SAME: :;<=>?@
-# CHECK-SAME: ABCDEFGHIJKLMNOPQRSTUVWXYZ
-# CHECK-SAME: [\]^_`
-# CHECK-SAME: abcdefghijklmnopqrstuvwxyz
-# CHECK-SAME: {|}~^?
-# CHECK-SAME: M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^Z
-# CHECK-SAME: M-^[M-^\M-^]M-^^M-^_M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/
-# CHECK-SAME: M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9
-# CHECK-SAME: M-:M-;M-<M-=M->M-?M-@
-# CHECK-SAME: M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-Z
-# CHECK-SAME: M-[M-\M-]M-^M-_M-`
-# CHECK-SAME: M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-z
-# CHECK-SAME: M-{M-|M-}M-~M-^?
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt
new file mode 100644
index 0000000000000..f893d553c8df7
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt
@@ -0,0 +1,49 @@
+# C Program to generate all ASCII characters in allchars.txt
+# #include <stdio.h>
+# int main() {
+# FILE *fptr = fopen("allchars.txt", "w");
+# if(fptr == NULL) {
+# return 1;
+# }
+# for(int i = 0; i < 256; i++) {
+# fprintf(fptr, "%c", i);
+# }
+# fclose(fptr);
+# return 0;
+# }
+
+
+## Tests to check cat -e output for ASCII characters and newlines
+
+# RUN: cat -v %S/txt-files/allchars | FileCheck %s --check-prefix=ALLCHARS
+# RUN: cat -v %S/txt-files/newline | FileCheck %s --check-prefix=NEWLINE
+
+# ALLCHARS: ^@^A^B^C^D^E^F^G^H
+# ALLCHARS: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
+# ALLCHARS-SAME: ^[^\^]^^^_
+# ALLCHARS-SAME: !"#$%&'()*+,-./
+# ALLCHARS-SAME: 0123456789
+# ALLCHARS-SAME: :;<=>?@
+# ALLCHARS-SAME: ABCDEFGHIJKLMNOPQRSTUVWXYZ
+# ALLCHARS-SAME: [\]^_`
+# ALLCHARS-SAME: abcdefghijklmnopqrstuvwxyz
+# ALLCHARS-SAME: {|}~^?
+# ALLCHARS-SAME: M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^Z
+# ALLCHARS-SAME: M-^[M-^\M-^]M-^^M-^_M- M-!M-"M-#M-$M-%M-&M-'M-(M-)M-*M-+M-,M--M-.M-/
+# ALLCHARS-SAME: M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9
+# ALLCHARS-SAME: M-:M-;M-<M-=M->M-?M-@
+# ALLCHARS-SAME: M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-Z
+# ALLCHARS-SAME: M-[M-\M-]M-^M-_M-`
+# ALLCHARS-SAME: M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-z
+# ALLCHARS-SAME: M-{M-|M-}M-~M-^?
+
+# NEWLINE: first
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE: last
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
new file mode 100644
index 0000000000000..a71f16bae82d0
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
@@ -0,0 +1,14 @@
+## Tests
+
+# RUN: cat %S/txt-files/newline | FileCheck %s --check-prefix=NEWLINE
+
+# NEWLINE: first
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE-EMPTY:
+# NEWLINE: last
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/newline b/llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/newline
index 6702897186ebc..8cf6e6741f192 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/newline
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/txt-files/newline
@@ -1,4 +1,4 @@
-new
+first
@@ -7,4 +7,4 @@ new
-line
\ No newline at end of file
+last
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/shtest-cat.py b/llvm/utils/lit/tests/shtest-cat.py
index 412fccd98c5ac..0b2b94e2b0cb7 100644
--- a/llvm/utils/lit/tests/shtest-cat.py
+++ b/llvm/utils/lit/tests/shtest-cat.py
@@ -1,11 +1,11 @@
-# Check the cat command
+## Test the cat command
# RUN: not %{lit} -a -v %{inputs}/shtest-cat \
# RUN: | FileCheck -match-full-lines %s
#
# END.
-# CHECK: FAIL: shtest-cat :: cat-e-allchars.txt ({{[^)]*}})
+# CHECK: FAIL: shtest-cat :: cat-e.txt ({{[^)]*}})
# CHECK: cat -e {{.+}}/allchars | FileCheck {{.*}}
# CHECK: # executed command: cat -e {{.*}}
# CHECK: # | Unsupported: 'cat': option -e not recognized
@@ -13,20 +13,15 @@
# CHECK: # executed command: FileCheck {{.*}}
# CHECK: # error: command failed with exit status: {{.*}}
-# CHECK: FAIL: shtest-cat :: cat-e-newline.txt ({{[^)]*}})
-# CHECK: cat -e {{.+}}/newline | FileCheck {{.*}}
-# CHECK: # executed command: cat -e {{.*}}
-# CHECK: # | Unsupported: 'cat': option -e not recognized
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK: PASS: shtest-cat :: cat-v.txt ({{[^)]*}})
+# CHECK: cat -v {{.+}}/allchars | FileCheck {{.*}}
+# CHECK: # executed command: cat -v {{.*}}
+# CHECK: # executed command: FileCheck {{.*}}
+# CHECK: cat -v {{.+}}/newline | FileCheck {{.*}}
+# CHECK: # executed command: cat -v {{.*}}
# CHECK: # executed command: FileCheck {{.*}}
-# CHECK: # error: command failed with exit status: {{.*}}
-# CHECK: PASS: shtest-cat :: cat-newline.txt ({{[^)]*}})
+# CHECK: PASS: shtest-cat :: cat.txt ({{[^)]*}})
# CHECK: cat {{.+}}/newline | FileCheck {{.*}}
# CHECK: # executed command: cat {{.*}}
-# CHECK: # executed command: FileCheck {{.*}}
-
-# CHECK: PASS: shtest-cat :: cat-v-allchars.txt ({{[^)]*}})
-# CHECK: cat -v {{.+}}/allchars | FileCheck {{.*}}
-# CHECK: # executed command: cat -v {{.*}}
# CHECK: # executed command: FileCheck {{.*}}
\ No newline at end of file
>From 1b7d6a68ad48be906725c13c0fdb524f92828c1f Mon Sep 17 00:00:00 2001
From: Connie Zhu <connieyzhu at google.com>
Date: Fri, 2 Aug 2024 20:47:59 +0000
Subject: [PATCH 3/5] [llvm-lit] Added more clarifying comments + minor syntax
changes
More comments describing the purpose of the tests were added for
clarification purposes. Some small syntax changes were also made for
better readability.
---
llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt | 7 +++++--
llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt | 7 ++++---
llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt | 2 +-
llvm/utils/lit/tests/Inputs/shtest-cat/lit.cfg | 3 +--
4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt
index 49c8d267a2e2c..739e1a37a7f5e 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt
@@ -1,9 +1,11 @@
-## Tests to check cat -e output for ASCII characters and newlines
+## Tests to check cat -e output
# RUN: cat -e %S/txt-files/allchars | FileCheck %s --check-prefix=ALLCHARS
# RUN: cat -e %S/txt-files/newline | FileCheck %s --check-prefix=NEWLINE
-# ALLCHARS: ^@^A^B^C^D^E^F^G^H $
+## Test output of -e for all ASCII characters in ^ and M- notation
+# ALLCHARS: ^@^A^B^C^D^E^F^G^H
+# ALLCHARS-SAME: $
# ALLCHARS: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
# ALLCHARS-SAME: ^[^\^]^^^_ !"#$%&'()*+,-./
# ALLCHARS-SAME: 0123456789
@@ -21,6 +23,7 @@
# ALLCHARS-SAME: M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-z
# ALLCHARS-SAME: M-{M-|M-}M-~M-^?
+## Test output of -e for new lines
# NEWLINE: first
# NEWLINE: $
# NEWLINE: $
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt
index f893d553c8df7..ac78eb4fd5f4c 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt
@@ -1,4 +1,4 @@
-# C Program to generate all ASCII characters in allchars.txt
+## C Program to generate all ASCII characters in allchars
# #include <stdio.h>
# int main() {
# FILE *fptr = fopen("allchars.txt", "w");
@@ -12,12 +12,12 @@
# return 0;
# }
-
-## Tests to check cat -e output for ASCII characters and newlines
+## Tests to check cat -v output
# RUN: cat -v %S/txt-files/allchars | FileCheck %s --check-prefix=ALLCHARS
# RUN: cat -v %S/txt-files/newline | FileCheck %s --check-prefix=NEWLINE
+## Test output of -v for all ASCII characters in ^ and M- notation
# ALLCHARS: ^@^A^B^C^D^E^F^G^H
# ALLCHARS: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
# ALLCHARS-SAME: ^[^\^]^^^_
@@ -37,6 +37,7 @@
# ALLCHARS-SAME: M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-z
# ALLCHARS-SAME: M-{M-|M-}M-~M-^?
+## Test output of -v for new lines
# NEWLINE: first
# NEWLINE-EMPTY:
# NEWLINE-EMPTY:
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
index a71f16bae82d0..532d54088da52 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
@@ -1,4 +1,4 @@
-## Tests
+## Tests to check cat output
# RUN: cat %S/txt-files/newline | FileCheck %s --check-prefix=NEWLINE
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-cat/lit.cfg
index 6b179bf5d4f3b..29246a84d7fab 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/lit.cfg
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/lit.cfg
@@ -4,5 +4,4 @@ config.name = "shtest-cat"
config.suffixes = [".txt"]
config.test_format = lit.formats.ShTest()
config.test_source_root = None
-config.test_exec_root = None
-config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
\ No newline at end of file
+config.test_exec_root = None
\ No newline at end of file
>From ff3f7e64492eb28ab3262cf37240dcbafd8f8227 Mon Sep 17 00:00:00 2001
From: Connie Zhu <connieyzhu at google.com>
Date: Fri, 2 Aug 2024 20:57:48 +0000
Subject: [PATCH 4/5] [llvm-lit] Added allchars test for cat
This patch adds another test to check the cat functionality with the
allchars text file that includes special/meta characters.
---
llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt | 2 ++
llvm/utils/lit/tests/shtest-cat.py | 8 ++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
index 532d54088da52..c8455d7c5dc3a 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
@@ -1,6 +1,8 @@
## Tests to check cat output
# RUN: cat %S/txt-files/newline | FileCheck %s --check-prefix=NEWLINE
+# RUN: cat %S/txt-files/allchars > %t
+# RUN: diff %S/txt-files/allchars %t
# NEWLINE: first
# NEWLINE-EMPTY:
diff --git a/llvm/utils/lit/tests/shtest-cat.py b/llvm/utils/lit/tests/shtest-cat.py
index 0b2b94e2b0cb7..e83484b1cb212 100644
--- a/llvm/utils/lit/tests/shtest-cat.py
+++ b/llvm/utils/lit/tests/shtest-cat.py
@@ -1,7 +1,7 @@
## Test the cat command
# RUN: not %{lit} -a -v %{inputs}/shtest-cat \
-# RUN: | FileCheck -match-full-lines %s
+# RUN: | FileCheck -match-full-lines %s --dump-input-context=1000
#
# END.
@@ -24,4 +24,8 @@
# CHECK: PASS: shtest-cat :: cat.txt ({{[^)]*}})
# CHECK: cat {{.+}}/newline | FileCheck {{.*}}
# CHECK: # executed command: cat {{.*}}
-# CHECK: # executed command: FileCheck {{.*}}
\ No newline at end of file
+# CHECK: # executed command: FileCheck {{.*}}
+# CHECK: cat {{.+}}/allchars > {{.*}}
+# CHECK: # executed command: cat {{.*}}
+# CHECK: diff {{.+}}/allchars {{.*}}
+# CHECK: # executed command: diff {{.*}}
\ No newline at end of file
>From 08082d1c3248cebb050c2032701abb6711bb625b Mon Sep 17 00:00:00 2001
From: Connie Zhu <connieyzhu at google.com>
Date: Fri, 2 Aug 2024 21:29:32 +0000
Subject: [PATCH 5/5] [llvm-lit] Changed CHECK directives for more check
precision
Made changes to CHECK directives to check output more precisely.
---
.../lit/tests/Inputs/shtest-cat/cat-e.txt | 20 ++++++++--------
.../lit/tests/Inputs/shtest-cat/cat-v.txt | 4 ++--
.../utils/lit/tests/Inputs/shtest-cat/cat.txt | 2 +-
llvm/utils/lit/tests/shtest-cat.py | 24 +++++++++----------
4 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt
index 739e1a37a7f5e..21c36df3fb81c 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-e.txt
@@ -6,7 +6,7 @@
## Test output of -e for all ASCII characters in ^ and M- notation
# ALLCHARS: ^@^A^B^C^D^E^F^G^H
# ALLCHARS-SAME: $
-# ALLCHARS: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
+# ALLCHARS-NEXT: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
# ALLCHARS-SAME: ^[^\^]^^^_ !"#$%&'()*+,-./
# ALLCHARS-SAME: 0123456789
# ALLCHARS-SAME: :;<=>?@
@@ -25,12 +25,12 @@
## Test output of -e for new lines
# NEWLINE: first
-# NEWLINE: $
-# NEWLINE: $
-# NEWLINE: $
-# NEWLINE: $
-# NEWLINE: $
-# NEWLINE: $
-# NEWLINE: $
-# NEWLINE: $
-# NEWLINE: last
\ No newline at end of file
+# NEWLINE-NEXT: $
+# NEWLINE-NEXT: $
+# NEWLINE-NEXT: $
+# NEWLINE-NEXT: $
+# NEWLINE-NEXT: $
+# NEWLINE-NEXT: $
+# NEWLINE-NEXT: $
+# NEWLINE-NEXT: $
+# NEWLINE-NEXT: last
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt
index ac78eb4fd5f4c..47abae7dc5e5d 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat-v.txt
@@ -19,7 +19,7 @@
## Test output of -v for all ASCII characters in ^ and M- notation
# ALLCHARS: ^@^A^B^C^D^E^F^G^H
-# ALLCHARS: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
+# ALLCHARS-NEXT: ^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z
# ALLCHARS-SAME: ^[^\^]^^^_
# ALLCHARS-SAME: !"#$%&'()*+,-./
# ALLCHARS-SAME: 0123456789
@@ -47,4 +47,4 @@
# NEWLINE-EMPTY:
# NEWLINE-EMPTY:
# NEWLINE-EMPTY:
-# NEWLINE: last
\ No newline at end of file
+# NEWLINE-NEXT: last
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
index c8455d7c5dc3a..60bacce16df3d 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-cat/cat.txt
@@ -13,4 +13,4 @@
# NEWLINE-EMPTY:
# NEWLINE-EMPTY:
# NEWLINE-EMPTY:
-# NEWLINE: last
\ No newline at end of file
+# NEWLINE-NEXT: last
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/shtest-cat.py b/llvm/utils/lit/tests/shtest-cat.py
index e83484b1cb212..b22d2df0505d7 100644
--- a/llvm/utils/lit/tests/shtest-cat.py
+++ b/llvm/utils/lit/tests/shtest-cat.py
@@ -1,13 +1,13 @@
## Test the cat command
# RUN: not %{lit} -a -v %{inputs}/shtest-cat \
-# RUN: | FileCheck -match-full-lines %s --dump-input-context=1000
+# RUN: | FileCheck -match-full-lines %s
#
# END.
# CHECK: FAIL: shtest-cat :: cat-e.txt ({{[^)]*}})
# CHECK: cat -e {{.+}}/allchars | FileCheck {{.*}}
-# CHECK: # executed command: cat -e {{.*}}
+# CHECK: # executed command: cat -e {{.+}}/allchars
# CHECK: # | Unsupported: 'cat': option -e not recognized
# CHECK: # error: command failed with exit status: {{.*}}
# CHECK: # executed command: FileCheck {{.*}}
@@ -15,17 +15,17 @@
# CHECK: PASS: shtest-cat :: cat-v.txt ({{[^)]*}})
# CHECK: cat -v {{.+}}/allchars | FileCheck {{.*}}
-# CHECK: # executed command: cat -v {{.*}}
-# CHECK: # executed command: FileCheck {{.*}}
+# CHECK-NEXT: # executed command: cat -v {{.+}}/allchars
+# CHECK-NEXT: # executed command: FileCheck {{.*}}
# CHECK: cat -v {{.+}}/newline | FileCheck {{.*}}
-# CHECK: # executed command: cat -v {{.*}}
-# CHECK: # executed command: FileCheck {{.*}}
+# CHECK-NEXT: # executed command: cat -v {{.+}}/newline
+# CHECK-NEXT: # executed command: FileCheck {{.*}}
# CHECK: PASS: shtest-cat :: cat.txt ({{[^)]*}})
# CHECK: cat {{.+}}/newline | FileCheck {{.*}}
-# CHECK: # executed command: cat {{.*}}
-# CHECK: # executed command: FileCheck {{.*}}
-# CHECK: cat {{.+}}/allchars > {{.*}}
-# CHECK: # executed command: cat {{.*}}
-# CHECK: diff {{.+}}/allchars {{.*}}
-# CHECK: # executed command: diff {{.*}}
\ No newline at end of file
+# CHECK-NEXT: # executed command: cat {{.+}}/newline
+# CHECK-NEXT: # executed command: FileCheck {{.*}}
+# CHECK: cat {{.+}}/allchars > {{.+}}
+# CHECK-NEXT: # executed command: cat {{.+}}/allchars
+# CHECK: diff {{.+}}/allchars {{.+}}
+# CHECK-NEXT: # executed command: diff {{.+}}/allchars {{.+}}
\ No newline at end of file
More information about the llvm-commits
mailing list