From: Reid Spencer
Below is an example of legal RUN lines in a .ll file:
++ ; RUN: llvm-as < %s | llvm-dis > %t1 + ; RUN: llvm-dis < %s.bc-13 > %t2 + ; RUN: diff %t1 %t2 ++
As with a Unix shell, the RUN: lines permit pipelines and I/O redirection to be used. However, the usage is slightly different than for Bash. To check what's legal, see the documentation for the @@ -341,12 +348,47 @@ location of these external programs is configured by the llvm-test shouldn't use that here. -
Below is an example of legal RUN lines in a .ll file:
+There are some quoting rules that you must pay attention to when writing + your RUN lines. In general nothing needs to be quoted. Tcl won't strip off any + ' or " so they will get passed to the invoked program. For example:
- ; RUN: llvm-as < %s | llvm-dis > %t1 - ; RUN: llvm-dis < %s.bc-13 > %t2 - ; RUN: diff %t1 %t2 + ... | grep 'find this string'+
This will fail because the ' characters are passed to grep. This would + instruction grep to look for 'find in the files this and + string'. To avoid this use curly braces to tell Tcl that it should + treat everything enclosed as one value. So our example would become:
++ ... | grep {find this string} ++
Additionally, the characters [ and ] are treated + specially by Tcl. They tell Tcl to interpret the content as a command to + execute. Since these characters are often used in regular expressions this can + have disastrous results and cause the entire test run in a directory to fail. + For example, a common idiom is to look for some basicblock number:
++ ... | grep bb[2-8] ++
This, however, will cause Tcl to fail because its going to try to execute + a program named "2-8". Instead, what you want is this:
++ ... | grep {bb\[2-8\]} ++
Finally, if you need to pass the \ character down to a program, + then it must be doubled. This is another Tcl special character. So, suppose + you had: +
+ ... | grep 'i32\*' ++
This will fail to match what you want (a pointer to i32). First, the + ' do not get stripped off. Second, the \ gets stripped off + by Tcl so what grep sees is: 'i32*'. That's not likely to match + anything. To resolve this you must use \\ and the {}, like + this:
++ ... | grep {i32\\*} ++