summaryrefslogtreecommitdiffstats
path: root/ci/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xci/tests/ci-tests.sh144
-rwxr-xr-xci/tests/deb-tests.sh102
-rwxr-xr-xci/tests/pk-tests.sh144
-rwxr-xr-xci/tests/pkg-tests.sh102
-rwxr-xr-xci/tests/rpm-tests.sh126
5 files changed, 618 insertions, 0 deletions
diff --git a/ci/tests/ci-tests.sh b/ci/tests/ci-tests.sh
new file mode 100755
index 0000000..1aaba03
--- /dev/null
+++ b/ci/tests/ci-tests.sh
@@ -0,0 +1,144 @@
+#! /bin/bash
+#
+# Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
+# All rights reserved.
+# This file is a part of rnp
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+set -o errexit -o pipefail -o noclobber -o nounset
+
+DIR0="$( cd "$( dirname "$0" )" && pwd )"
+# shellcheck disable=SC2034
+SHUNIT_PARENT="$0"
+
+# Defaults applicable to 'normal' installation and not build environment
+: "${BOTAN_INSTALL:=/usr}"
+: "${JSONC_INSTALL:=/usr}"
+: "${RNP_INSTALL:=/usr}"
+
+: "${ENABLE_SM2:=}"
+: "${ENABLE_IDEA:=}"
+
+test_symbol_visibility() {
+ case "$OSTYPE" in
+ msys)
+ mkdir tmp
+ wget -O tmp/Dependencies_x64_Release.zip https://github.com/lucasg/Dependencies/releases/download/v1.10/Dependencies_x64_Release.zip
+ 7z x tmp/Dependencies_x64_Release.zip -otmp
+ tmp/Dependencies -exports "$RNP_INSTALL"/bin/librnp.dll > exports
+ rm -rf tmp
+ ;;
+ darwin*)
+ nm --defined-only -g "$RNP_INSTALL"/lib/librnp.dylib > exports
+ ;;
+ *)
+ nm --defined-only -g "$RNP_INSTALL"/lib64/librnp*.so > exports
+ esac
+
+ assertEquals "Unexpected: 'dst_close' is in exports" 0 "$(grep -c dst_close exports)"
+ assertEquals "Unexpected: 'Botan' is in exports" 0 "$(grep -c Botan exports)"
+ assertEquals "Unexpected: 'OpenSSL' is in exports" 0 "$(grep -c OpenSSL exports)"
+ assertEquals "Unexpected: 'rnp_version_string_full' is not in exports" 1 "$(grep -c rnp_version_string_full exports)"
+
+ rm -f exports
+}
+
+test_supported_features() {
+ # Make sure that we support all features which should be supported
+ supported=( RSA ELGAMAL DSA ECDH ECDSA EDDSA \
+ TRIPLEDES CAST5 BLOWFISH AES128 AES192 AES256 CAMELLIA128 CAMELLIA192 CAMELLIA256 \
+ MD5 SHA1 RIPEMD160 SHA256 SHA384 SHA512 SHA224 SHA3-256 SHA3-512 \
+ ZIP ZLIB BZip2 \
+ "NIST P-256" "NIST P-384" "NIST P-521" Ed25519 Curve25519 secp256k1 \
+ OCB)
+
+ # Old versions say ${unsupported[@]} is unbound if empty
+ unsupported=( NOOP )
+
+ botan_only=( TWOFISH EAX )
+ brainpool=( brainpoolP256r1 brainpoolP384r1 brainpoolP512r1 )
+ sm2=( SM2 SM4 SM3 "SM2 P-256" )
+
+ # SM2
+ if [[ "$ENABLE_SM2" == "Off" ]]; then
+ unsupported+=("${sm2[@]}")
+ elif [[ "${CRYPTO_BACKEND:-}" == "openssl" ]]; then
+ unsupported+=("${sm2[@]}")
+ else
+ supported+=("${sm2[@]}")
+ fi
+
+ # IDEA
+ if [[ "$ENABLE_IDEA" == "Off" ]] ;then
+ unsupported+=(IDEA)
+ else
+ supported+=(IDEA)
+ fi
+
+ case "$OSTYPE" in
+ msys)
+ so_folder="bin"
+ support+=("${brainpool[@]}")
+ ;;
+ darwin*)
+ so_folder="lib"
+ support+=("${brainpool[@]}")
+ ;;
+ *)
+ so_folder="lib64"
+ botan_only+=("${brainpool[@]}")
+ esac
+
+ if [[ "${CRYPTO_BACKEND:-}" == "openssl" ]]; then
+ unsupported+=("${botan_only[@]}")
+ library_path="${JSONC_INSTALL}/$so_folder:${RNP_INSTALL}/$so_folder"
+ else
+ supported+=("${botan_only[@]}")
+ library_path="${BOTAN_INSTALL}/$so_folder:${JSONC_INSTALL}/$so_folder:${RNP_INSTALL}/$so_folder"
+ fi
+
+ if [[ "$OSTYPE" == darwin* ]]; then
+ export DYLD_LIBRARY_PATH="$library_path"
+ else
+ export LD_LIBRARY_PATH="$library_path"
+ fi
+
+ "$RNP_INSTALL"/bin/rnp --version > rnp-version
+
+ for feature in "${supported[@]}"
+ do
+ fea="$(grep -ci "$feature" rnp-version)"
+ assertTrue "Unexpected unsupported feature: '$feature'" "[[ $fea -ge 1 ]]"
+ done
+ for feature in "${unsupported[@]}"
+ do
+ fea="$(grep -ci "$feature" rnp-version)"
+ assertTrue "Unexpected supported feature: '$feature'" "[[ $fea == 0 ]]"
+ done
+
+ rm -f rnp-version
+}
+
+# ......................................................................
+# shellcheck source=/dev/null
+. "$DIR0"/shunit2/shunit2
diff --git a/ci/tests/deb-tests.sh b/ci/tests/deb-tests.sh
new file mode 100755
index 0000000..7805702
--- /dev/null
+++ b/ci/tests/deb-tests.sh
@@ -0,0 +1,102 @@
+#! /bin/bash
+#
+# Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
+# All rights reserved.
+# This file is a part of rnp
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+set -o errexit -o pipefail -o noclobber -o nounset
+
+DIR0="$( cd "$( dirname "$0" )" && pwd )"
+
+# Defaults applicable to 'normal' installation and not build environment
+: "${INSTALL_PREFIX:=/usr}"
+DIR_LIB="$INSTALL_PREFIX/lib/x86_64-linux-gnu"
+DIR_INC="$INSTALL_PREFIX/include/rnp"
+DIR_BIN="$INSTALL_PREFIX/bin"
+#DIR_MAN="$INSTALL_PREFIX/share/man"
+DIR_CMAKE="$INSTALL_PREFIX/lib/x86_64-linux-gnu/cmake/rnp"
+
+declare expected_libraries=(
+ "$DIR_LIB/librnp.so.0"
+)
+
+declare expected_devlibraries=(
+ "$DIR_LIB/librnp.so"
+ "$DIR_LIB/librnp.a"
+ "$DIR_LIB/libsexp.a"
+ "$DIR_LIB/pkgconfig/librnp.pc"
+)
+
+declare expected_includes=(
+ "$DIR_INC/rnp.h"
+ "$DIR_INC/rnp_err.h"
+ "$DIR_INC/rnp_export.h"
+)
+
+declare expected_cmakefiles=(
+ "$DIR_CMAKE/rnp-config.cmake"
+ "$DIR_CMAKE/rnp-config-version.cmake"
+ "$DIR_CMAKE/rnp-targets.cmake"
+ "$DIR_CMAKE/rnp-targets-release.cmake"
+)
+
+declare expected_binaries=(
+ "$DIR_BIN/rnp"
+ "$DIR_BIN/rnpkeys"
+)
+
+# Man page installation does not work as expected
+#declare expected_manuals=(
+# "$DIR_MAN/man3/librnp.3.gz"
+# "$DIR_MAN/man1/rnp.1.gz"
+# "$DIR_MAN/man1/rnpkeys.1.gz"
+#)
+
+t_installed_files() {
+ local f=
+ for f in "$@"
+ do
+ assertTrue "$f was not installed" "[ -e $f ]"
+ done
+}
+
+test_installed_files_librnp() {
+# shellcheck disable=SC2046
+ sudo dpkg -i $(ls ./*.deb) || sudo apt-get -y -f install
+
+ t_installed_files "${expected_libraries[@]}"
+ t_installed_files "${expected_devlibraries[@]}"
+ t_installed_files "${expected_includes[@]}"
+ t_installed_files "${expected_cmakefiles[@]}"
+ t_installed_files "${expected_binaries[@]}"
+
+# Man page installation does not work as expected
+# t_installed_files "${expected_manuals[@]}"
+
+ sudo dpkg -r rnp0
+}
+
+# ......................................................................
+# shellcheck source=/dev/null
+. "$DIR0"/shunit2/shunit2
diff --git a/ci/tests/pk-tests.sh b/ci/tests/pk-tests.sh
new file mode 100755
index 0000000..2b22df9
--- /dev/null
+++ b/ci/tests/pk-tests.sh
@@ -0,0 +1,144 @@
+#! /bin/bash
+#
+# Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
+# All rights reserved.
+# This file is a part of rnp
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+set -o errexit -o pipefail -o noclobber -o nounset
+
+DIR0="$( cd "$( dirname "$0" )" && pwd )"
+
+# Defaults applicable to 'normal' installation and not build environment
+: "${INSTALL_PREFIX:=/usr}"
+
+DIR_CMAKE="$INSTALL_PREFIX/lib64/cmake/rnp"
+
+create_source_file() {
+ cat <<"EOF" > find_package_test.cpp
+ #include <rnp/rnp.h>
+
+ int main(int argc, char *argv[]) {
+ printf("RNP version: %s\n", rnp_version_string());
+ return 0;
+ }
+EOF
+}
+
+create_cmake_file() {
+ cat <<"EOF" > CMakeLists.txt
+ project(find_package_test)
+
+ find_package(PkgConfig REQUIRED)
+
+ find_package(BZip2 REQUIRED)
+ find_package(ZLIB REQUIRED)
+
+ pkg_check_modules(JSONC IMPORTED_TARGET json-c12)
+ if(NOT JSONC_FOUND)
+ pkg_check_modules(JSONC REQUIRED IMPORTED_TARGET json-c)
+ endif(NOT JSONC_FOUND)
+
+ add_library(JSON-C::JSON-C INTERFACE IMPORTED)
+ set_target_properties(JSON-C::JSON-C PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::JSONC)
+
+ pkg_check_modules(Botan REQUIRED IMPORTED_TARGET botan-2)
+ add_library(Botan2::Botan2 INTERFACE IMPORTED)
+ set_target_properties(Botan2::Botan2 PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::Botan)
+
+ find_package(rnp REQUIRED)
+
+ cmake_minimum_required(VERSION 3.12)
+ add_executable(find_package_test find_package_test.cpp)
+EOF
+ echo "target_link_libraries(find_package_test $1)">>CMakeLists.txt
+}
+
+test_shared_library() {
+ sudo yum -y localinstall librnp0-0*.*.rpm librnp0-devel-0*.*.rpm
+ pushd "$(mktemp -d)"
+ create_source_file
+ create_cmake_file 'rnp::librnp'
+
+# shellcheck disable=SC2251
+! cmake . -DCMAKE_MODULE_PATH="$DIR_CMAKE"/*
+ assertEquals "cmake failed at shared library test" 0 "${PIPESTATUS[0]}"
+
+# shellcheck disable=SC2251
+! make
+ assertEquals "make failed at shared library test" 0 "${PIPESTATUS[0]}"
+
+# shellcheck disable=SC2251
+! ./find_package_test
+ assertEquals "test program failed at shared library test" 0 "${PIPESTATUS[0]}"
+
+# shellcheck disable=SC2251
+! ldd find_package_test | grep librnp
+ assertEquals "no reference to shared rnp library at shared library test" 0 "${PIPESTATUS[1]}"
+
+ popd
+# shellcheck disable=SC2046
+ sudo yum -y erase $(rpm -qa | grep rnp)
+}
+
+test_static_library() {
+ sudo yum -y localinstall librnp0-0*.*.rpm librnp0-devel-0*.*.rpm
+ pushd "$(mktemp -d)"
+ create_source_file
+ create_cmake_file 'rnp::librnp-static'
+
+# shellcheck disable=SC2251
+! cmake . -DCMAKE_MODULE_PATH="$DIR_CMAKE"/*
+ assertEquals "cmake failed at static library test" 0 "${PIPESTATUS[0]}"
+
+# shellcheck disable=SC2251
+! make
+ assertEquals "make failed at static library test" 0 "${PIPESTATUS[0]}"
+
+# shellcheck disable=SC2251
+! ./find_package_test
+ assertEquals "test program failed at static library test" 0 "${PIPESTATUS[0]}"
+
+# shellcheck disable=SC2251
+! ldd find_package_test | grep librnp
+ assertNotEquals "unexpected reference to shared rnp library at static library test" 0 "${PIPESTATUS[1]}"
+
+ popd
+# shellcheck disable=SC2046
+ sudo yum -y erase $(rpm -qa | grep rnp)
+}
+
+test_no_library() {
+ pushd "$(mktemp -d)"
+ create_source_file
+ create_cmake_file 'rnp::librnp'
+
+# shellcheck disable=SC2251
+! cmake . -DCMAKE_MODULE_PATH="$DIR_CMAKE"/*
+ assertNotEquals "cmake succeeded at no library test" 0 "${PIPESTATUS[0]}"
+ popd
+}
+
+# ......................................................................
+# shellcheck source=/dev/null
+. "$DIR0"/shunit2/shunit2
diff --git a/ci/tests/pkg-tests.sh b/ci/tests/pkg-tests.sh
new file mode 100755
index 0000000..dbeaac6
--- /dev/null
+++ b/ci/tests/pkg-tests.sh
@@ -0,0 +1,102 @@
+#! /bin/bash
+#
+# Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
+# All rights reserved.
+# This file is a part of rnp
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+set -o errexit -o pipefail -o noclobber -o nounset
+
+DIR0="$( cd "$( dirname "$0" )" && pwd )"
+
+# Defaults applicable to 'normal' installation and not build environment
+: "${INSTALL_PREFIX:=/usr/local}"
+DIR_LIB="$INSTALL_PREFIX/lib"
+DIR_INC="$INSTALL_PREFIX/include/rnp"
+DIR_BIN="$INSTALL_PREFIX/bin"
+# DIR_MAN="$INSTALL_PREFIX/share/man"
+DIR_CMAKE="$INSTALL_PREFIX/lib/cmake/rnp"
+
+declare expected_libraries=(
+ "$DIR_LIB/librnp.so.0"
+)
+
+declare expected_devlibraries=(
+ "$DIR_LIB/librnp.so"
+ "$DIR_LIB/librnp.a"
+ "$DIR_LIB/libsexp.a"
+ "$DIR_LIB/pkgconfig/librnp.pc"
+)
+
+declare expected_includes=(
+ "$DIR_INC/rnp.h"
+ "$DIR_INC/rnp_err.h"
+ "$DIR_INC/rnp_export.h"
+)
+
+declare expected_cmakefiles=(
+ "$DIR_CMAKE/rnp-config.cmake"
+ "$DIR_CMAKE/rnp-config-version.cmake"
+ "$DIR_CMAKE/rnp-targets.cmake"
+ "$DIR_CMAKE/rnp-targets-release.cmake"
+)
+
+declare expected_binaries=(
+ "$DIR_BIN/rnp"
+ "$DIR_BIN/rnpkeys"
+)
+
+# Installation of man files does not work as expected
+#declare expected_manuals=(
+# "$DIR_MAN/man3/librnp.3.gz"
+# "$DIR_MAN/man1/rnp.1.gz"
+# "$DIR_MAN/man1/rnpkeys.1.gz"
+#)
+
+t_installed_files() {
+ local f=
+ for f in "$@"
+ do
+ assertTrue "$f was not installed" "[ -e $f ]"
+ done
+}
+
+test_installed_files_librnp() {
+# shellcheck disable=SC2046
+ pkg add $(ls ./*.pkg)
+
+ t_installed_files "${expected_libraries[@]}"
+ t_installed_files "${expected_devlibraries[@]}"
+ t_installed_files "${expected_includes[@]}"
+ t_installed_files "${expected_cmakefiles[@]}"
+ t_installed_files "${expected_binaries[@]}"
+
+# Installation of man files does not work as expected
+# t_installed_files "${expected_manuals[@]}"
+
+ pkg delete rnp0
+}
+
+# ......................................................................
+# shellcheck source=/dev/null
+. "$DIR0"/shunit2/shunit2
diff --git a/ci/tests/rpm-tests.sh b/ci/tests/rpm-tests.sh
new file mode 100755
index 0000000..39f8dd0
--- /dev/null
+++ b/ci/tests/rpm-tests.sh
@@ -0,0 +1,126 @@
+#! /bin/bash
+#
+# Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
+# All rights reserved.
+# This file is a part of rnp
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+set -o errexit -o pipefail -o noclobber -o nounset
+
+DIR0="$( cd "$( dirname "$0" )" && pwd )"
+
+# Defaults applicable to 'normal' installation and not build environment
+: "${INSTALL_PREFIX:=/usr}"
+: "${BOTAN_INSTALL:=$INSTALL_PREFIX}"
+: "${JSONC_INSTALL:=$INSTALL_PREFIX}"
+: "${RNP_INSTALL:=$INSTALL_PREFIX}"
+
+: "${ENABLE_SM2:=}"
+: "${ENABLE_IDEA:=}"
+
+DIR_LIB="$INSTALL_PREFIX/lib64"
+DIR_INC="$INSTALL_PREFIX/include/rnp"
+DIR_BIN="$INSTALL_PREFIX/bin"
+DIR_MAN="$INSTALL_PREFIX/share/man"
+DIR_CMAKE="$INSTALL_PREFIX/lib64/cmake/rnp"
+
+declare expected_libraries=(
+ "$DIR_LIB/librnp.so.0"
+)
+
+declare expected_devlibraries=(
+ "$DIR_LIB/librnp.so"
+ "$DIR_LIB/librnp.a"
+ "$DIR_LIB/libsexp.a"
+ "$DIR_LIB/pkgconfig/librnp.pc"
+)
+
+declare expected_includes=(
+ "$DIR_INC/rnp.h"
+ "$DIR_INC/rnp_err.h"
+ "$DIR_INC/rnp_export.h"
+)
+
+declare expected_cmakefiles=(
+ "$DIR_CMAKE/rnp-config.cmake"
+ "$DIR_CMAKE/rnp-config-version.cmake"
+ "$DIR_CMAKE/rnp-targets.cmake"
+ "$DIR_CMAKE/rnp-targets-release.cmake"
+)
+
+declare expected_binaries=(
+ "$DIR_BIN/rnp"
+ "$DIR_BIN/rnpkeys"
+)
+
+declare expected_manuals=(
+ "$DIR_MAN/man3/librnp.3.gz"
+ "$DIR_MAN/man1/rnp.1.gz"
+ "$DIR_MAN/man1/rnpkeys.1.gz"
+)
+
+test_installed_files() {
+ local f=
+ for f in "$@"
+ do
+ assertTrue "$f was not installed" "[ -e $f ]"
+ done
+}
+
+test_installed_files_librnp() {
+ sudo yum -y localinstall librnp0-0*.*.rpm
+ test_installed_files "${expected_libraries[@]}"
+# shellcheck disable=SC2046
+ sudo yum -y erase $(rpm -qa | grep rnp)
+}
+
+test_installed_files_librnp-devel() {
+ sudo yum -y localinstall librnp0-0*.*.rpm librnp0-devel-0*.*.rpm
+ test_installed_files "${expected_libraries[@]}"
+ test_installed_files "${expected_devlibraries[@]}"
+ test_installed_files "${expected_includes[@]}"
+ test_installed_files "${expected_cmakefiles[@]}"
+# shellcheck disable=SC2046
+ sudo yum -y erase $(rpm -qa | grep rnp)
+}
+
+test_installed_files_rnp() {
+ sudo yum -y localinstall librnp0-0*.*.rpm rnp0-0*.*.rpm
+ test_installed_files "${expected_libraries[@]}"
+ test_installed_files "${expected_binaries[@]}"
+# shellcheck disable=SC2046
+ sudo yum -y erase $(rpm -qa | grep rnp)
+}
+
+test_installed_files_doc() {
+# in case the nodocs transaction flag is set in the yum configuration
+ sudo yum --setopt=tsflags='' -y install man-db
+ sudo yum --setopt=tsflags='' -y localinstall rnp-*-doc.rpm
+ test_installed_files "${expected_manuals[@]}"
+# shellcheck disable=SC2046
+ sudo yum -y erase $(rpm -qa | grep rnp)
+}
+
+# ......................................................................
+# shellcheck source=/dev/null
+. "$DIR0"/shunit2/shunit2