summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/librdkafka-2.1.0/tests/parse-refcnt.sh
blob: f77b2a1275018e09fe5505bfe8d12458f9cd186d (plain)
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
#!/bin/bash
#
#

set -e

# Parse a log with --enable-refcnt output enabled.

log="$1"

if [[ ! -f $log ]]; then
    echo "Usage: $0 <log-file>"
    exit 1
fi


# Create a file with all refcnt creations
cfile=$(mktemp)
grep 'REFCNT.* 0 +1:' $log | awk '{print $6}' | sort > $cfile

# .. and one file with all refcnt destructions
dfile=$(mktemp)
grep 'REFCNT.* 1 -1:' $log | awk '{print $6}' | sort > $dfile

# For each refcnt that was never destructed (never reached 0), find it
# in the input log.

seen=
for p in $(grep -v -f $dfile $cfile) ; do
    echo "=== REFCNT $p never reached 0 ==="
    grep -nH "$p" $log
    echo ""
    seen=yes
done

rm -f "$cfile" "$dfile"

if [[ -z $seen ]]; then
    echo "No refcount leaks found"
    exit 0
fi

exit 2