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
|
#!/bin/sh
# dep8 smoke test for mariadbd
# Author: Otto Kekäläinen <otto@debian.org>
#
# This test should be declared in debian/tests/control with a dependency
# on the package that provides a configured MariaDB server (eg.
# mariadb-server).
#
# This test should be declared in debian/tests/control with the
# following restrictions:
# - needs-root (binaries in /usr/sbin need root to run)
# - allow-stderr (set -x always outputs to stderr, also if mariadbd was not
# launched as a service it will complain that mysql.plugin table is empty)
#
# This test prints out various configuration information from mariadbd and
# compares the result to expected values in original binary/build.
#
normalize_value() {
VARIABLE="$1"
VALUE="$2"
# In sed the '\s.*' will match whitespace followed by any other chars until end of line
sed "s/^$VARIABLE\(\s\s*\).*$/$VARIABLE\1$VALUE/" -i "$TEMPFILE"
}
trace() {
TRACE_NAME="$(echo "$*" | sed -E 's|/usr/(s?)bin/||' | sed 's/ //g' | sed 's/--/-/g')"
# Show in test what was run
echo
echo "Tracing: $*"
# shellcheck disable=SC2068
$@ > "$TRACE_NAME.actual"
# Normalize contents for know special case
if echo "$*" | grep -q verbose
then
TEMPFILE="$(mktemp)"
# Use 'tail' to skip first line that has version and architecture strings which
# we intentionally do not want to include in the trace file.
tail -n +2 "$TRACE_NAME.actual" > "$TEMPFILE"
# Hostname varies one very machine
sed "s/$(hostname)/HOSTNAME/g" -i "$TEMPFILE"
# Version/revision increases on every release
VERSION=$(mariadbd --help --verbose | grep -e "^version " | rev | cut -d ' ' -f 1 | rev)
sed "s/$VERSION/VERSION/g" -i "$TEMPFILE"
# SSL library version inherited form dependency, not relevant for tracing
# the correctness of the MariaDB build itself
sed 's/OpenSSL 3.*/SSL-VERSION/' -i "$TEMPFILE"
# Normalize values that depend on build environment
normalize_value system-time-zone UTC # depends on OS environment
normalize_value open-files-limit 32000 # depends on OS environment
normalize_value thread-pool-size 2 # depends on CPU cores available
normalize_value version-compile-machine ARCH # x86_64, aarch64, armv7l ..
# armhf/armel might have: debian-linux-gnueabi, debian-linux-gnueabihf
normalize_value version-compile-os debian-linux-gnu
# In Sid 'Debian n/a', in Bookworm 'Debian 12'
normalize_value version-comment "Debian RELEASE"
# Inherits git commit id from latest upstream release and thus not constant
normalize_value version-source-revision -
# 32-bit systems (i386, armel, armhf) have lower values
normalize_value innodb-io-capacity-max 18446744073709551615 # 32-bit: 4294967295
normalize_value max-binlog-cache-size 18446744073709547520 # 32-bit: 4294963200
normalize_value max-binlog-stmt-cache-size 18446744073709547520 # 32-bit: 4294963200
normalize_value myisam-max-sort-file-size 18446744073709551615 # 32-bit: 2146435072
normalize_value myisam-mmap-size 9223372036853727232 # 32-bit: 4294967295
normalize_value tmp-disk-table-size 18446744073709551615 # 32-bit: 4294967295
# ppc64el has larger default value: 393216
normalize_value log-tc-size 24576
mv "$TEMPFILE" "$TRACE_NAME.actual"
fi
echo "diff --ignore-space-change -u $TRACE_NAME.expected $TRACE_NAME.actual"
# Validate that trace file in source code matches tested
if ! diff --ignore-space-change -u "$TRACE_NAME.expected" "$TRACE_NAME.actual"
then
echo "Error: Output from '$*' did NOT match what was expected"
echo
echo "If the change is intentional, update the debian/tests/traces to match"
echo "the new values and document change to users in mariadb-server.NEWS"
if [ -n "$ERRORS" ]
then
ERRORS="$ERRORS, $TRACE_NAME"
else
ERRORS="$TRACE_NAME"
fi
fi
}
echo "Running test 'configuration-tracing'"
cd debian/tests/traces || exit 1
set -e
ERRORS=""
# Dump out what parameters mariadb would be called with by default
trace /usr/bin/mariadb --print-defaults
# Dump out all help texts, client variables and their default values
trace /usr/bin/mariadb --verbose --help
# Dump out what parameters mariadbd would be called with by default on system
trace /usr/sbin/mariadbd --print-defaults
# Dump out all help texts, server variables and their default values
trace /usr/sbin/mariadbd --verbose --help
# Emit non-zero exit code if there was errors
if [ -n "$ERRORS" ]
then
echo "Error: mismatch in $ERRORS"
exit 1
fi
|