From 1257669be39db39586e9d80720aa216666787c12 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 20 Feb 2024 00:17:59 -0600 Subject: [PATCH] Update: Backport fixes for bootstrap-example.sh, package.sh, and test.sh scripts. Add support for "-m gcc". - A follow up backport commit for every build settings file and fakefile is needed after this commit. Fix issue with test_operate_build_project not getting the test_thread_individual variable. See commits: - a850c4fc237e346cecc70bf3ed87b958299ceca2 - ea1c3d46fecaa3e267bb9900e509a43026a85648 - ba083b0d08191cb03f3531ef64ae82c881318f04 --- build/scripts/bootstrap-example.sh | 19 +-- build/scripts/package.sh | 29 ---- build/scripts/test.sh | 281 ++++++++++++++++++++++++++----------- 3 files changed, 212 insertions(+), 117 deletions(-) diff --git a/build/scripts/bootstrap-example.sh b/build/scripts/bootstrap-example.sh index 164d2c2..9456a89 100644 --- a/build/scripts/bootstrap-example.sh +++ b/build/scripts/bootstrap-example.sh @@ -52,7 +52,8 @@ color= shared= static= version=0.6.9 -clang= +mode_compiler_param="-m" +mode_compiler_value="gcc" mode_part= mode_parameter= mode_path= @@ -112,7 +113,7 @@ while [[ ${i} -le $# ]] ; do elif [[ ${p} == "--disable-shared" ]] ; then shared="--disable-shared" elif [[ ${p} == "clang" ]] ; then - clang="-m clang" + mode_compiler_value="clang" elif [[ ${p} == "-w" || ${p} == "--work" ]] ; then let i++ @@ -139,7 +140,7 @@ if [[ ${1} == "individual" ]] ; then ${shell_command} ./bootstrap.sh clean ${verbose} ${color} ${suppress_first} && - ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m individual -m individual_thread ${mode_thread_param} ${mode_thread_value} ${clang} && + ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m individual -m individual_thread ${mode_thread_param} ${mode_thread_value} ${mode_compiler_param} ${mode_compiler_value} && ${shell_command} ./install.sh ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} && @@ -155,7 +156,7 @@ if [[ ${1} == "level" ]] ; then ${shell_command} ./bootstrap.sh clean ${verbose} ${color} ${suppress_first} && - ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m level ${mode_thread_param} ${mode_thread_value} ${clang} && + ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m level ${mode_thread_param} ${mode_thread_value} ${mode_compiler_param} ${mode_compiler_value} && ${shell_command} ./install.sh ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} && @@ -165,7 +166,7 @@ if [[ ${1} == "level" ]] ; then ${shell_command} ./bootstrap.sh clean ${verbose} ${color} ${suppress_first} && - ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m level ${mode_thread_param} ${mode_thread_value} && + ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m level ${mode_thread_param} ${mode_thread_value} ${mode_compiler_param} ${mode_compiler_value} && ${shell_command} ./install.sh ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} && @@ -175,7 +176,7 @@ if [[ ${1} == "level" ]] ; then ${shell_command} ./bootstrap.sh clean ${verbose} ${color} ${suppress_first} && - ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m level ${mode_thread_param} ${mode_thread_value} && + ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m level ${mode_thread_param} ${mode_thread_value} ${mode_compiler_param} ${mode_compiler_value} && ${shell_command} ./install.sh ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} fi @@ -187,7 +188,7 @@ if [[ ${1} == "monolithic" ]] ; then ${shell_command} ./bootstrap.sh clean ${verbose} ${color} ${suppress_first} && - ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m monolithic ${mode_thread_param} ${mode_thread_value} ${clang} && + ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m monolithic ${mode_thread_param} ${mode_thread_value} ${mode_compiler_param} ${mode_compiler_value} && ${shell_command} ./install.sh ${verbose} ${color} ${shared} ${suppress_first} ${static} -w ${path_work} fi @@ -243,7 +244,7 @@ if [[ ${mode_part} != "" ]] ; then ${shell_command} ./bootstrap.sh clean ${verbose} ${color} ${suppress_first} && - ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m ${build_mode} ${build_mode_extra_param_1} ${build_mode_extra_value_1} ${build_mode_extra_param_2} ${build_mode_extra_value_2} && + ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m ${build_mode} ${build_mode_extra_param_1} ${build_mode_extra_value_1} ${build_mode_extra_param_2} ${build_mode_extra_value_2} ${mode_compiler_param} ${mode_compiler_value} && ${shell_command} ./install.sh ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} @@ -286,7 +287,7 @@ elif [[ ${1} == "programs-individual" || ${1} == "programs-level" || ${1} == "pr ${shell_command} ./bootstrap.sh clean ${verbose} ${color} ${suppress_first} && - ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m ${build_mode} ${build_mode_extra_param_1} ${build_mode_extra_value_1} ${build_mode_extra_param_2} ${build_mode_extra_value_2} && + ${shell_command} ./bootstrap.sh build ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} -m ${build_mode} ${build_mode_extra_param_1} ${build_mode_extra_value_1} ${build_mode_extra_param_2} ${build_mode_extra_value_2} ${mode_compiler_param} ${mode_compiler_value} && ${shell_command} ./install.sh ${verbose} ${color} ${suppress_first} ${shared} ${static} -w ${path_work} || diff --git a/build/scripts/package.sh b/build/scripts/package.sh index c2ca442..1070267 100644 --- a/build/scripts/package.sh +++ b/build/scripts/package.sh @@ -666,7 +666,6 @@ package_dependencies_individual() { local dependencies_2= local dependencies_thread= local dependencies_individual= - local dependencies_individual_threadless= local dependency= local dependency_file= local dependency_files= @@ -912,32 +911,6 @@ package_dependencies_individual() { break fi - if [[ $has_thread == "yes" && ${dependencies_individual} != "" && $(grep -o "^\s*build_libraries-individual_threadless\>" ${settings}) != "" ]] ; then - dependencies_individual_threadless=$(echo "${dependencies_individual}" | sed -e "s| \-lf_thread\>||g") - - if [[ ${verbosity} == "verbose" ]] ; then - package_print_first - - echo -e " (threadless) ${dependencies_individual_threadless}" - fi - - settings=${directory}/data/build/settings - sed -i -e "s|^\s*build_libraries-individual_threadless[[:space:]].*\$|build_libraries-individual_threadless${dependencies_individual_threadless}|" ${settings} && - sed -i -e "s|^\s*build_libraries-individual_threadless\$|build_libraries-individual_threadless${dependencies_individual_threadless}|" ${settings} - - if [[ ${?} -ne 0 ]] ; then - if [[ ${verbosity} != "quiet" ]] ; then - package_print_first - - echo -e "${c_error}ERROR: Failed to update settings file ${c_notice}${settings}${c_error}.${c_reset}" - fi - - let failure=1 - - break - fi - fi - # All level 3 are expected to support all modes: individual, level, and monolithic. if [[ ${level_current} == "3" ]] ; then sed -i -e "s|^\s*build_libraries-level\>.*\$|build_libraries-level -lfll_2 -lfll_1 -lfll_0|" ${settings} && @@ -1161,8 +1134,6 @@ package_dependencies_level_update() { sed -i -e "s|^\s*build_libraries-level\s.*\$|build_libraries-level${level_libraries}|" ${settings} && sed -i -e "s|^\s*build_libraries-level\$|build_libraries-level${level_libraries}|" ${settings} && - sed -i -e "s|^\s*build_libraries-level_threadless\s.*\$|build_libraries-level_threadless${level_libraries}|" ${settings} && - sed -i -e "s|^\s*build_libraries-level_threadless\$|build_libraries-level_threadless${level_libraries}|" ${settings} if [[ ${?} -ne 0 ]] ; then if [[ ${verbosity} != "quiet" ]] ; then diff --git a/build/scripts/test.sh b/build/scripts/test.sh index 38dde42..57583ab 100644 --- a/build/scripts/test.sh +++ b/build/scripts/test.sh @@ -52,15 +52,16 @@ test_main() { local path_scripts_package=${path_scripts}package.sh local path_test=${PWD}/test/ local path_test_package=${path_test}package/ - local path_test_project=${path_test}project/ - local path_test_work=${path_test}work/ local path_test_package_individual=${path_test_package}individual/ + local path_test_package_program=${path_test_package}program/ local path_test_package_stand_alone=${path_test_package}stand_alone/ + local path_test_project=${path_test}project/ + local path_test_work=${path_test}work/ local print_line_first="yes" local print_line_last="yes" local test_system= local test_thread="thread" - local test_thread_individual="thread_individual" + local test_thread_individual="individual_thread" local context= local failure=0 @@ -72,6 +73,7 @@ test_main() { local projects="f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_serialize f_signal f_socket f_status_string f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_path fll_print fll_program fll_status_string" local projects_no_tests="f_type" + local programs="" if [[ $# -gt 0 ]] ; then t=$# @@ -135,10 +137,10 @@ test_main() { path_test= elif [[ ${p} == "-T" || ${p} == "--thread" ]] ; then test_thread="thread" - test_thread_individual="thread_individual" + test_thread_individual="individual_thread" elif [[ ${p} == "-L" || ${p} == "--threadless" ]] ; then test_thread="threadless" - test_thread_individual="" + test_thread_individual= elif [[ ${test_system} == "" ]] ; then test_system="${p}" else @@ -155,6 +157,7 @@ test_main() { path_test=$(echo ${p} | sed -e 's|^//*|/|' -e 's|/*$|/|') path_test_package=${path_test}package/ path_test_package_individual=${path_test_package}individual/ + path_test_package_program=${path_test_package}program/ path_test_package_stand_alone=${path_test_package}stand_alone/ path_test_project=${path_test}project/ path_test_work=${path_test}work/ @@ -412,45 +415,31 @@ test_operate() { ci_arguments="-d -I${includes_path} -d -L${libraries_path}" test_operate_ci_prebuild - - if [[ ${?} -ne 0 ]] ; then - let failure=1 - - return 1 - fi fi - if [[ ${build_project} == "yes" ]] ; then + if [[ ${failure} -eq 0 && ${build_project} == "yes" ]] ; then test_operate_build_tools - - if [[ ${?} -ne 0 ]] ; then - let failure=1 - - return 1 - fi fi - test_operate_build_individual - - if [[ ${?} -ne 0 ]] ; then - let failure=1 - - return 1 + if [[ ${failure} -eq 0 ]] ; then + test_operate_build_individual fi - if [[ ${test_system} == "github" || ${test_system} == "gitlab" ]] ; then - test_operate_ci_pretest - - if [[ ${?} -ne 0 ]] ; then - let failure=1 + if [[ ${failure} -eq 0 ]] ; then + test_operate_build_program + fi - return 1 + if [[ ${failure} -eq 0 ]] ; then + if [[ ${test_system} == "github" || ${test_system} == "gitlab" ]] ; then + test_operate_ci_pretest fi fi - test_operate_tests + if [[ ${failure} -eq 0 ]] ; then + test_operate_tests + fi - return $? + return ${failure} } test_operate_build_individual() { @@ -460,8 +449,8 @@ test_operate_build_individual() { if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then test_print_first_or_always - echo -e "${c_highlight}Cleaning and building package.${c_reset}" - echo -e "${c_title}------------------------------${c_reset}" + echo -e "${c_highlight}Cleaning and building individual package.${c_reset}" + echo -e "${c_title}-----------------------------------------${c_reset}" echo fi @@ -480,12 +469,14 @@ test_operate_build_individual() { echo -e "${c_error}ERROR: Failed to clean and build the individual packages.${c_reset}" fi + let failure=1 + return 1 fi for project in ${projects} ; do - test_operate_build_project "${path_test_package_individual}" "${path_test_work}" "${project}" individual ${test_thread} ${test_thread_individual} + test_operate_build_project "${path_test_package_individual}" "${path_test_work}" "${project}" individual "" ${test_thread} ${test_thread_individual} if [[ ${?} -ne 0 ]] ; then let failure=1 @@ -505,6 +496,45 @@ test_operate_build_individual() { return 0 } +test_operate_build_program() { + local program= + local path_original="${PWD}/" + + if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then + test_print_first_or_always + + echo -e "${c_highlight}Cleaning and building program packages.${c_reset}" + echo -e "${c_title}---------------------------------------${c_reset}" + echo + fi + + if [[ ${verbosity} == "debug" ]] ; then + test_print_first_or_always + + echo "${shell_command} ${path_scripts_package} ${verbose} ${context} -d ${path_test_package} -p rebuild" + fi + + ${shell_command} ${path_scripts_package} ${verbose} ${context} -d ${path_test_package} -p rebuild + + if [[ ${?} -ne 0 ]] ; then + if [[ ${verbosity} != "quiet" ]] ; then + test_print_first + + echo -e "${c_error}ERROR: Failed to clean and build the program packages.${c_reset}" + fi + + let failure=1 + + return 1 + fi + + if [[ ${failure} -eq 1 ]] ; then + return 1 + fi + + return 0 +} + test_operate_build_project() { local path_="${1}" local destination="${2}" @@ -533,6 +563,8 @@ test_operate_build_project() { echo -e "${c_error}ERROR: Package directory '${c_notice}${path_}${project}-${version}${c_error}' is invalid or missing.${c_reset}" fi + let failure=1 + return 1 fi @@ -672,6 +704,8 @@ test_operate_build_tools() { echo -e "${c_error}ERROR: Failed to clean and build the stand_alone fake package.${c_reset}" fi + let failure=1 + return 1 fi @@ -998,7 +1032,6 @@ test_operate_ci_prebuild_libcap() { } test_operate_tests() { - local project= local path_original="${PWD}/" local destination="${path_test_work}" local thread_individual_param= @@ -1008,27 +1041,85 @@ test_operate_tests() { thread_individual_param="-m" fi - for project in ${projects} ; do + if [[ ${projects} != "" ]] ; then + test_operate_tests_projects + fi - if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then + if [[ ${failure} -eq 0 && ${programs} != "" ]] ; then + test_operate_tests_programs + fi + + if [[ ${failure} -eq 1 ]] ; then + return 1 + fi + + return 0 +} + +test_operate_tests_change_to() { + local destination=${1} + + if [[ ${failure} -eq 0 ]] ; then + if [[ ${verbosity} == "debug" ]] ; then test_print_first_or_always - echo -e "${c_highlight}Testing Project ${project}.${c_reset}" - echo -e "${c_title}--------------------------------------${c_reset}" - echo + echo -e "Running '${c_notice}cd ${destination}${c_reset}'." fi - if [[ ! -d ${path_test_package_individual}${project}-${version}/ ]] ; then + cd ${destination} + + if [[ ${?} -ne 0 ]] ; then if [[ ${verbosity} != "quiet" ]] ; then test_print_first - echo -e "${c_error}ERROR: Package directory '${c_notice}${path_test_package_individual}${project}-${version}${c_error}' is invalid or missing.${c_reset}" + echo -e "${c_error}ERROR: Failed to change into directory '${c_notice}${destination}${c_error}'.${c_reset}" test_print_last fi let failure=1 fi + fi +} + +test_operate_tests_name() { + local what=${1} + local name=${2} + + if [[ ${verbosity} != "quiet" && ${verbosity} != "error" ]] ; then + test_print_first_or_always + + echo -e "${c_highlight}Testing ${what} ${name}.${c_reset}" + echo -e "${c_title}--------------------------------------${c_reset}" + echo + fi +} + +test_operate_tests_path_exists() { + local what=${1} + local path_name=${2} + + if [[ ! -d ${path_name}/ ]] ; then + if [[ ${verbosity} != "quiet" ]] ; then + test_print_first + + echo -e "${c_error}ERROR: ${what} directory '${c_notice}${path_name}${c_error}' is invalid or missing.${c_reset}" + + test_print_last + fi + + let failure=1 + fi +} + +test_operate_tests_projects() { + local project= + + for project in ${projects} ; do + + test_operate_tests_name "Project" "${project}" + + test_operate_tests_path_exists "Project" "${path_test_package_individual}${project}-${version}/" if [[ ${failure} -eq 0 ]] ; then if [[ ! -f ${path_test_package_individual}${project}-${version}/data/build/testfile ]] ; then @@ -1048,58 +1139,49 @@ test_operate_tests() { fi fi - if [[ ${failure} -eq 0 ]] ; then - if [[ ${verbosity} == "debug" ]] ; then - test_print_first_or_always - - echo -e "Running '${c_notice}cd ${path_test_package_individual}${project}-${version}/${c_reset}'." - fi + test_operate_tests_change_to "${path_test_package_individual}${project}-${version}/" - cd ${path_test_package_individual}${project}-${version}/ + test_operate_tests_run "project" "${project}" - if [[ ${?} -ne 0 ]] ; then - if [[ ${verbosity} != "quiet" ]] ; then - test_print_first + cd ${path_original} - echo -e "${c_error}ERROR: Failed to change into directory '${c_notice}${path_test_package_individual}${project}-${version}${c_error}'.${c_reset}" + if [[ ${failure} -eq 1 ]] ; then + break; + fi + done - test_print_last - fi + if [[ ${failure} -eq 1 ]] ; then + return 1 + fi - let failure=1 - fi - fi + return 0 +} - if [[ ${failure} -eq 0 ]] ; then - if [[ ${verbosity} == "debug" ]] ; then - test_print_first_or_always +test_operate_tests_programs() { + local program= - if [[ ${build_compiler} == "gcc" ]] ; then - echo "PATH=\"${env_path}\" LD_LIBRARY_PATH=\"${env_libs}\" fake ${verbose} ${context} -w \"${destination}\" -m individual -m ${test_thread} ${thread_individual_param} ${thread_individual_value} -m test clean make -f testfile ${ci_arguments}" - else - echo "PATH=\"${env_path}\" LD_LIBRARY_PATH=\"${env_libs}\" fake ${verbose} ${context} -w \"${destination}\" -m individual -m ${test_thread} ${thread_individual_param} ${thread_individual_value} -m test -m ${build_compiler} clean make -f testfile ${ci_arguments}" - fi - fi + for program in ${programs} ; do - if [[ ${build_compiler} == "gcc" ]] ; then - PATH="${env_path}" LD_LIBRARY_PATH="${env_libs}" fake ${verbose} ${context} -w "${destination}" -m individual -m ${test_thread} ${thread_individual_param} ${thread_individual_value} -m test clean make -f testfile ${ci_arguments} - else - PATH="${env_path}" LD_LIBRARY_PATH="${env_libs}" fake ${verbose} ${context} -w "${destination}" -m individual -m ${test_thread} ${thread_individual_param} ${thread_individual_value} -m test -m ${build_compiler} clean make -f testfile ${ci_arguments} - fi + test_operate_tests_name "Program" "${program}" - if [[ ${?} -ne 0 ]] ; then - if [[ ${verbosity} != "quiet" ]] ; then - test_print_first + test_operate_tests_path_exists "Program" "${path_test_package_program}${program}-${version}/" - echo -e "${c_error}ERROR: Failure while testing project '${c_notice}${project}${c_reset}${c_error}'.${c_reset}" + if [[ ${failure} -eq 0 ]] ; then + if [[ ! -f ${path_test_package_program}${program}-${version}/data/build/testfile ]] ; then + if [[ ${verbosity} == "verbose" || ${verbosity} == "debug" ]] ; then + test_print_first_or_always - test_print_last + echo -e "${c_warning}WARNING: Program '${c_notice}${program}${c_warning}' does not have a testfile.${c_reset}" fi - let failure=1 + continue fi fi + test_operate_tests_change_to "${path_test_package_program}${program}-${version}/" + + test_operate_tests_run "program" "${program}" + cd ${path_original} if [[ ${failure} -eq 1 ]] ; then @@ -1114,6 +1196,41 @@ test_operate_tests() { return 0 } +test_operate_tests_run() { + local what=${1} + local name=${2} + + if [[ ${failure} -eq 0 ]] ; then + if [[ ${verbosity} == "debug" ]] ; then + test_print_first_or_always + + if [[ ${build_compiler} == "gcc" ]] ; then + echo "PATH=\"${env_path}\" LD_LIBRARY_PATH=\"${env_libs}\" fake ${verbose} ${context} -w \"${destination}\" -m individual -m ${test_thread} ${thread_individual_param} ${thread_individual_value} -m test clean make -f testfile ${ci_arguments}" + else + echo "PATH=\"${env_path}\" LD_LIBRARY_PATH=\"${env_libs}\" fake ${verbose} ${context} -w \"${destination}\" -m individual -m ${test_thread} ${thread_individual_param} ${thread_individual_value} -m test -m ${build_compiler} clean make -f testfile ${ci_arguments}" + fi + fi + + if [[ ${build_compiler} == "gcc" ]] ; then + PATH="${env_path}" LD_LIBRARY_PATH="${env_libs}" fake ${verbose} ${context} -w "${destination}" -m individual -m ${test_thread} ${thread_individual_param} ${thread_individual_value} -m test clean make -f testfile ${ci_arguments} + else + PATH="${env_path}" LD_LIBRARY_PATH="${env_libs}" fake ${verbose} ${context} -w "${destination}" -m individual -m ${test_thread} ${thread_individual_param} ${thread_individual_value} -m test -m ${build_compiler} clean make -f testfile ${ci_arguments} + fi + + if [[ ${?} -ne 0 ]] ; then + if [[ ${verbosity} != "quiet" ]] ; then + test_print_first + + echo -e "${c_error}ERROR: Failure while testing ${what} '${c_notice}${name}${c_reset}${c_error}'.${c_reset}" + + test_print_last + fi + + let failure=1 + fi + fi +} + test_print_first() { if [[ ${print_line_first} == "yes" ]] ; then @@ -1158,6 +1275,12 @@ test_cleanup() { unset test_operate_ci_pretest unset test_operate_ci_pretest_cmocka unset test_operate_tests + unset test_operate_tests_change_to + unset test_operate_tests_name + unset test_operate_tests_path_exists + unset test_operate_tests_projects + unset test_operate_tests_programs + unset test_operate_tests_run unset test_print_first unset test_print_first_or_always unset test_print_last -- 1.8.3.1