| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Copyright 2015-2019 Red Hat Inc., Durham, North Carolina. |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # OpenSCAP Probes Test Suite. |
| 7 | # Tests the rpmverifypackage probe. |
| 8 | # |
| 9 | # Authors: |
| 10 | # Jan Černý <[email protected]> |
| 11 | # Evgenii Kolesnikov <[email protected]> |
| 12 | |
| 13 | . $builddir/tests/test_common.sh |
| 14 | . $srcdir/rpmverifypackage_common.sh |
| 15 | |
| 16 | set -e -o pipefail |
| 17 | set -x |
| 18 | |
| 19 | [ -f /etc/os-release ] && . /etc/os-release |
| 20 | |
| 21 | |
| 22 | function test_probes_rpmverifypackage_epoch { |
| 23 | RPM_package_1=$(rpm -qa --qf "%{NAME}\t%{EPOCH}\n" | grep -v "(none)" | sort -u | head -1 | cut -f 1) || ret=$? |
| 24 | test_probes_rpmverifypackage $RPM_package_1 |
| 25 | } |
| 26 | |
| 27 | function test_probes_rpmverifypackage_noepoch { |
| 28 | RPM_package_2=$(rpm -qa --qf "%{NAME}\t%{EPOCH}\n" | grep "(none)" | sort -u | head -1 | cut -f 1) || ret=$? |
| 29 | test_probes_rpmverifypackage $RPM_package_2 |
| 30 | } |
| 31 | |
| 32 | function test_probes_rpmverifypackage_rpm { |
| 33 | test_probes_rpmverifypackage rpm |
| 34 | } |
| 35 | |
| 36 | |
| 37 | test_init |
| 38 | |
| 39 | if [[ $ID != *"sle"* && $ID != *"suse"* ]]; then |
| 40 | test_run "rpmverifypackage probe test with epoch" test_probes_rpmverifypackage_epoch |
| 41 | else |
| 42 | test_run "rpmverifypackage probe test" test_probes_rpmverifypackage_noepoch |
| 43 | fi |
| 44 | |
| 45 | test_exit |