blob: 15b8b09b33cba0dda0e412a1e7c2bcff707e5043 [file] [log] [blame]
Andres Amaya Garciaf2d17922017-10-24 22:47:14 +01001# test_zeroize.gdb
2#
3# This file is part of mbed TLS (https://tls.mbed.org)
4#
5# Copyright (c) 2017, ARM Limited, All Rights Reserved
6#
7# Purpose
8#
9# Run a test using the debugger to check that the mbedtls_zeroize() function in
10# utils.h is not being optimized out by the compiler. To do so, the script
11# loads the test program at programs/test/zeroize.c and sets a breakpoint at
12# the last return statement in the main(). When the breakpoint is hit, the
13# debugger manually checks the contents to be zeroized and checks that it is
14# actually cleared.
15#
16# Note: This test requires that the test program is compiled with -g3.
17
Andres Amaya Garciaddebc492017-10-24 22:16:34 +010018set confirm off
19file ./programs/test/zeroize
Andres Amaya Garcia7111a0d2017-10-31 21:28:31 +000020break zeroize.c:90
Andres Amaya Garciaddebc492017-10-24 22:16:34 +010021
22set args ./programs/test/zeroize.c
23run
24
25set $i = 0
26set $len = sizeof(buf)
27set $buf = buf
28
29if exit_code != 0
30 echo The program did not terminate correctly\n
31 quit 1
32end
33
34while $i < $len
35 if $buf[$i++] != 0
36 echo The buffer at was not zeroized\n
37 quit 1
38 end
39end
40
41echo The buffer was correctly zeroized\n
42quit 0