Commit ae2e6bc9 authored by Moritz Koenig's avatar Moritz Koenig
Browse files

Merge branch 'master' of gitlab.cs.fau.de:stettberger/clang-hash

parents dd69af56 41e3e080
......@@ -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"
......@@ -336,15 +376,22 @@ def usage():
print "%s [-c] [-t threads] [-q] [-v] [test-cases...]" % sys.argv[0]
print " if no test-cases are given, all in current directory are run"
def get_testcases():
def get_testcases(paths = ["."]):
all_files = []
for root, subFolders, files in os.walk("."):
for file in files:
path = os.path.join(root, file)
if fnmatch.fnmatch(path, testcase_pattern) and not "var.c" in file:
all_files.append(path)
for path in paths:
if os.path.isfile(path):
all_files.append(path)
else:
for root, subFolders, files in os.walk(path):
for file in files:
path = os.path.join(root, file)
all_files.append(path)
ret = []
for fn in all_files:
if fnmatch.fnmatch(fn, testcase_pattern) and not "var.c" in fn:
ret.append(fn)
return sorted(all_files)
return sorted(ret)
if __name__ == '__main__':
opts, args = getopt.getopt(sys.argv[1:], "ht:qcv")
......@@ -373,10 +420,10 @@ if __name__ == '__main__':
print "unkown option"
assert False
if len(args) > 0:
ret = run_test_suite(args)
else:
ret = run_test_suite(get_testcases())
if len(args) == 0:
args = ["."]
ret = run_test_suite(get_testcases(args))
if ret:
sys.exit(0)
......
......@@ -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