1#!/bin/bash 2# Export tool testing script 3# 4# Version: 20200705 5 6EXIT_SUCCESS=0; 7EXIT_FAILURE=1; 8EXIT_IGNORE=77; 9 10OPTION_SETS=""; 11OPTIONS=(); 12 13INPUT_GLOB="*"; 14 15if test -n "${SKIP_TOOLS_TESTS}" || test -n "${SKIP_TOOLS_END_TO_END_TESTS}"; 16then 17 exit ${EXIT_IGNORE}; 18fi 19 20TEST_EXECUTABLE="../cregtools/cregexport"; 21 22if ! test -x "${TEST_EXECUTABLE}"; 23then 24 TEST_EXECUTABLE="../cregtools/cregexport.exe"; 25fi 26 27if ! test -x "${TEST_EXECUTABLE}"; 28then 29 echo "Missing test executable: ${TEST_EXECUTABLE}"; 30 31 exit ${EXIT_FAILURE}; 32fi 33 34TEST_RUNNER="tests/test_runner.sh"; 35 36if ! test -f "${TEST_RUNNER}"; 37then 38 TEST_RUNNER="./test_runner.sh"; 39fi 40 41if ! test -f "${TEST_RUNNER}"; 42then 43 echo "Missing test runner: ${TEST_RUNNER}"; 44 45 exit ${EXIT_FAILURE}; 46fi 47 48source ${TEST_RUNNER}; 49 50if ! test -d "input"; 51then 52 echo "Test input directory not found."; 53 54 exit ${EXIT_IGNORE}; 55fi 56RESULT=`ls input/* | tr ' ' '\n' | wc -l`; 57 58if test ${RESULT} -eq ${EXIT_SUCCESS}; 59then 60 echo "No files or directories found in the test input directory"; 61 62 exit ${EXIT_IGNORE}; 63fi 64 65TEST_PROFILE_DIRECTORY=$(get_test_profile_directory "input" "cregexport"); 66 67IGNORE_LIST=$(read_ignore_list "${TEST_PROFILE_DIRECTORY}"); 68 69RESULT=${EXIT_SUCCESS}; 70 71for TEST_SET_INPUT_DIRECTORY in input/*; 72do 73 if ! test -d "${TEST_SET_INPUT_DIRECTORY}"; 74 then 75 continue; 76 fi 77 if check_for_directory_in_ignore_list "${TEST_SET_INPUT_DIRECTORY}" "${IGNORE_LIST}"; 78 then 79 continue; 80 fi 81 82 TEST_SET_DIRECTORY=$(get_test_set_directory "${TEST_PROFILE_DIRECTORY}" "${TEST_SET_INPUT_DIRECTORY}"); 83 84 OLDIFS=${IFS}; 85 86 # IFS="\n"; is not supported by all platforms. 87 IFS=" 88"; 89 90 if test -f "${TEST_SET_DIRECTORY}/files"; 91 then 92 for INPUT_FILE in `cat ${TEST_SET_DIRECTORY}/files | sed "s?^?${TEST_SET_INPUT_DIRECTORY}/?"`; 93 do 94 run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "cregexport" "with_stdout_reference" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "${INPUT_FILE}" "${OPTIONS[@]}"; 95 RESULT=$?; 96 97 if test ${RESULT} -ne ${EXIT_SUCCESS}; 98 then 99 break; 100 fi 101 done 102 else 103 for INPUT_FILE in `ls -1d ${TEST_SET_INPUT_DIRECTORY}/${INPUT_GLOB}`; 104 do 105 run_test_on_input_file_with_options "${TEST_SET_DIRECTORY}" "cregexport" "with_stdout_reference" "${OPTION_SETS}" "${TEST_EXECUTABLE}" "${INPUT_FILE}" "${OPTIONS[@]}"; 106 RESULT=$?; 107 108 if test ${RESULT} -ne ${EXIT_SUCCESS}; 109 then 110 break; 111 fi 112 done 113 fi 114 IFS=${OLDIFS}; 115 116 if test ${RESULT} -ne ${EXIT_SUCCESS}; 117 then 118 break; 119 fi 120done 121 122exit ${RESULT}; 123 124