diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-05-18 10:40:54 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-05-19 11:07:28 +0200 |
commit | 4e8295f42dc7b7e001f620db64abfcd407b4e36c (patch) | |
tree | 94c4584dbb4fbb22a9aa356d31bd7441535d6192 | |
parent | bc012a3e913075d14ac39d33a090c5dcddce2e09 (diff) | |
download | systemd-4e8295f42dc7b7e001f620db64abfcd407b4e36c.tar.gz |
test-compare-versions: basic test for systemd-analyze compare-versions
-rw-r--r-- | meson.build | 9 | ||||
-rw-r--r-- | test/meson.build | 8 | ||||
-rwxr-xr-x | test/test-compare-versions.sh | 34 |
3 files changed, 50 insertions, 1 deletions
diff --git a/meson.build b/meson.build index 36cbfa4893..42e746558b 100644 --- a/meson.build +++ b/meson.build @@ -2162,7 +2162,7 @@ meson.add_install_script(meson_make_symlink, rootlibexecdir / 'systemd', rootsbindir / 'init') -public_programs += executable( +exe = executable( 'systemd-analyze', systemd_analyze_sources, include_directories : core_includes, @@ -2172,6 +2172,13 @@ public_programs += executable( libseccomp], install_rpath : rootlibexecdir, install : conf.get('ENABLE_ANALYZE')) +public_programs += exe + +if want_tests != 'false' + test('test-compare-versions', + test_compare_versions_sh, + args : exe.full_path()) +endif executable( 'systemd-journald', diff --git a/test/meson.build b/test/meson.build index d4e1e3088d..65cb52cd21 100644 --- a/test/meson.build +++ b/test/meson.build @@ -108,6 +108,14 @@ endif ############################################################ +test_compare_versions_sh = files('test-compare-versions.sh') +if install_tests + install_data(test_compare_versions_sh, + install_dir : testsdir) +endif + +############################################################ + rule_syntax_check_py = find_program('rule-syntax-check.py') if want_tests != 'false' test('rule-syntax-check', diff --git a/test/test-compare-versions.sh b/test/test-compare-versions.sh new file mode 100755 index 0000000000..6cfcc158e6 --- /dev/null +++ b/test/test-compare-versions.sh @@ -0,0 +1,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 |