summaryrefslogtreecommitdiffstats
path: root/test/test-compare-versions.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
commit55944e5e40b1be2afc4855d8d2baf4b73d1876b5 (patch)
tree33f869f55a1b149e9b7c2b7e201867ca5dd52992 /test/test-compare-versions.sh
parentInitial commit. (diff)
downloadsystemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.tar.xz
systemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.zip
Adding upstream version 255.4.upstream/255.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/test-compare-versions.sh')
-rwxr-xr-xtest/test-compare-versions.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/test-compare-versions.sh b/test/test-compare-versions.sh
new file mode 100755
index 0000000..c40208b
--- /dev/null
+++ b/test/test-compare-versions.sh
@@ -0,0 +1,35 @@
+#!/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 )
+
+test "$($ANALYZE compare-versions 1 2)" = '1 < 2'
+test "$($ANALYZE compare-versions 2 2)" = '2 == 2'
+test "$($ANALYZE compare-versions 2 1)" = '2 > 1'
+test "$($ANALYZE compare-versions '' '')" = "'' == ''"
+
+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