Skip to content

Commit

Permalink
Updates to unit tests (for running on arm64 Mac)
Browse files Browse the repository at this point in the history
  • Loading branch information
perwin committed Jul 12, 2024
1 parent 04b4373 commit cc4c945
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 25 deletions.
20 changes: 18 additions & 2 deletions define_unittest_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
# "-w" suppresses all warnings
# "-Wl,-no_compact_unwind" is for suppressing the silly "no compact unwind"
# warnings from the clang linker.

if [[ $OSTYPE == darwin* ]]
then
CPP="g++ -w -Wl,-no_compact_unwind"
CC=gcc
# CPP=g++-5
# CC=gcc-5
else
CPP="g++ -w"
CC=gcc
Expand All @@ -36,8 +35,25 @@ fi
CXXTESTGEN=cxxtestgen


# Locations of external libraries (CFITSIO, FFTW3, GSL, NLopt)
# Figure out which type of macOS architecture we're running under

# defaults for Linux and for x86-64 macOS
EXTERNAL_INCLUDE_PATH="/usr/local/include"
EXTERNAL_LIB_PATH="/usr/local/lib"
ARCH=$(uname -m)
# if we're running on an arm64 (Apple silicon) Mac, use Homebrew's arm64 location
if [[ $OSTYPE == darwin* ]] && [[ "$ARCH" -eq "arm64" ]]
then
EXTERNAL_INCLUDE_PATH="/opt/homebrew/include"
EXTERNAL_LIB_PATH="/opt/homebrew/lib"
fi


export CPP
export CC
export CXXTEST
export CXXTESTGEN
export LDFLAGS
export EXTERNAL_INCLUDE_PATH
export EXTERNAL_LIB_PATH
5 changes: 5 additions & 0 deletions run_unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ echo $RESULT
RESULT+=$?
echo $RESULT

# Unit tests for psf_interpolators
./run_unittest_psf_interpolators.sh
RESULT+=$?
echo $RESULT

