11#! /bin/bash
22
3- INGEST_SCRIPT=$( dirname " $( realpath $0 ) " ) /ingest-tarball.sh
4- TEST_OUTPUT=/dev/null # change to /dev/stdout to print test outputs for debugging purposes
5-
63# Temporary base dir for the tests
74tstdir=$( mktemp -d)
85
6+ # let ingest-tarball.sh script not use /cvmfs, but a temporary directory we can create
7+ export CUSTOM_CVMFS_ROOT=${tstdir} /cvmfs
8+
9+ INGEST_SCRIPT=$( dirname " $( realpath $0 ) " ) /ingest-tarball.sh
10+ TEST_OUTPUT=${tstdir} /out.txt
11+
912# Statistics
1013num_tests=0
1114num_tests_failed=0
@@ -87,15 +90,30 @@ tarballs_fail=(
8790 " $tstdir /eessi-2000.01-compat-123456.tar.gz 2000.01 compat"
8891)
8992
93+ # update_lmod_caches.sh script requires that directory exists,
94+ # and that script to update Lmod cache is found in there
95+ repo_version_root=" ${CUSTOM_CVMFS_ROOT} /my.repo.tld/versions/2000.01"
96+ lmod_libexec_path=" ${repo_version_root} /compat/linux/$( uname -m) /usr/share/Lmod/libexec/"
97+ mkdir -p " ${lmod_libexec_path} "
98+ lmod_update_script=" ${lmod_libexec_path} /update_lmod_system_cache_files"
99+ touch " ${lmod_update_script} "
100+ chmod u+x " ${lmod_update_script} "
101+
102+
90103# Run the tests that should succeed
91104for (( i = 0 ; i < ${# tarballs_success[@]} ; i++ )) ; do
92105 t=$( create_tarball ${tarballs_success[$i]} )
93106 " ${INGEST_SCRIPT} " " my.repo.tld" " $t " >& " ${TEST_OUTPUT} "
94107 if [ ! $? -eq 0 ]; then
108+ echo " >> ${tarballs_success[$i]} test with existing repo FAILed!" >&2
109+ echo " >> output:" >&2
110+ cat " ${TEST_OUTPUT} " >&2
111+ echo >&2
95112 num_tests_failed=$(( num_tests_failed + 1 ))
96113 else
97114 num_tests_succeeded=$(( num_tests_succeeded + 1 ))
98115 fi
116+ rm -f " ${TEST_OUTPUT} "
99117 num_tests=$(( num_tests + 1 ))
100118done
101119
@@ -104,10 +122,15 @@ for ((i = 0; i < ${#tarballs_fail[@]}; i++)); do
104122 t=$( create_tarball ${tarballs_fail[$i]} )
105123 " ${INGEST_SCRIPT} " " my.repo.tld" " $t " >& " ${TEST_OUTPUT} "
106124 if [ ! $? -eq 1 ]; then
125+ echo " >> ${tarballs_fail[$i]} test passed, but should have failed!" >&2
126+ echo " >> output:" >&2
127+ cat " ${TEST_OUTPUT} " >&2
128+ echo >&2
107129 num_tests_failed=$(( num_tests_failed + 1 ))
108130 else
109131 num_tests_succeeded=$(( num_tests_succeeded + 1 ))
110132 fi
133+ rm -f " ${TEST_OUTPUT} "
111134 num_tests=$(( num_tests + 1 ))
112135done
113136
@@ -116,10 +139,15 @@ for ((i = 0; i < ${#tarballs_success[@]}; i++)); do
116139 t=$( create_tarball ${tarballs_success[$i]} )
117140 " ${INGEST_SCRIPT} " " my.nonexistingrepo.tld" " $t " >& " ${TEST_OUTPUT} "
118141 if [ ! $? -eq 1 ]; then
142+ echo " >> ${tarballs_success[$i]} test passed with non-existing repo, should have failed!" >&2
143+ echo " >> output:" >&2
144+ cat " ${TEST_OUTPUT} " >&2
145+ echo >&2
119146 num_tests_failed=$(( num_tests_failed + 1 ))
120147 else
121148 num_tests_succeeded=$(( num_tests_succeeded + 1 ))
122149 fi
150+ rm -f " ${TEST_OUTPUT} "
123151 num_tests=$(( num_tests + 1 ))
124152done
125153
0 commit comments