aboutsummaryrefslogtreecommitdiffstats
path: root/abi-perf-test
blob: 8bd017b10fb3427d6d8245bcf7775fb070bdfe93 (plain) (blame)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
set -eo pipefail
cd $(dirname $0)
whoami=$(basename $0)

if [[ $(git status -s | grep -E -v abi-perf-test | wc -l) != 0 ]]; then
    echo 1>&2 "${whoami}: git is not clean. (abi-perf-test changes ignored)"
    git status -s
    exit 2
fi

old_rev=${1-bad}
new_rev=${2-bad}

if [ "$new_rev" = "bad" ]; then
    echo 1>&2 "Usage: $whoami old-rev new-rev"
    exit 2
fi

old_rev_hash=$(git rev-parse $old_rev)
new_rev_hash=$(git rev-parse $new_rev)

cat <<EOF

Checking ABI:
* old revision: $old_rev = $old_rev_hash
* new revision: $new_rev = $new_rev_hash

EOF

work=/tmp/check-abi
if [ -d $work ]; then
   if [ ! -f $work/.abi ]; then
       echo 1>&2 "$work exists and is not ours"
       exit 2
   else
       rm -rf $work
   fi
fi
mkdir -p $work/{old,new}
touch $work/.abi

source=$PWD
repo=file://$source/.git
cd $work
git clone $repo qpdf
cd qpdf

git tag abi-old $old_rev_hash
git tag abi-new $new_rev_hash

echo "** building old version **"

git checkout abi-old
cmake -S . -B build \
  -DMAINTAINER_MODE=1 -DBUILD_STATIC_LIBS=0 -DBUILD_DOC=0 \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build -j$(nproc)

echo "** saving old library and size information **"

$source/check_abi check-sizes --lib build/libqpdf/libqpdf.so
./build/qpdf/sizes >| $work/old/sizes
cp build/libqpdf/libqpdf.so.*.* $work/old

if [ "$SKIP_PERF" != "1" ]; then
    echo "** writing performance details for old revision to $work/perf **"
    $source/performance_check --dir $source/../performance-test-files | \
        tee -a $work/perf
fi

echo "** building new version's library and sizes **"

git checkout abi-new
cmake -S . -B build \
  -DMAINTAINER_MODE=1 -DBUILD_STATIC_LIBS=0 -DBUILD_DOC=0 \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build -j$(nproc) --target sizes

echo "** saving new library and size information **"

$source/check_abi check-sizes --lib build/libqpdf/libqpdf.so
./build/qpdf/sizes >| $work/new/sizes
cp build/libqpdf/libqpdf.so.*.* $work/new

echo "** running ABI comparison **"

$source/check_abi compare --old-lib $work/old/libqpdf.so.*.* \
  --new-lib build/libqpdf/libqpdf.so \
  --old-sizes $work/old/sizes --new-sizes $work/new/sizes

test_warn=0
if [ "$SKIP_TESTS" != "1" ]; then
    # Switch back to the previous release and run tests. There may be
    # some failures based on functionality change. We are looking for
    # ABI breakage.
    git checkout abi-old
    set +e
    (cd build; ctest --verbose)
    if [ $? != 0 ]; then
        test_warn=1
    fi
    set -e
fi

git checkout abi-new

if [ "$SKIP_PERF" != "1" ]; then
    echo "** writing performance details for new revision to $work/perf **"

    cmake -S . -B build \
      -DMAINTAINER_MODE=1 -DBUILD_STATIC_LIBS=0 -DBUILD_DOC=0 \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo
    cmake --build build -j$(nproc)
    $source/performance_check --dir $source/../performance-test-files | \
        tee -a $work/perf
fi

if [ $test_warn = 1 ]; then
    cat <<EOF

**********************************************************************
There were some test failures; inspect to determine whether they are
ABI-related.

Check test results in $work/qpdf/build
**********************************************************************

EOF
fi