# NOTE: the following code will correctly set up and run unittest_oversampled_region.t.h;
# However, that "unit test" doesn't perform proper tests; instead, it generates test image
# output meant to be inspected with DS9. Therefore, it is currently commented out.
Expand Down
4 changes: 2 additions & 2 deletions run_unittest_add_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function_objects/func_pointsource-rot.cpp function_objects/func_peanut_dattathri
function_objects/helper_funcs.cpp function_objects/helper_funcs_3d.cpp \
function_objects/psf_interpolators.cpp \
core/mersenne_twister.cpp core/mp_enorm.cpp \
-I. -Icore -Isolvers -I/usr/local/include -Ifunction_objects -I$CXXTEST -L/usr/local/lib \
-lfftw3_threads -lfftw3 -lcfitsio -lgsl -lgslcblas -lm
-I. -Icore -Isolvers -I$EXTERNAL_INCLUDE_PATH -Ifunction_objects -I$CXXTEST \
-L$EXTERNAL_LIB_PATH -lfftw3_threads -lfftw3 -lcfitsio -lgsl -lgslcblas -lm
if [ $? -eq 0 ]
then
echo "Running unit tests for add_functions:"
Expand Down
2 changes: 1 addition & 1 deletion run_unittest_commandlineparser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo "Generating and compiling unit tests for command-line parser..."
$CXXTESTGEN --error-printer -o test_runner_cmparser.cpp unit_tests/unittest_commandline_parser.t.h
$CPP -std=c++11 -Wno-write-strings -o test_runner_cmparser test_runner_cmparser.cpp \
core/commandline_parser.cpp core/utilities.cpp -I. -Icore -Isolvers -Ifunction_objects \
-I/usr/local/include -I$CXXTEST -L/usr/local/lib
-I$CXXTEST
if [ $? -eq 0 ]
then
echo "Running unit tests for commandline_parser:"
Expand Down
2 changes: 1 addition & 1 deletion run_unittest_configfileparser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ echo
echo "Generating and compiling unit tests for config-file parser..."
$CXXTESTGEN --error-printer -o test_runner_config.cpp unit_tests/unittest_config_parser.t.h
$CPP -std=c++11 -o test_runner_config test_runner_config.cpp core/config_file_parser.cpp \
core/utilities.cpp -I. -Icore -Isolvers -Ifunction_objects -I/usr/local/include -I$CXXTEST
core/utilities.cpp -I. -Icore -Isolvers -Ifunction_objects -I$CXXTEST
if [ $? -eq 0 ]
then
echo "Running unit tests for config_file_parser:"
Expand Down
4 changes: 2 additions & 2 deletions run_unittest_downsample.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ echo
echo "Generating and compiling unit tests for downsample..."
$CXXTESTGEN --error-printer -o test_runner_downsample.cpp unit_tests/unittest_downsample.t.h
$CPP -std=c++11 -o test_runner_downsample test_runner_downsample.cpp core/downsample.cpp \
core/image_io.cpp -I. -Icore -Isolvers -I/usr/local/include -I$CXXTEST \
-L/usr/local/lib -lcfitsio -lfftw3 -lm
core/image_io.cpp -I. -Icore -Isolvers -I$EXTERNAL_INCLUDE_PATH -I$CXXTEST \
-L$EXTERNAL_LIB_PATH -lcfitsio -lfftw3 -lm
if [ $? -eq 0 ]
then
echo "Running unit tests for downsample:"
Expand Down
4 changes: 2 additions & 2 deletions run_unittest_funcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function_objects/func_pointsource.cpp function_objects/psf_interpolators.cpp \
function_objects_1d/func1d_exp_test.cpp \
function_objects/helper_funcs.cpp function_objects/helper_funcs_3d.cpp \
function_objects/integrator.cpp core/utilities.cpp \
-I/usr/local/include -I$CXXTEST -I. -Icore -Isolvers -Ifunction_objects \
-L/usr/local/lib -lm -lgsl -lgslcblas
-I$EXTERNAL_INCLUDE_PATH -I$CXXTEST -I. -Icore -Isolvers -Ifunction_objects \
-L$EXTERNAL_LIB_PATH -lm -lgsl -lgslcblas
if [ $? -eq 0 ]
then
echo "Running unit tests for function objects:"
Expand Down
2 changes: 1 addition & 1 deletion run_unittest_getimages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo "Generating and compiling unit tests for getimages..."
$CXXTESTGEN --error-printer -o test_runner_getimages.cpp unit_tests/unittest_getimages.t.h
$CPP -std=c++11 -o test_runner_getimages test_runner_getimages.cpp \
core/getimages.cpp core/image_io.cpp core/psf_oversampling_info.cpp core/utilities.cpp \
-L/usr/local/lib -lcfitsio -lfftw3 -I. -I/usr/local/include -Icore -Isolvers \
-L$EXTERNAL_LIB_PATH -lcfitsio -lfftw3 -I. -I$EXTERNAL_INCLUDE_PATH -Icore -Isolvers \
-Ifunction_objects -I$CXXTEST
if [ $? -eq 0 ]
then
Expand Down
2 changes: 1 addition & 1 deletion run_unittest_imageio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ echo
echo "Generating and compiling unit tests for image_io..."
$CXXTESTGEN --error-printer -o test_runner_imageio.cpp unit_tests/unittest_image_io.t.h
$CPP -std=c++11 -o test_runner_imageio test_runner_imageio.cpp core/image_io.cpp -I. \
-I/usr/local/include -Icore -I$CXXTEST -L/usr/local/lib -lcfitsio -lfftw3
-I$EXTERNAL_INCLUDE_PATH -Icore -I$CXXTEST -L$EXTERNAL_LIB_PATH -lcfitsio -lfftw3
if [ $? -eq 0 ]
then
echo "Running unit tests for image_io:"
Expand Down
4 changes: 2 additions & 2 deletions run_unittest_model_object.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ function_objects/func_pointsource.cpp function_objects/func_pointsource-rot.cpp
function_objects/func_peanut_dattathri.cpp \
function_objects/helper_funcs.cpp function_objects/helper_funcs_3d.cpp \
function_objects/psf_interpolators.cpp \
-I. -Icore -Isolvers -I/usr/local/include -Ifunction_objects -I$CXXTEST \
-L/usr/local/lib -lfftw3_threads -lcfitsio -lfftw3 -lgsl -lgslcblas -lm
-I. -Icore -Isolvers -I$EXTERNAL_INCLUDE_PATH -Ifunction_objects -I$CXXTEST \
-L$EXTERNAL_LIB_PATH -lfftw3_threads -lcfitsio -lfftw3 -lgsl -lgslcblas -lm
if [ $? -eq 0 ]
then
echo "Running unit tests for model_object:"
Expand Down
2 changes: 1 addition & 1 deletion run_unittest_mpfit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo "Generating and compiling unit tests for mpfit..."
$CXXTESTGEN --error-printer -o test_runner_mpfit.cpp unit_tests/unittest_mpfit.t.h
$CPP -std=c++11 -o test_runner_mpfit test_runner_mpfit.cpp core/mp_enorm.cpp \
core/utilities.cpp solvers/mpfit.cpp -I. -Icore -Isolvers -Ifunction_objects \
-I/usr/local/include -I$CXXTEST
-I$CXXTEST
if [ $? -eq 0 ]
then
echo "Running unit tests for mpfit:"
Expand Down
3 changes: 2 additions & 1 deletion run_unittest_options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ NC='\033[0m' # No Color
echo
echo "Generating and compiling unit tests for options_makeimage..."
$CXXTESTGEN --error-printer -o test_runner_options.cpp unit_tests/unittest_options.t.h
$CPP -std=c++11 -o test_runner_options test_runner_options.cpp -I. -Icore -I/usr/local/include -I$CXXTEST
$CPP -std=c++11 -o test_runner_options test_runner_options.cpp -I. -Icore \
-I$CXXTEST
if [ $? -eq 0 ]
then
echo "Running unit tests for OptionsBase and derived classes:"
Expand Down
4 changes: 2 additions & 2 deletions run_unittest_psf_interpolators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ echo "Generating and compiling unit tests for PsfInterpolator classes..."
$CXXTESTGEN --error-printer -o test_runner_funcs.cpp unit_tests/unittest_psf_interpolators.t.h
$CPP -std=c++11 -o test_runner_funcs test_runner_funcs.cpp \
function_objects/psf_interpolators.cpp core/image_io.cpp \
-I/usr/local/include -I$CXXTEST -I. -Icore -Isolvers -Ifunction_objects \
-L/usr/local/lib -lm -lcfitsio -lfftw3 -lgsl -lgslcblas
-I$EXTERNAL_INCLUDE_PATH -I$CXXTEST -I. -Icore -Isolvers -Ifunction_objects \
-L$EXTERNAL_LIB_PATH -lm -lcfitsio -lfftw3 -lgsl -lgslcblas
if [ $? -eq 0 ]
then
echo "Running unit tests for PsfInterpolator classes:"
Expand Down
4 changes: 2 additions & 2 deletions run_unittest_psf_oversampling_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ $CXXTESTGEN --error-printer -o test_runner_psf_oversampling_info.cpp \
unit_tests/unittest_psf_oversampling_info.t.h
$CPP -std=c++11 -o test_runner_psf_oversampling_info \
test_runner_psf_oversampling_info.cpp core/psf_oversampling_info.cpp core/utilities.cpp \
-L/usr/local/lib -lfftw3 -I. -Icore -Isolvers -Ifunction_objects \
-I/usr/local/include -I$CXXTEST
-L$EXTERNAL_LIB_PATH -lfftw3 -I. -Icore -Isolvers -Ifunction_objects \
-I$EXTERNAL_INCLUDE_PATH -I$CXXTEST
if [ $? -eq 0 ]
then
echo "Running unit tests for psf_oversampling_info:"
Expand Down
4 changes: 2 additions & 2 deletions run_unittest_setup_model_object.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ $CPP -std=c++11 -o test_runner_setup_modelobj test_runner_setup_modelobj.cpp cor
core/setup_model_object.cpp core/utilities.cpp core/convolver.cpp core/config_file_parser.cpp \
core/mersenne_twister.cpp core/mp_enorm.cpp core/oversampled_region.cpp core/downsample.cpp \
core/image_io.cpp core/psf_oversampling_info.cpp function_objects/psf_interpolators.cpp \
-I. -Icore -Isolvers -I/usr/local/include -Ifunction_objects -I$CXXTEST \
-L/usr/local/lib -lfftw3_threads -lcfitsio -lfftw3 -lgsl -lgslcblas -lm
-I. -Icore -Isolvers -I$EXTERNAL_INCLUDE_PATH -Ifunction_objects -I$CXXTEST \
-L$EXTERNAL_LIB_PATH -lfftw3_threads -lcfitsio -lfftw3 -lgsl -lgslcblas -lm
if [ $? -eq 0 ]
then
echo "Running unit tests for setup_model_object:"
Expand Down
3 changes: 1 addition & 2 deletions run_unittest_solverresults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ echo
echo "Generating and compiling unit tests for solver_results..."
$CXXTESTGEN --error-printer -o test_runner_solver_results.cpp unit_tests/unittest_solver_results.t.h
$CPP -std=c++11 -o test_runner_solver_results test_runner_solver_results.cpp \
solvers/solver_results.cpp -I. -Isolvers -Ifunction_objects -Icore \
-I/usr/local/include -I$CXXTEST
solvers/solver_results.cpp -I. -Isolvers -Ifunction_objects -Icore -I$CXXTEST
if [ $? -eq 0 ]
then
echo "Running unit tests for solver_results:"
Expand Down
2 changes: 1 addition & 1 deletion run_unittest_utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ echo
echo "Generating and compiling unit tests for utilities..."
$CXXTESTGEN --error-printer -o test_runner_utilities.cpp unit_tests/unittest_utilities.t.h
$CPP -std=c++11 -o test_runner_utilities test_runner_utilities.cpp core/utilities.cpp \
-I. -Icore -Isolvers -Ifunction_objects -I/usr/local/include -I$CXXTEST
-I. -Icore -Isolvers -Ifunction_objects -I$CXXTEST
if [ $? -eq 0 ]
then
echo "Running unit tests for utilities:"
Expand Down

0 comments on commit cc4c945

Please sign in to comment.