Skip to content

Commit

Permalink
Improve pattern for FileCheck in UBSan's tests
Browse files Browse the repository at this point in the history
  • Loading branch information
operasfantom authored and ccadar committed Sep 14, 2022
1 parent 9b08202 commit 8ecf071
Show file tree
Hide file tree
Showing 32 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_alignment-assumption.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main() {

char *ptr = (char *)address;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: alignment-assumption
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: alignment-assumption
__builtin_assume_aligned(ptr, 0x8000);

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main() {

char *ptr = (char *)address;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: alignment-assumption
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: alignment-assumption
__builtin_assume_aligned(ptr, 0x8000, 1);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_alignment-type-mismatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main() {
char c[] __attribute__((aligned(8))) = {0, 0, 0, 0, 1, 2, 3, 4, 5};
int *p = (int *)&c[x];

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: misaligned-pointer-use
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: misaligned-pointer-use
result = *p;
return 0;
}
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_array_bounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
unsigned int array_index(unsigned int n) {
unsigned int a[4] = {0};

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: out-of-bounds-index
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: out-of-bounds-index
return a[n];
}

Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_bool.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main() {

klee_make_symbolic(&x, sizeof(x), "x");

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: load invalid value
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: load invalid value
result = *(_Bool *)&x;

return 0;
Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main() {

klee_make_symbolic(&x, sizeof(x), "x");

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: invalid-builtin-use
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: invalid-builtin-use
__builtin_ctz(x);
return 0;
}
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int main() {
for (unsigned char *p = (unsigned char *)&e; p != (unsigned char *)(&e + 1); ++p)
*p = x;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: load invalid value
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: load invalid value
result = (int)e != -1;

return 0;
Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_float_cast_overflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main() {

// klee_make_symbolic(&f, sizeof(f), "f");

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: float-cast-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: float-cast-overflow
result = f + 0x80;
return 0;
}
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_float_divide_by_zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ int main() {
// klee_make_symbolic(&x, sizeof(x), "x");
// klee_assume(x != 0.0);

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: float-divide-by-zero
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: float-divide-by-zero
volatile float result = x / 0;
}
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_implicit_integer_sign_change.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "klee/klee.h"

signed int convert_unsigned_int_to_signed_int(unsigned int x) {
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: implicit-integer-sign-change
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: implicit-integer-sign-change
return x;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "klee/klee.h"

unsigned char convert_signed_int_to_unsigned_char(signed int x) {
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: implicit-signed-integer-truncation
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: implicit-signed-integer-truncation
return x;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "klee/klee.h"

unsigned char convert_unsigned_int_to_unsigned_char(unsigned int x) {
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: implicit-unsigned-integer-truncation
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: implicit-unsigned-integer-truncation
return x;
}

Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_integer_divide_by_zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main() {

klee_make_symbolic(&x, sizeof(x), "x");

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: integer division overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: integer division overflow
result = x / 0;
return 0;
}
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_nonnull_attribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int main() {
int local = 0;
int *arg = null ? 0x0 : &local;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: invalid-null-argument
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: invalid-null-argument
result = func(arg);
return 0;
}
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main() {
int local = 0;
int *arg = null ? 0x0 : &local;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: null-pointer-use
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: null-pointer-use
result = *arg;
return 0;
}
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_nullability_arg.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main() {

int local = 0;
int *arg = null ? 0x0 : &local;
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: invalid-null-argument
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: invalid-null-argument
nonnull_arg(arg);
return 0;
}
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_nullability_assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

void nonnull_assign(int *p) {
volatile int *_Nonnull local;
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: null-pointer-use
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: null-pointer-use
local = p;
}

Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_nullability_return.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "klee/klee.h"

int *_Nonnull nonnull_retval(int *p) {
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: invalid-null-return
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: invalid-null-return
return p;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main() {

char *ptr = (char *)address;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: pointer-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: pointer-overflow
result = ptr + 1;
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main() {

char *ptr = (char *)address;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: nullptr-after-nonzero-offset
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: nullptr-after-nonzero-offset
result = ptr + 1;
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main() {

char *ptr = (char *)address;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: nullptr-with-nonzero-offset
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: nullptr-with-nonzero-offset
result = ptr + 1;
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main() {

char *ptr = (char *)address;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: nullptr-with-offset
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: nullptr-with-offset
result = ptr + 0;
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int main() {
klee_make_symbolic(&offset, sizeof(offset), "offset");
klee_assume((size_t)(ptr) + offset != 0);

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: pointer-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: pointer-overflow
result = ptr + offset;

return 0;
Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_return.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "klee/klee.h"

int no_return() {
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: missing-return
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: missing-return
}

int main() {
Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_returns_nonnull_attribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "klee/klee.h"

__attribute__((returns_nonnull)) char *foo(char *a) {
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: invalid-null-return
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: invalid-null-return
return a;
}

Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_shift_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "klee/klee.h"

int lsh_overflow(signed int a, signed int b) {
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: shift out of bounds
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: shift out of bounds
return a << b;
}

Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_shift_exponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "klee/klee.h"

int rsh_inbounds(signed int a, signed int b) {
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: shift out of bounds
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: shift out of bounds
return a >> b;
}

Expand Down
8 changes: 4 additions & 4 deletions test/Feature/ubsan/ubsan_signed_integer_overflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ int main() {
klee_make_symbolic(&x, sizeof(x), "x");
klee_make_symbolic(&y, sizeof(y), "y");

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: signed-integer-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: signed-integer-overflow
result = x + y;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: signed-integer-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: signed-integer-overflow
result = x - y;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: signed-integer-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: signed-integer-overflow
result = x * y;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: signed-integer-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: signed-integer-overflow
result = -x;

return 0;
Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_unreachable.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "klee/klee.h"

void _Noreturn f() {
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: unreachable-call
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: unreachable-call
__builtin_unreachable();
}

Expand Down
8 changes: 4 additions & 4 deletions test/Feature/ubsan/ubsan_unsigned_integer_overflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ int main() {
klee_make_symbolic(&x, sizeof(x), "x");
klee_make_symbolic(&y, sizeof(y), "y");

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: unsigned-integer-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: unsigned-integer-overflow
result = x + y;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: unsigned-integer-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: unsigned-integer-overflow
result = x - y;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: unsigned-integer-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: unsigned-integer-overflow
result = x * y;

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: unsigned-integer-overflow
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: unsigned-integer-overflow
result = -x;

return 0;
Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_unsigned_shift_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "klee/klee.h"

int lsh_overflow(unsigned int a, unsigned int b) {
// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: shift out of bounds
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: shift out of bounds
return a << b;
}

Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ubsan/ubsan_vla_bound.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main() {

x = klee_range(-10, 10, "x");

// CHECK: runtime/Sanitizer/ubsan/ubsan_handlers.cpp:35: non-positive-vla-index
// CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:34: non-positive-vla-index
int arr[x];
result = arr[0];
return 0;
Expand Down

0 comments on commit 8ecf071

Please sign in to comment.