Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test_code += ["#include <stdlib.h>"]
- test_code += ["#define STR_(x) #x"]
- test_code += ["#define STR(x) STR_(x)"]
- test_code += [
- "#define TEST(lhs, rhs) if(lhs(val8, lb8, sz8) != rhs(val8, lb8, sz8)) { fprintf(stderr, \"%s != %s (%d vs %d) -- %d/%d/%d\\n\", STR(lhs), STR(rhs), lhs(val8, lb8, sz8), rhs(val8, lb8, sz8), val, lb, ub); return 1; }"
- ]
- for pf in prefixes:
- for decl in pf[2]:
- test_code += [
- "extern _Bool {}(unsigned char, unsigned char, unsigned char);".
- format(decl)
- ]
- test_code += ["int main() {"]
- test_code += ["unsigned val, lb, ub;"]
- test_code += ["for(val = 0; val < 256; ++val) {"]
- test_code += ["for(lb = 0; lb < 256; ++lb) {"]
- test_code += ["for(ub = lb; ub < 256; ++ub) {"]
- test_code += ["unsigned char val8, lb8, sz8;"]
- test_code += ["val8 = val; lb8 = lb; sz8 = ub - lb;"]
- num_decls = len(prefixes[0][2])
- for i in range(0, num_decls):
- test_code += ["TEST({}, {});".format(prefixes[0][2][i], prefixes[1][2][i])]
- test_code += ["}}}"]
- test_code += ["fprintf(stderr, \"Success!\\n\");"]
- test_code += ["return 0; }"]
- f = open("test-bounds.c", "w+")
- f.write("\n".join(test_code))
- f.close()
- assert os.system("ninja") == 0
- assert os.system(
- "{} -filetype=obj -O3 -mcpu=native test-new.ll -o test-new.o".format(
- new_llc)) == 0
- assert os.system(
- "llc -filetype=obj -O3 -mcpu=native test-old.ll -o test-old.o") == 0
- assert os.system("clang -O3 -c test-bounds.c -o test-bounds.o") == 0
- assert os.system(
- "clang test-bounds.o test-new.o test-old.o -o bounds-test") == 0
- assert os.system("./bounds-test") == 0
Advertisement
Add Comment
Please, Sign In to add comment