From 72d968cc711de33fae84fa9a95a4f94cf5d43fc1 Mon Sep 17 00:00:00 2001 From: Johnny Hughes Date: Jul 11 2023 14:53:27 +0000 Subject: Merge pull request #92 from carofe82/master setup podman tests, and enhance output upon test failures in sysstat, and libbpf-tools --- diff --git a/tests/p_libbpf-tools/libbpf-tools_tests.sh b/tests/p_libbpf-tools/libbpf-tools_tests.sh index 6704200..a5862d6 100755 --- a/tests/p_libbpf-tools/libbpf-tools_tests.sh +++ b/tests/p_libbpf-tools/libbpf-tools_tests.sh @@ -104,12 +104,16 @@ tracing_tests=( "bpf-wakeuptime 1" ) +output_file=$(mktemp) +trap "rm -f ${output_file}" EXIT + one_failed=0 for cmd in "${version_tests[@]}"; do t_Log "Running $0 - libbpf-tools test: ${cmd}" - if ! eval "${cmd}" > /dev/null 2>&1; then + if ! eval "${cmd}" > ${output_file} 2>&1; then t_Log "FAIL: $0: libbpf-tools test: ${cmd}" + cat ${output_file} one_failed=1 else t_Log "PASS: $0: libbpf-tools test: ${cmd}" @@ -118,8 +122,9 @@ done for cmd in "${tracing_tests[@]}"; do t_Log "Running $0 - libbpf-tools test: ${cmd}" - if ! eval "${cmd}" > /dev/null 2>&1; then + if ! eval "${cmd}" > ${output_file} 2>&1; then t_Log "FAIL: $0: libbpf-tools test: ${cmd}" + cat ${output_file} one_failed=1 else t_Log "PASS: $0: libbpf-tools test: ${cmd}" diff --git a/tests/p_podman/00_install_podman.sh b/tests/p_podman/00_install_podman.sh new file mode 100755 index 0000000..5f2b76d --- /dev/null +++ b/tests/p_podman/00_install_podman.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Author: Carlos Rodriguez-Fernandez + +t_Log "Running $0 - installing podman." + +if [ "$centos_ver" -lt 8 ] ; then + t_Log "SKIP $0: only install in centos stream 8 or greater" + exit 0 +fi + +t_InstallPackage podman diff --git a/tests/p_podman/10_podman_tests.sh b/tests/p_podman/10_podman_tests.sh new file mode 100755 index 0000000..32c61c9 --- /dev/null +++ b/tests/p_podman/10_podman_tests.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Author: Carlos Rodriguez-Fernandez + +t_Log "Running $0 - podman tests" + +if [ "$centos_ver" -lt 8 ] ; then + t_Log "SKIP $0: only run on centos stream 8 or greater" + exit 0 +fi + +tests_in_order=( + "podman version" + "podman info" + "podman run --rm quay.io/centos/centos:stream${centos_ver} bash -c 'echo HELLO' | grep -q -e 'HELLO'" + "podman system service -t 1" + "touch ${HOME}/test.txt && \ + podman run --rm --privileged -v ${HOME}/test.txt:/test.txt quay.io/centos/centos:stream${centos_ver} bash -c 'echo HELLO > /test.txt' && \ + grep -q -e 'HELLO' ${HOME}/test.txt && \ + rm -f ${HOME}/test.txt" + "printf \"FROM quay.io/centos/centos:stream${centos_ver}\nCMD echo 'HELLO'\n\" > ${HOME}/Containerfile && \ + podman build -t test:latest -f ${HOME}/Containerfile && \ + podman image rm localhost/test:latest && \ + rm -rf ${HOME}/Containerfile" +) + +output_file=$(mktemp) +trap "rm -f ${output_file}" EXIT + +for cmd in "${tests_in_order[@]}"; do + t_Log "Running $0: ${cmd}" + if ! eval "${cmd}" > ${output_file} 2>&1; then + t_Log "FAIL: $0: ${cmd}" + cat ${output_file} + exit 1 + else + t_Log "PASS: $0: ${cmd}" + fi +done + diff --git a/tests/p_sysstat/20-pidstat-basic.sh b/tests/p_sysstat/20-pidstat-basic.sh index 07da167..00b13a5 100755 --- a/tests/p_sysstat/20-pidstat-basic.sh +++ b/tests/p_sysstat/20-pidstat-basic.sh @@ -3,5 +3,10 @@ t_Log "Running $0 - pidstat test" -pidstat 1 1 > /dev/null 2>&1 -t_CheckExitStatus $? +output_file=$(mktemp) +trap "rm -f ${output_file}" EXIT + +if ! pidstat 1 1 > ${output_file} 2>&1; then + cat ${output_file} + exit 1 +fi diff --git a/tests/p_sysstat/25-sa-tests.sh b/tests/p_sysstat/25-sa-tests.sh index c93102d..87bae44 100755 --- a/tests/p_sysstat/25-sa-tests.sh +++ b/tests/p_sysstat/25-sa-tests.sh @@ -11,10 +11,14 @@ tests_in_order=( "/usr/lib64/sa/sa2 -A" ) +output_file=$(mktemp) +trap "rm -f ${output_file}" EXIT + for cmd in "${tests_in_order[@]}"; do t_Log "Running $0 - sa test: ${cmd}" - if ! eval "${cmd}" > /dev/null 2>&1; then + if ! eval "${cmd}" > ${output_file} 2>&1; then t_Log "FAIL: $0: sa test: ${cmd}" + cat ${output_file} exit 1 else t_Log "PASS: $0: sa test: ${cmd}"