[Mesa-dev] [PATCH 6/6] glsl/glcpp: Add testing to ensure illegal characters generate errors

Carl Worth cworth at cworth.org
Tue Aug 5 16:33:07 PDT 2014


This mostly-exhaustive test ensures that the illegal-character error
implemented in the previous commit is actually generated for most every
illegal character.
---
 src/glsl/glcpp/tests/141-illegal-characters.c      |  99 +++++++++++++
 .../glcpp/tests/141-illegal-characters.c.expected  | 165 +++++++++++++++++++++
 2 files changed, 264 insertions(+)
 create mode 100644 src/glsl/glcpp/tests/141-illegal-characters.c
 create mode 100644 src/glsl/glcpp/tests/141-illegal-characters.c.expected

diff --git a/src/glsl/glcpp/tests/141-illegal-characters.c b/src/glsl/glcpp/tests/141-illegal-characters.c
new file mode 100644
index 0000000..0ea227e
--- /dev/null
+++ b/src/glsl/glcpp/tests/141-illegal-characters.c
@@ -0,0 +1,99 @@
+/* After subtracting out the legal characters (see test
+ * 140-legal-characters.c), any other possible character must be
+ * illegal. That leaves:
+ *
+ * Illegal in all contexts:
+ *
+ *      0x00 - 0x08 (^@ - ^H)
+ *      0x0E - 0x1F (^N - ^Z, ^[, ^\, ^], ^^, ^_)
+ *      0x22 (")
+ *      0x24 ($)
+ *      0x27 (')
+ *      0x40 (@)
+ *      0x60 (`)
+ *      0x7F (DEL or ^?)
+ *      0x80 - 0xFF (non-ASCII)
+ *
+ * Illegal in some contexts:
+ *
+ *      0x23 (#), not introducting a directive, not as part of past operator
+ *      0x5C (\), not as last character of a line
+ *
+ * This file tests at least one occurence of most of the above
+ * characters. The exceptions are:
+ *
+ * 0x00: This character would be tricky to test. The calling
+ *        convention of bison to the lexer is such that a return value
+ *        of 0 indicates end-of-file. So without any direct support
+ *        for the 0x00 character, it is being interpreted as
+ *        end-of-file. This semms legitimate enough, (since the 0x00
+ *        character is illegal).
+ *
+ * 0x80 -0xFF: Only 25% of these characters are represented here.
+ */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+"
+$
+'
+@
+`
+
+€
+
+Ž
+
+
+‘
+ž
+Ÿ
+ 
+¡
+®
+¯
+°
+±
+¾
+¿
+À
+Á
+Î
+Ï
+Ð
+Ñ
+Þ
+ß
+à
+á
+î
+ï
+ð
+ñ
+þ
+ÿ
+.#.
+.\.
diff --git a/src/glsl/glcpp/tests/141-illegal-characters.c.expected b/src/glsl/glcpp/tests/141-illegal-characters.c.expected
new file mode 100644
index 0000000..ef89400
--- /dev/null
+++ b/src/glsl/glcpp/tests/141-illegal-characters.c.expected
@@ -0,0 +1,165 @@
+0:34(1): preprocessor error: Illegal character ''
+0:35(1): preprocessor error: Illegal character ''
+0:36(1): preprocessor error: Illegal character ''
+0:37(1): preprocessor error: Illegal character ''
+0:38(1): preprocessor error: Illegal character ''
+0:39(1): preprocessor error: Illegal character ''
+0:40(1): preprocessor error: Illegal character ''
+0:41(1): preprocessor error: Illegal character ''
+0:42(1): preprocessor error: Illegal character ''
+0:43(1): preprocessor error: Illegal character ''
+0:44(1): preprocessor error: Illegal character ''
+0:45(1): preprocessor error: Illegal character ''
+0:46(1): preprocessor error: Illegal character ''
+0:47(1): preprocessor error: Illegal character ''
+0:48(1): preprocessor error: Illegal character ''
+0:49(1): preprocessor error: Illegal character ''
+0:50(1): preprocessor error: Illegal character ''
+0:51(1): preprocessor error: Illegal character ''
+0:52(1): preprocessor error: Illegal character ''
+0:53(1): preprocessor error: Illegal character ''
+0:54(1): preprocessor error: Illegal character ''
+0:55(1): preprocessor error: Illegal character ''
+0:56(1): preprocessor error: Illegal character ''
+0:57(1): preprocessor error: Illegal character ''
+0:58(1): preprocessor error: Illegal character ''
+0:59(1): preprocessor error: Illegal character ''
+0:60(1): preprocessor error: Illegal character '"'
+0:61(1): preprocessor error: Illegal character '$'
+0:62(1): preprocessor error: Illegal character '''
+0:63(1): preprocessor error: Illegal character '@'
+0:64(1): preprocessor error: Illegal character '`'
+0:65(1): preprocessor error: Illegal character ''
+0:66(1): preprocessor error: Illegal character '€'
+0:67(1): preprocessor error: Illegal character ''
+0:68(1): preprocessor error: Illegal character 'Ž'
+0:69(1): preprocessor error: Illegal character ''
+0:70(1): preprocessor error: Illegal character ''
+0:71(1): preprocessor error: Illegal character '‘'
+0:72(1): preprocessor error: Illegal character 'ž'
+0:73(1): preprocessor error: Illegal character 'Ÿ'
+0:74(1): preprocessor error: Illegal character ' '
+0:75(1): preprocessor error: Illegal character '¡'
+0:76(1): preprocessor error: Illegal character '®'
+0:77(1): preprocessor error: Illegal character '¯'
+0:78(1): preprocessor error: Illegal character '°'
+0:79(1): preprocessor error: Illegal character '±'
+0:80(1): preprocessor error: Illegal character '¾'
+0:81(1): preprocessor error: Illegal character '¿'
+0:82(1): preprocessor error: Illegal character 'À'
+0:83(1): preprocessor error: Illegal character 'Á'
+0:84(1): preprocessor error: Illegal character 'Î'
+0:85(1): preprocessor error: Illegal character 'Ï'
+0:86(1): preprocessor error: Illegal character 'Ð'
+0:87(1): preprocessor error: Illegal character 'Ñ'
+0:88(1): preprocessor error: Illegal character 'Þ'
+0:89(1): preprocessor error: Illegal character 'ß'
+0:90(1): preprocessor error: Illegal character 'à'
+0:91(1): preprocessor error: Illegal character 'á'
+0:92(1): preprocessor error: Illegal character 'î'
+0:93(1): preprocessor error: Illegal character 'ï'
+0:94(1): preprocessor error: Illegal character 'ð'
+0:95(1): preprocessor error: Illegal character 'ñ'
+0:96(1): preprocessor error: Illegal character 'þ'
+0:97(1): preprocessor error: Illegal character 'ÿ'
+0:98(2): preprocessor error: Illegal character '#' (not a preprocessing directive)
+0:99(2): preprocessor error: Illegal character '\'
+ 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+..
+..
-- 
2.0.0



More information about the mesa-dev mailing list