From 3b896ae1c22c7c4f72411b26ed8d5ab1e2d4aa76 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Mon, 4 Dec 2023 02:37:20 -0700 Subject: [PATCH] func: add pdf test, modify exports --- func/common/imports.sh | 9 ++++++++- func/lib/pdf/00-install-pdf-utils.sh | 3 +++ func/lib/pdf/10-test-pdf.sh | 23 +++++++++++++++++++++++ func/runtests.sh | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 func/lib/pdf/00-install-pdf-utils.sh create mode 100644 func/lib/pdf/10-test-pdf.sh diff --git a/func/common/imports.sh b/func/common/imports.sh index 562f1d7..b70ac9b 100644 --- a/func/common/imports.sh +++ b/func/common/imports.sh @@ -113,7 +113,11 @@ function p_getPackageArch() { } function p_getDist() { - rpm -q "$(rpm -qf /etc/redhat-release)" --queryformat '%{version}\n' | cut -d'.' -f1 + rpm -q --whatprovides redhat-release --queryformat '%{version}\n' | cut -d'.' -f1 +} + +function p_getMinorVersion() { + rpm -q --whatprovides redhat-release --queryformat '%{version}\n' | cut -d'.' -f2 } ################################################################################ @@ -218,8 +222,10 @@ function m_recycleLog() { rl_ver=$(p_getDist) rl_arch=$(m_getArch) +rl_minor_ver=$(p_getMinorVersion) export rl_ver export rl_arch +export rl_minor_ver export -f r_log export -f r_checkExitStatus @@ -234,6 +240,7 @@ export -f p_resetModule export -f p_getPackageRelease export -f p_getPackageArch export -f p_getDist +export -f p_getMinorVersion export -f m_serviceCycler export -f m_checkForPort export -f m_assertCleanExit diff --git a/func/lib/pdf/00-install-pdf-utils.sh b/func/lib/pdf/00-install-pdf-utils.sh new file mode 100644 index 0000000..09272dc --- /dev/null +++ b/func/lib/pdf/00-install-pdf-utils.sh @@ -0,0 +1,3 @@ +#!/bin/bash +r_log "pdf" "Install enscript, ghostscript, and poppler" +p_installPackageNormal fontconfig @fonts enscript ghostscript poppler-utils diff --git a/func/lib/pdf/10-test-pdf.sh b/func/lib/pdf/10-test-pdf.sh new file mode 100644 index 0000000..2f11709 --- /dev/null +++ b/func/lib/pdf/10-test-pdf.sh @@ -0,0 +1,23 @@ +#!/bin/bash +r_log "pdf" "Create a PDF from postscript from text, convert it back to text and check" +trap 'rm -rf $PSFILE $PDFFILE $TESTFILE' EXIT + +TOFIND="BlueOnyx" +PSFILE="/var/tmp/test.ps" +PDFFILE="/var/tmp/test.pdf" +TESTFILE="/var/tmp/psresult" + +encript -q -p $PSFILE /etc/rocky-release + +r_log "pdf" "Check created file" + +grep -q $TOFIND $PSFILE +pdf_ret_val=$? +r_checkExitStatus $pdf_ret_val + +ps2pdf $PSFILE $PDFFILE +pdftotext -q $PDFFILE $TESTFILE +r_log "pdf" "Checking after conversion to text" +grep -q $TOFIND $TESTFILE +text_ret_val=$? +r_checkExitStatus $text_ret_val diff --git a/func/runtests.sh b/func/runtests.sh index 40b2f89..d2f82df 100644 --- a/func/runtests.sh +++ b/func/runtests.sh @@ -62,7 +62,7 @@ fi # TODO: get some stacks and lib in there r_processor <(/usr/bin/find ./core -type f | sort -t'/') -#r_processor <(/usr/bin/find ./lib -type f | sort -t'/') +r_processor <(/usr/bin/find ./lib -type f | sort -t'/') #r_processor <(/usr/bin/find ./stacks -type f | sort -t'/') r_log "internal" "Core Tests completed"