Commit 41e3e080 authored by Christian Dietrich's avatar Christian Dietrich
Browse files

run-tests: add assert-ast and assert-obj flags

parent a30e8696
......@@ -17,7 +17,7 @@ extern int docd(const char *, int);
#include <unistd.h>
static int
int
cdcmd(int argc, char **argv)
{
const char *dest;
......@@ -41,7 +41,7 @@ cdcmd(int argc, char **argv)
goto step7;
if (*dest == '.') {
c = dest[1];
dotdot:
{{A}} dotdot:
switch (c) {
case '\0':
case '/':
......@@ -58,7 +58,9 @@ cdcmd(int argc, char **argv)
if (!path) {
step6:
step7:
p = dest;
{{B}} dotdot:
p = dest;
goto docd;
}
do {
......@@ -80,7 +82,7 @@ cdcmd(int argc, char **argv)
out1fmt("%s\n", curdir);
return 0;
}
{{A}}
/*
* check-name: complex stuff once failed
* check-name: Forward and backward gotos
* assert-obj: A != B
*/
void cdcmd(void)
{
const char *dest;
const char *dest; {{A}}
const char * const dest; {{B}}
char c;
c = dest[2];
}
{{A}}
/*
* check-name: qualifiers in subtype
* obj-not-diff: maybe
* assert-ast: A != B
*/
......@@ -6,5 +6,5 @@ int f(){
}
/*
* check-name: Initlist array access
* B != A
* assert-ast: A != B
*/
......@@ -4,5 +4,5 @@ int a = 0x4711; {{C}}
/*
* check-name: oktal,...
* B != A, B != C, A != C
* assert-obj: B != A, B != C, A != C
*/
......@@ -7,5 +7,5 @@ void f(){
}
/*
* check-name: NOT, L_NOT
* B != A, B != C, C != A
* assert-obj: B != A, B != C, C != A
*/
......@@ -9,5 +9,6 @@ int foo() {
/*
* check-name: Include with function extern
* obj-not-diff: void parameter != no parameter
* B == A
* assert-ast: A != B
* assert-obj: A == B
*/
......@@ -145,6 +145,34 @@ def get_variants(test_case):
variants[variant] = "\n".join(text)
return variants
def check_asserts(asserts, results, idx):
asserts = [x.strip() for x in asserts.split(",")]
failed = False
output = ""
for A in asserts:
if "==" in A:
(LHS, RHS) = A.split("==")
LHS = results[LHS.strip()][idx]
RHS = results[RHS.strip()][idx]
if LHS != RHS:
output += COLOR.format(" ASSERT", "red", True) + " failed: " + A + "\n"
failed = True
elif LOGLEVEL >= LOGLEVEL_DEBUG:
output += COLOR.format(" ASSERT", "green") + " holds: %s\n" % A
elif "!=" in A:
(LHS, RHS) = A.split("!=")
LHS = results[LHS.strip()][idx]
RHS = results[RHS.strip()][idx]
if LHS == RHS:
output += COLOR.format(" ASSERT", "red", True) + " failed: " + A + "\n"
failed = True
elif LOGLEVEL >= LOGLEVEL_DEBUG:
output += COLOR.format(" ASSERT", "green") + " holds: %s\n" % A
else:
assert False, "Invalid assert: " + A
return failed, output
def run_testcase_cleaner(basename):
cruftfiles=list()
......@@ -286,6 +314,18 @@ def run_testcase_helper(test_case, check_name, future):
failed = True
assert_ast = get_tag(test_case, "assert-ast")
assert_obj = get_tag(test_case, "assert-obj")
if assert_obj:
(F, out) = check_asserts(assert_obj, results, 0)
failed = failed or F
output += out
if assert_ast:
(F, out) = check_asserts(assert_ast, results, 1)
failed = failed or F
output += out
if failed:
output += " Failed\n"
......@@ -380,6 +420,9 @@ if __name__ == '__main__':
print "unkown option"
assert False
if len(args) == 0:
args = ["."]
ret = run_test_suite(get_testcases(args))
if ret:
......
......@@ -13,5 +13,5 @@ void foo() {
* check-name: internal linkage name changes
* compile-command: /usr/bin/gcc
* compile-flags: -fdata-sections -Wall
* B == A
* assert-ast: A == B
*/
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment