summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-rc
diff options
context:
space:
mode:
authorMarek Sokolowski <mnbvmar@gmail.com>2017-08-18 18:24:17 +0000
committerMarek Sokolowski <mnbvmar@gmail.com>2017-08-18 18:24:17 +0000
commit5cd3d5c8d63bd1070da792fe06b4dc4401a20d06 (patch)
tree0cc4934fe093d2fa790c8a88b38b6e18b5ee1e9e /llvm/test/tools/llvm-rc
parent291d658e1923e7a1f0fcecb07115a788d0bea4a7 (diff)
downloadbcm5719-llvm-5cd3d5c8d63bd1070da792fe06b4dc4401a20d06.tar.gz
bcm5719-llvm-5cd3d5c8d63bd1070da792fe06b4dc4401a20d06.zip
Reapply: [llvm-rc] Add basic RC scripts parsing ability.
As for now, the parser supports a limited set of statements and resources. This will be extended in the following patches. Thanks to Nico Weber (thakis) for his original work in this area. This patch was originally submitted as r311175 and got reverted in r311177 because of the problems with compilation under gcc. Differential Revision: https://reviews.llvm.org/D36340 llvm-svn: 311184
Diffstat (limited to 'llvm/test/tools/llvm-rc')
-rw-r--r--llvm/test/tools/llvm-rc/Inputs/parser-correct-everything.rc15
-rw-r--r--llvm/test/tools/llvm-rc/Inputs/parser-eof.rc1
-rw-r--r--llvm/test/tools/llvm-rc/Inputs/parser-language-no-comma.rc1
-rw-r--r--llvm/test/tools/llvm-rc/Inputs/parser-language-too-many-commas.rc1
-rw-r--r--llvm/test/tools/llvm-rc/Inputs/parser-no-characteristics-arg.rc5
-rw-r--r--llvm/test/tools/llvm-rc/Inputs/parser-nonsense-token.rc1
-rw-r--r--llvm/test/tools/llvm-rc/Inputs/parser-nonsense-type-eof.rc1
-rw-r--r--llvm/test/tools/llvm-rc/Inputs/parser-nonsense-type.rc1
-rw-r--r--llvm/test/tools/llvm-rc/Inputs/parser-stringtable-no-string.rc6
-rw-r--r--llvm/test/tools/llvm-rc/Inputs/parser-stringtable-weird-option.rc4
-rw-r--r--llvm/test/tools/llvm-rc/parser.test67
-rw-r--r--llvm/test/tools/llvm-rc/tokenizer.test4
12 files changed, 106 insertions, 1 deletions
diff --git a/llvm/test/tools/llvm-rc/Inputs/parser-correct-everything.rc b/llvm/test/tools/llvm-rc/Inputs/parser-correct-everything.rc
new file mode 100644
index 00000000000..6337a369fe6
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/Inputs/parser-correct-everything.rc
@@ -0,0 +1,15 @@
+meh IcOn "hello.bmp"
+Icon Icon "Icon"
+
+LANGUAGE 5, 12
+
+STRINGTABLE
+LANGUAGE 1, 1
+CHARACTERISTICS 500
+LANGUAGE 3, 4
+VERSION 14
+{
+ 1 "hello"
+ 2 "world"
+}
+STRINGTABLE BEGIN END
diff --git a/llvm/test/tools/llvm-rc/Inputs/parser-eof.rc b/llvm/test/tools/llvm-rc/Inputs/parser-eof.rc
new file mode 100644
index 00000000000..8a70c88e975
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/Inputs/parser-eof.rc
@@ -0,0 +1 @@
+LANGUAGE
diff --git a/llvm/test/tools/llvm-rc/Inputs/parser-language-no-comma.rc b/llvm/test/tools/llvm-rc/Inputs/parser-language-no-comma.rc
new file mode 100644
index 00000000000..9d875636680
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/Inputs/parser-language-no-comma.rc
@@ -0,0 +1 @@
+LANGUAGE 5 7
diff --git a/llvm/test/tools/llvm-rc/Inputs/parser-language-too-many-commas.rc b/llvm/test/tools/llvm-rc/Inputs/parser-language-too-many-commas.rc
new file mode 100644
index 00000000000..2b46d07e083
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/Inputs/parser-language-too-many-commas.rc
@@ -0,0 +1 @@
+LANGUAGE 5,, 7
diff --git a/llvm/test/tools/llvm-rc/Inputs/parser-no-characteristics-arg.rc b/llvm/test/tools/llvm-rc/Inputs/parser-no-characteristics-arg.rc
new file mode 100644
index 00000000000..993f854419e
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/Inputs/parser-no-characteristics-arg.rc
@@ -0,0 +1,5 @@
+STRINGTABLE
+CHARACTERISTICS
+BEGIN
+ 100 "No integer after CHARACTERISTICS."
+END
diff --git a/llvm/test/tools/llvm-rc/Inputs/parser-nonsense-token.rc b/llvm/test/tools/llvm-rc/Inputs/parser-nonsense-token.rc
new file mode 100644
index 00000000000..6586b2fb395
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/Inputs/parser-nonsense-token.rc
@@ -0,0 +1 @@
+& ICON "WeirdResourceName.ico"
diff --git a/llvm/test/tools/llvm-rc/Inputs/parser-nonsense-type-eof.rc b/llvm/test/tools/llvm-rc/Inputs/parser-nonsense-type-eof.rc
new file mode 100644
index 00000000000..e427984d4a2
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/Inputs/parser-nonsense-type-eof.rc
@@ -0,0 +1 @@
+HELLO
diff --git a/llvm/test/tools/llvm-rc/Inputs/parser-nonsense-type.rc b/llvm/test/tools/llvm-rc/Inputs/parser-nonsense-type.rc
new file mode 100644
index 00000000000..4e3dffe834a
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/Inputs/parser-nonsense-type.rc
@@ -0,0 +1 @@
+HELLO WORLD
diff --git a/llvm/test/tools/llvm-rc/Inputs/parser-stringtable-no-string.rc b/llvm/test/tools/llvm-rc/Inputs/parser-stringtable-no-string.rc
new file mode 100644
index 00000000000..10a8f652933
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/Inputs/parser-stringtable-no-string.rc
@@ -0,0 +1,6 @@
+STRINGTABLE
+VERSION 8
+{
+ 1 "hello"
+ 2
+}
diff --git a/llvm/test/tools/llvm-rc/Inputs/parser-stringtable-weird-option.rc b/llvm/test/tools/llvm-rc/Inputs/parser-stringtable-weird-option.rc
new file mode 100644
index 00000000000..ecbb018196f
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/Inputs/parser-stringtable-weird-option.rc
@@ -0,0 +1,4 @@
+STRINGTABLE
+NONSENSETYPE 12 34
+BEGIN
+END
diff --git a/llvm/test/tools/llvm-rc/parser.test b/llvm/test/tools/llvm-rc/parser.test
new file mode 100644
index 00000000000..40b66da88fb
--- /dev/null
+++ b/llvm/test/tools/llvm-rc/parser.test
@@ -0,0 +1,67 @@
+; RUN: llvm-rc /V %p/Inputs/parser-correct-everything.rc | FileCheck %s --check-prefix PGOOD
+
+; PGOOD: Icon (meh): "hello.bmp"
+; PGOOD-NEXT: Icon (Icon): "Icon"
+; PGOOD-NEXT: Language: 5, Sublanguage: 12
+; PGOOD-NEXT: StringTable:
+; PGOOD-NEXT: Option: Language: 1, Sublanguage: 1
+; PGOOD-NEXT: Option: Characteristics: 500
+; PGOOD-NEXT: Option: Language: 3, Sublanguage: 4
+; PGOOD-NEXT: Option: Version: 14
+; PGOOD-NEXT: 1 => "hello"
+; PGOOD-NEXT: 2 => "world"
+; PGOOD-NEXT: StringTable:
+
+
+; RUN: not llvm-rc /V %p/Inputs/parser-stringtable-no-string.rc 2> %t2
+; RUN: FileCheck %s --check-prefix PSTRINGTABLE1 --input-file %t2
+
+; PSTRINGTABLE1: llvm-rc: Error parsing file: expected string, got }
+
+
+; RUN: not llvm-rc /V %p/Inputs/parser-stringtable-weird-option.rc 2> %t3
+; RUN: FileCheck %s --check-prefix PSTRINGTABLE2 --input-file %t3
+
+; PSTRINGTABLE2: llvm-rc: Error parsing file: expected optional statement type, BEGIN or '{', got NONSENSETYPE
+
+
+; RUN: not llvm-rc /V %p/Inputs/parser-eof.rc 2> %t4
+; RUN: FileCheck %s --check-prefix PEOF --input-file %t4
+
+; PEOF: llvm-rc: Error parsing file: expected integer, got <EOF>
+
+
+; RUN: not llvm-rc /V %p/Inputs/parser-no-characteristics-arg.rc 2> %t5
+; RUN: FileCheck %s --check-prefix PCHARACTERISTICS1 --input-file %t5
+
+; PCHARACTERISTICS1: llvm-rc: Error parsing file: expected integer, got BEGIN
+
+
+; RUN: not llvm-rc /V %p/Inputs/parser-nonsense-token.rc 2> %t6
+; RUN: FileCheck %s --check-prefix PNONSENSE1 --input-file %t6
+
+; PNONSENSE1: llvm-rc: Error parsing file: expected int or identifier, got &
+
+
+; RUN: not llvm-rc /V %p/Inputs/parser-nonsense-type.rc 2> %t7
+; RUN: FileCheck %s --check-prefix PNONSENSE2 --input-file %t7
+
+; PNONSENSE2: llvm-rc: Error parsing file: expected resource type, got WORLD
+
+
+; RUN: not llvm-rc /V %p/Inputs/parser-nonsense-type-eof.rc 2> %t8
+; RUN: FileCheck %s --check-prefix PNONSENSE3 --input-file %t8
+
+; PNONSENSE3: llvm-rc: Error parsing file: expected int or identifier, got <EOF>
+
+
+; RUN: not llvm-rc /V %p/Inputs/parser-language-no-comma.rc 2> %t9
+; RUN: FileCheck %s --check-prefix PLANGUAGE1 --input-file %t9
+
+; PLANGUAGE1: llvm-rc: Error parsing file: expected ',', got 7
+
+
+; RUN: not llvm-rc /V %p/Inputs/parser-language-too-many-commas.rc 2> %t10
+; RUN: FileCheck %s --check-prefix PLANGUAGE2 --input-file %t10
+
+; PLANGUAGE2: llvm-rc: Error parsing file: expected integer, got ,
diff --git a/llvm/test/tools/llvm-rc/tokenizer.test b/llvm/test/tools/llvm-rc/tokenizer.test
index 789b313efad..08c01a2fe73 100644
--- a/llvm/test/tools/llvm-rc/tokenizer.test
+++ b/llvm/test/tools/llvm-rc/tokenizer.test
@@ -1,4 +1,6 @@
-; RUN: llvm-rc /V %p/Inputs/tokens.rc | FileCheck %s
+; RUN: not llvm-rc /V %p/Inputs/tokens.rc | FileCheck %s
+; llvm-rc fails now on this sample because it is an invalid resource file
+; script. We silence the error message and just analyze the output.
; CHECK: Int: 1; int value = 1
; CHECK-NEXT: Plus: +
OpenPOWER on IntegriCloud