Home | History | Annotate | Download | only in Linux
      1 // Test the handle_sigfpe option.
      2 // RUN: %clang %s -o %t
      3 // RUN:                               not         %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s
      4 // RUN: %env_tool_opts=handle_sigfpe=0 not --crash %run %t 2>&1 | FileCheck --check-prefix=CHECK0 %s
      5 // RUN: %env_tool_opts=handle_sigfpe=1 not         %run %t 2>&1 | FileCheck --check-prefix=CHECK1 %s
      6 // FIXME: implement in other sanitizers, not just asan.
      7 // XFAIL: msan
      8 // XFAIL: lsan
      9 // XFAIL: tsan
     10 //
     11 // FIXME: seems to fail on ARM
     12 // REQUIRES: x86_64-supported-target
     13 #include <assert.h>
     14 #include <stdio.h>
     15 #include <sanitizer/asan_interface.h>
     16 
     17 void death() {
     18   fprintf(stderr, "DEATH CALLBACK\n");
     19 }
     20 
     21 int main(int argc, char **argv) {
     22   __sanitizer_set_death_callback(death);
     23   volatile int one = 1;
     24   volatile int zero = 0;
     25   volatile int sink;
     26   sink = one / zero;
     27 }
     28 // CHECK1: ERROR: {{.*}}Sanitizer:
     29 // CHECK1: DEATH CALLBACK
     30 // CHECK0-NOT: Sanitizer
     31