summaryrefslogtreecommitdiff
path: root/scripts/qmlbenchrunner/build_and_test.sh
blob: c983afd163798165c7609324b2c704d9d1c298f6 (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
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
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# Copyright (C) 2021 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

# XAUTHORITY must be set and DISPLAY must be set
# Usage: build_and_test.sh <main branch> <hardwareId> <jobs> ["annotate"?] [qtdeclarative-branch]
# XAUTHORITY must be accessible

dir=$(pwd)
prefix=''
moduleConfig=''
makecmd=''
install=''
QtverGtEq6=0
module_set=''
benchmark_set=':benchmarks/auto/creation/ :benchmarks/auto/changes/ :benchmarks/auto/js :benchmarks/auto/animations :benchmarks/auto/bindings'


# checkoutQtModule <module name> <branch>
function checkoutQtModule {
    git clone --progress https://codereview.qt-project.org/qt/$1
    cd $dir/$1
    git checkout $2
    echo "Checked out $1 revision $(git rev-parse HEAD)"
    git rev-parse HEAD > ../$1_$2_sha1.txt
    if [[ $1 == 'qtquick3d' ]]; then
        git submodule init
        git submodule update
    fi
    cd $dir
}

# buildQtModule <module name> <branch> <jobs>
function buildQtModule {
    checkoutQtModule $1 $2
    cd $dir/$1
    ($moduleConfig)
    ($makecmd)
    if [[ -n "$install" ]]; then
        ($install)
    fi
    cd $dir
}

# compareSha1sAndAnnotate <module name> <branch>
function compareSha1sAndAnnotate {
    if [[ -e ../$1_$2_sha1.txt && -e $1_$2_sha1.txt ]]; then
        local new_sha1=$(cat $1_$2_sha1.txt)
        local old_sha1=$(cat ../$1_$2_sha1.txt)
        if [[ "$new_sha1" != "$old_sha1" ]]; then
            $dir/qtqa/scripts/qmlbenchrunner/annotate.py --title="$1 update" --tag="$1Update" --text="Updated $1 to $new_sha1 (previous was $old_sha1)" --branch="$2"
        fi
    fi

    if [[ -e $1_$2_sha1.txt ]]; then
        cp $1_$2_sha1.txt ../$1_$2_sha1.txt
    fi
}

branch_label="$1+$5"
qtdeclarative_branch=$5
if [[ -z $qtdeclarative_branch ]]; then
    qtdeclarative_branch=$1
    branch_label=$1
fi

echo "Using $1 as base and $qtdeclarative_branch for qtdeclarative. Using $branch_label as label in database."

if [[ "$1" =~ ^(v?6\.|dev) ]]; then
    QtverGtEq6=1
    echo "Using CMake for qt6+"
    # Qt6 introduced breaking changes for qmlbench. Use qmlbench/dev for Qt6+ builds.
    qmlbenchBranch=dev
    # Qt6 makes cmake the default. Set up the build to use it.
    prefix_dir="$dir/install"
    prefix="--prefix=$prefix_dir"
    moduleConfig="$dir/install/bin/qt-configure-module ."
    makecmd="cmake --build . --parallel $3"
    install="cmake --install ."
    module_set="$module_set qt5compat qtshadertools qtdeclarative qtquickcontrols2 qtquick3d"
    benchmark_set="$benchmark_set :benchmarks/auto/quick3d/"
else
    makecmd="make -j$3"
    moduleConfig="../qtbase/bin/qmake"
    qmlbenchBranch=5.15
    module_set="$module_set qtdeclarative qtquickcontrols qtquickcontrols2 qtgraphicaleffects"
fi

echo 'Running test suites: ' $benchmark_set

# checkout and configure Qt Base
checkoutQtModule qtbase $1
cd $dir/qtbase
./configure -developer-build -nomake tests -nomake examples -release -opensource -confirm-license -no-warnings-are-errors $prefix $EXTRA_CONFIGURE_ARGS
($makecmd)
if [[ -n "$install" ]]; then
    ($install)
fi
cd $dir

# other modules
for module in $module_set; do
    buildQtModule $module $1 $3
done

# qmlbench
git clone --progress https://codereview.qt-project.org/qt-labs/qmlbench
cd $dir/qmlbench

git checkout $qmlbenchBranch
git rev-parse HEAD > ../qmlbench_${qmlbenchBranch}_sha1.txt

#Remove any bad tests that are too difficult for low-power hardware if the variable is set.
if [ ! -z "$BADTESTS" ]; then
    echo "deleting bad tests: $BADTESTS"
    rm -rf $BADTESTS
fi
($moduleConfig)
($makecmd)

./src/qmlbench --json --shell frame-count $benchmark_set > ../results.json
cd $dir
echo Label: $branch_label
qtqa/scripts/qmlbenchrunner/run.py results.json $branch_label $2

module_set="qtbase $module_set"  # Add qtbase back in for iterating over the module set.

if [ "$4" == "annotate" ]; then
    for module in $module_set; do
        compareSha1sAndAnnotate $module $1
    done
    compareSha1sAndAnnotate qmlbench $qmlbenchBranch
fi

for module in $module_set; do
    rm -rf $dir/$module
done
if [[ -n "$install" ]]; then
    rm -rf $prefix_dir
fi
rm -rf $dir/qmlbench