2 /* Test simple use of the disable/enable macros. */
7 #include "../include/valgrind.h"
11 __attribute__((noinline
)) void usechar ( char c
)
13 // Spook gcc into believing mysterious bad things are
14 // happening behind its back, and that 'c' is definitely
15 // used in some (unknown) way.
16 __asm__
__volatile__("" : : "r"(c
) : "memory","cc");
19 __attribute__((noinline
)) void err ( void )
29 fprintf(stderr
, "\n--------- SIMPLE TEST ---------\n\n");
30 fprintf(stderr
, "\n--------- enabled (expect 1) ---------\n\n");
34 fprintf(stderr
, "\n--------- disabled (expect 0) ---------\n\n");
35 VALGRIND_DISABLE_ERROR_REPORTING
;
39 fprintf(stderr
, "\n--------- re-enabled (expect 1) ---------\n\n");
40 VALGRIND_ENABLE_ERROR_REPORTING
;
46 fprintf(stderr
, "\n--------- MULTI-LEVEL TEST (expect 2) ---------\n\n");
49 VALGRIND_DISABLE_ERROR_REPORTING
;
50 VALGRIND_DISABLE_ERROR_REPORTING
;
51 VALGRIND_DISABLE_ERROR_REPORTING
;
52 VALGRIND_DISABLE_ERROR_REPORTING
; // lev = 4
54 // now gradually undo them until an error appears
57 VALGRIND_ENABLE_ERROR_REPORTING
; // lev = 3
60 VALGRIND_ENABLE_ERROR_REPORTING
; // lev = 2
63 VALGRIND_ENABLE_ERROR_REPORTING
; // lev = 1
66 VALGRIND_ENABLE_ERROR_REPORTING
; // lev = 0
69 VALGRIND_ENABLE_ERROR_REPORTING
; // lev = 0 (won't go down further)
72 fprintf(stderr
, "\n--------- MULTI-LEVEL TEST end ---------\n\n");