File: test-versioning.sh

package info (click to toggle)
sdl2-compat 2.32.54%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 52,892 kB
  • sloc: ansic: 93,277; python: 1,549; sh: 569; makefile: 45; javascript: 21; cpp: 11
file content (115 lines) | stat: -rwxr-xr-x 3,677 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
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
#!/bin/sh
# Copyright 2022 Collabora Ltd.
# SPDX-License-Identifier: Zlib

set -eu

cd `dirname $0`/..

ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION  *//p' include/SDL2/SDL_version.h)
ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION  *//p' include/SDL2/SDL_version.h)
ref_micro=$(sed -ne 's/^#define SDL_PATCHLEVEL  *//p' include/SDL2/SDL_version.h)
ref_version="${ref_major}.${ref_minor}.${ref_micro}"

tests=0
failed=0

ok () {
    tests=$(( tests + 1 ))
    echo "ok - $*"
}

not_ok () {
    tests=$(( tests + 1 ))
    echo "not ok - $*"
    failed=1
}

version=$(sed -Ene 's/^project\(sdl[0-9]+_compat VERSION ([0-9.]*) LANGUAGES C\)$/\1/p' CMakeLists.txt)

if [ "$ref_version" = "$version" ]; then
    ok "CMakeLists.txt $version"
else
    not_ok "CMakeLists.txt $version disagrees with SDL_version.h $ref_version"
fi

tuple=$(sed -ne 's/^ *FILEVERSION *//p' src/version.rc | tr -d '\r')
ref_tuple="${ref_major},${ref_minor},${ref_micro},0"

if [ "$ref_tuple" = "$tuple" ]; then
    ok "version.rc FILEVERSION $tuple"
else
    not_ok "version.rc FILEVERSION $tuple disagrees with SDL_version.h $ref_tuple"
fi

tuple=$(sed -ne 's/^ *PRODUCTVERSION *//p' src/version.rc | tr -d '\r')

if [ "$ref_tuple" = "$tuple" ]; then
    ok "version.rc PRODUCTVERSION $tuple"
else
    not_ok "version.rc PRODUCTVERSION $tuple disagrees with SDL_version.h $ref_tuple"
fi

tuple=$(sed -Ene 's/^ *VALUE "FileVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/version.rc | tr -d '\r')
ref_tuple="${ref_major}, ${ref_minor}, ${ref_micro}, 0"

if [ "$ref_tuple" = "$tuple" ]; then
    ok "version.rc FileVersion $tuple"
else
    not_ok "version.rc FileVersion $tuple disagrees with SDL_version.h $ref_tuple"
fi

tuple=$(sed -Ene 's/^ *VALUE "ProductVersion", "([0-9, ]*)\\0"\r?$/\1/p' src/version.rc | tr -d '\r')

if [ "$ref_tuple" = "$tuple" ]; then
    ok "version.rc ProductVersion $tuple"
else
    not_ok "version.rc ProductVersion $tuple disagrees with SDL_version.h $ref_tuple"
fi

minor=$(sed -Ene 's/^#define SDL2_COMPAT_VERSION_MINOR ([0-9]+)$/\1/p' src/sdl2_compat.c)

if [ "$ref_minor" = "$minor" ]; then
    ok "sdl2_compat.c SDL2_COMPAT_VERSION_MINOR $minor"
else
    not_ok "sdl2_compat.c SDL2_COMPAT_VERSION_MINOR $minor disagrees with SDL_version.h $ref_minor"
fi

micro=$(sed -Ene 's/^#define SDL2_COMPAT_VERSION_PATCH ([0-9]+)$/\1/p' src/sdl2_compat.c)

if [ "$ref_micro" = "$micro" ]; then
    ok "sdl2_compat.c SDL2_COMPAT_VERSION_PATCH $micro"
else
    not_ok "sdl2_compat.c SDL2_COMPAT_VERSION_PATCH $micro disagrees with SDL_version.h $ref_micro"
fi

if [ "x$(($ref_minor%2))" = "x0" ]; then
    so_version="$((100 * $ref_minor)).$ref_micro"
    compat_version="$((100 * $ref_minor + 1)).0"
    dylib_version="$((100 * $ref_minor + 1)).$ref_micro"
else
    so_version="$((100 * $ref_minor + $ref_micro)).0"
    compat_version="$((100 * $ref_minor + $ref_micro + 1)).0"
    dylib_version="$((100 * $ref_minor + $ref_micro + 1)).0"
fi

ref_dylib_versions="$compat_version $dylib_version"
dylib_versions=$(sed -Ene 's/^LDFLAGS\+= -Wl,-compatibility_version,([0-9.]+) -Wl,-current_version,([0-9.]+)$/\1 \2/p' src/Makefile.darwin)

if [ "$ref_dylib_versions" = "$dylib_versions" ]; then
    ok "Makefile.darwin LDFLAGS $dylib_versions"
else
    not_ok "Makefile.darwin LDFLAGS $dylib_versions disagrees with reference $ref_dylib_versions"
fi

ref_so_version="$so_version"
so_version=$(sed -Ene 's/^SHLIB = libSDL2-2.0.so.0.([0-9.]+)$/\1/p' src/Makefile.linux)

if [ "$ref_so_version" = "$so_version" ]; then
    ok "Makefile.linux SHLIB $so_version"
else
    not_ok "Makefile.linux SHLIB $so_version disagrees with reference $ref_so_version"
fi

echo "1..$tests"
exit "$failed"