File: 039_debug

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (71 lines) | stat: -rwxr-xr-x 1,718 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash

set -e 
$PREPARE_DEFAULT > /dev/null
$INCLUDE_FUNCS
cd $WC

if [[ "$opt_DEBUG" != "1" ]]
then
# This test will run in any case via ext-tests.
	$WARN "Cannot do debug tests without --enable-debug."
	exit 0
fi

logfile=$LOGDIR/039.debug
logfile1=$logfile-1
logfile2=$logfile-2
logfile3=$logfile-3

# We have to give some option so that the number of parameters is the same.
# We cut the timestamp and the memory addresses away, as they might be
# different if address space randomization is enabled.
function Clean
{
	cut -f2- -d' ' | perl -pe 's#0x\w+#0x*#g; s#\d+ KB#* KB#;' 
}

$BINdflt -o debug_output=$logfile1 -d -D main
Clean < $logfile1 > $logfile2

$BINdflt -o debug_output="cat > $logfile1" -d -D main
Clean < $logfile1 > $logfile3

$BINdflt -o diff_extra=1 -d -D main | Clean > $logfile1

if [[ `md5sum $logfile-* | cut -f1 -d" " | sort -u | wc -l` -eq 1 ]]
then
	$SUCCESS "Debug tests successful."
else
  md5sum $logfile-*
  $ERROR "Debug output is different."
fi


# Check debug_buffer, if enabled.
if ! $BINdflt -v -V | grep ENABLE_DEBUGBUFFER
then
	$WARN "Option debugbuffer not enabled, won't test."
else
	function fsize
	{
		ls -1ds "$1" | cut -f1 -d" "
	}

	# Check tree and a non-existing file, to an error.
	$BINdflt -o debug_buffer=4 st tree g > $logfile1 2> /dev/null || true
	if [[ `fsize $logfile1` -gt 4 ]]
	then
		$ERROR "debug_buffer doesn't limit to 4kB"
	fi
	> $logfile1
	$BINdflt -o debug_output="cat > /dev/zero" -o debug_buffer=4 -d st tree g > $logfile1 2> /dev/null || true
	if [[ `fsize $logfile1` -lt 4 ]]
	then
		$ERROR "debug_buffer should turn debug_buffer and debug_output off."
	fi

	$SUCCESS "debug_buffer behaves as designed."
fi

# vi: textwidth=0 formatoptions=