summaryrefslogtreecommitdiffstats
path: root/test/test-compare-versions.sh
blob: 6cfcc158e6fc9ee6d769e0c857eb709299686fed (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
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e

ANALYZE="${1:-systemd-analyze}"

$ANALYZE compare-versions 1 lt 2
$ANALYZE compare-versions 1 '<' 2
$ANALYZE compare-versions 1 le 2
$ANALYZE compare-versions 1 '<=' 2
$ANALYZE compare-versions 1 ne 2
$ANALYZE compare-versions 1 '!=' 2
( ! $ANALYZE compare-versions 1 ge 2 )
( ! $ANALYZE compare-versions 1 '>=' 2 )
( ! $ANALYZE compare-versions 1 eq 2 )
( ! $ANALYZE compare-versions 1 '==' 2 )
( ! $ANALYZE compare-versions 1 gt 2 )
( ! $ANALYZE compare-versions 1 '>' 2 )

$ANALYZE compare-versions 1 2 | grep ' < '
$ANALYZE compare-versions 2 2 | grep ' == '
$ANALYZE compare-versions 2 1 | grep ' > '

set +e

$ANALYZE compare-versions 1 2; ret1=$?
$ANALYZE compare-versions 2 2; ret2=$?
$ANALYZE compare-versions 2 1; ret3=$?

set -e

test $ret1 == 12
test $ret2 == 0
test $ret3 == 11