diff --git a/.gitignore b/.gitignore index a9ed6f9eb39679115bc7f5eb3fd89644732ddb87..f87bc41702f02e531e27852a9e5c04011f2e5e54 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ docs/mpi-start.out docs/mpi-start.pdf docs/mpi-start.tex docs/mpi-start.toc - +build +src/mpi-start +tests/test.o diff --git a/config/Makefile.in b/config/Makefile.in index 34bf89c2475d8933f3eed124dd3aeeb5fea17fe0..1c9b6a8879dea311e82b3f011caed33ea69b0300 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -1,13 +1,21 @@ -all: mpi-config.local - -mpi-config.local: - cp mpi-config.local.template mpi-config.local +all: clean: install: install -d $(DESTDIR)/$(moduledir) - install -m 0644 mpi-config.local $(DESTDIR)/$(moduledir)/ + install -m 0644 mpi-config.local.template $(DESTDIR)/$(moduledir)/ + install -m 0644 mpi-config.debian $(DESTDIR)/$(moduledir)/ + install -m 0644 mpi-config.el5-i386 $(DESTDIR)/$(moduledir)/ + install -m 0644 mpi-config.el6-i386 $(DESTDIR)/$(moduledir)/ + install -m 0644 mpi-config.el5-x86_64 $(DESTDIR)/$(moduledir)/ + install -m 0644 mpi-config.el6-x86_64 $(DESTDIR)/$(moduledir)/ uninstall: - rm -f $(DESTDIR)/$(moduledir)/mpi-config.local + rm -f $(DESTDIR)/$(moduledir)/mpi-config.local.template + rm -f $(DESTDIR)/$(moduledir)/mpi-config.debian + rm -f $(DESTDIR)/$(moduledir)/mpi-config.el5-i386 + rm -f $(DESTDIR)/$(moduledir)/mpi-config.el6-i386 + rm -f $(DESTDIR)/$(moduledir)/mpi-config.el5-x86_64 + rm -f $(DESTDIR)/$(moduledir)/mpi-config.el6-x86_64 + diff --git a/configure b/configure index 4973bd26163746f876b04ef4878596bf78d8b910..51e9699a598212719c4a14afd19768c3881b5bab 100755 --- a/configure +++ b/configure @@ -143,7 +143,7 @@ modules/schedulers/pbs/Makefile modules/schedulers/sge/Makefile modules/schedulers/slurm/Makefile' -maintainerclean_files="$files config/mpi-config.local" +maintainerclean_files="$files" for f in $files ; do cat > $f << EOF @@ -161,33 +161,33 @@ done ################### DEFAULT CONFIG FILE FOR MPI ######################## -if [ -z "$build" ] ; then - # assume uname is correct as target arch - arch=`uname -m` -else - echo "$build" | grep "x86_64" > /dev/null - if [ $? -eq 0 ] ; then - arch="x86_64" - else - # assume i386 - arch="i386" - fi -fi - -if [ -z "$dist" ] ; then - if [ -z "target" ]; then - # probably we are on debian, no arch - dist=.debian - arch="" - else - # dist is missing in some el5 (CentOS/SL) - echo "$target" | grep "redhat" > /dev/null && dist=".el5" - fi -fi - -if [ -f config/mpi-config.local${dist}-${arch} ] ; then - cp config/mpi-config.local${dist}-${arch} config/mpi-config.local -fi +#if [ -z "$build" ] ; then +# # assume uname is correct as target arch +# arch=`uname -m` +#else +# echo "$build" | grep "x86_64" > /dev/null +# if [ $? -eq 0 ] ; then +# arch="x86_64" +# else +# # assume i386 +# arch="i386" +# fi +#fi +# +#if [ -z "$dist" ] ; then +# if [ -z "target" ]; then +# # probably we are on debian, no arch +# dist=.debian +# arch="" +# else +# # dist is missing in some el5 (CentOS/SL) +# echo "$target" | grep "redhat" > /dev/null && dist=".el5" +# fi +#fi +# +#if [ -f config/mpi-config.local${dist}-${arch} ] ; then +# cp config/mpi-config.local${dist}-${arch} config/mpi-config.local +#fi ######################################################################## diff --git a/src/mpi-start.in b/src/mpi-start.in index 1146d4f282cafc4322f3ea41f9b8869bb7a04655..c744f9994d069ef76db98a392624fa942e2f5dc3 100755 --- a/src/mpi-start.in +++ b/src/mpi-start.in @@ -441,6 +441,62 @@ mpi_start_get_plugin() { } +#====================================================================== +# Load the mpi configuration variables +#====================================================================== +mpi_start_load_mpi_config() { + local pfx=mpi-config + local cfiles=${pfx}.${MPI_START_UNAME} + if test "x${MPI_START_OS_DIST_TYPE}" != "x" ; then + cfiles="${pfx}.${MPI_START_OS_DIST_TYPE} $cfiles" + if test "x${MPI_START_OS_RELEASE_MAJOR}" != "x" ; then + cfiles="${pfx}.${MPI_START_OS_DIST_TYPE}${MPI_START_OS_RELEASE_MAJOR} $cfiles" + if test "x${MPI_START_ARCH}" != "x" ; then + cfiles="${pfx}.${MPI_START_OS_DIST_TYPE}${MPI_START_OS_RELEASE_MAJOR}-${MPI_START_ARCH} $cfiles" + fi + fi + fi + for c in $cfiles; do + mpi_start_get_plugin $c 1 + if test "x${MPI_START_PLUGIN_FILES}" != "x" ; then + info_msg "Loading configuration from $MPI_START_PLUGIN_FILES" + . ${MPI_START_PLUGIN_FILES} + break + fi + done + # finally load the mpi-config.local if available + mpi_start_get_plugin "mpi-config.local" 1 + if test "x${MPI_START_PLUGIN_FILES}" != "x" ; then + info_msg "Loading local configuration from $MPI_START_PLUGIN_FILES" + . ${MPI_START_PLUGIN_FILES} + fi +} + +#====================================================================== +# Try to find out the current OS distribution +#====================================================================== +mpi_start_detect_os() { + MPI_START_UNAME=`uname -s | tr "[:upper:]" "[:lower:]"` + MPI_START_ARCH=`uname -m` + + if test "x${MPI_START_UNAME}" = "xlinux" ; then + which lsb_release 2> /dev/null > /dev/null + if test $? -eq 0 ; then + export MPI_START_OS_DIST=`lsb_release -si 2> /dev/null` + echo $MPI_START_OS_DIST | egrep -i "debian|ubuntu" > /dev/null + if test $? -eq 0 ; then + export MPI_START_OS_DIST_TYPE="debian" + fi + echo $MPI_START_OS_DIST | egrep -i "redhat|scientificlinux" > /dev/null + if test $? -eq 0 ; then + export MPI_START_OS_DIST_TYPE="el" + fi + export MPI_START_OS_RELEASE=`lsb_release -sr 2> /dev/null` + export MPI_START_OS_RELEASE_MAJOR=`echo $MPI_START_OS_RELEASE | cut -f1 -d"."` + fi + fi +} + #====================================================================== # Checks that mpi-start are correct and coherent #====================================================================== @@ -468,7 +524,8 @@ mpi_start_check_options() { set -x fi - MPI_START_UNAME=`uname -s | tr "[:upper:]" "[:lower:]"` + # detect os flavor + mpi_start_detect_os if test -r "${I2G_MPI_CONFIG}" ; then . ${I2G_MPI_CONFIG} @@ -546,11 +603,8 @@ mpi_start_check_options() { dump_env fi - # source the local mpi-start variables if any - mpi_start_get_plugin "mpi-config.local" 1 - if test "x${MPI_START_PLUGIN_FILES}" != "x" ; then - . ${MPI_START_PLUGIN_FILES} - fi + # try to source the OS mpi variables + mpi_start_load_mpi_config } diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 34aa74236dfb5198eebb7b5ed8d3b6d6e3a612ac..4439263650535accbee49e6f0904cc17c9307d80 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -30,18 +30,18 @@ REMOVE_MY_SHUNIT=0 # tests to run RUN_UNIT_TESTS=1 -RUN_BASIC_TESTS=1 -RUN_HOOK_TESTS=1 -RUN_NP_TESTS=1 -RUN_SCH_TESTS=1 -RUN_FSDETECT_TESTS=1 -RUN_AFFINITY_TESTS=1 +RUN_BASIC_TESTS=0 +RUN_HOOK_TESTS=0 +RUN_NP_TESTS=0 +RUN_SCH_TESTS=0 +RUN_FSDETECT_TESTS=0 +RUN_AFFINITY_TESTS=0 # if running these tests, ensure you have proper environment loaded! -RUN_OMP_TESTS=1 -RUN_MPICH2_TESTS=1 +RUN_OMP_TESTS=0 +RUN_MPICH2_TESTS=0 RUN_MVAPICH2_TESTS=0 RUN_MPICH_TESTS=0 -RUN_OPENMPI_TESTS=1 +RUN_OPENMPI_TESTS=0 RUN_LAM_TESTS=0 export MPI_OPENMPI_MPIEXEC_PARAMS="--mca btl ^openib" @@ -96,6 +96,8 @@ if test "x${RUN_UNIT_TESTS}" = "x1" ; then ./test_trac_63.sh || exitcode=1 echo "* Issue #1" ./test_issue_1.sh || exitcode=1 + echo "* Issue #6" + ./test_issue_6.sh || exitcode=1 echo "***************************" fi if test "x${RUN_BASIC_TESTS}" = "x1" ; then diff --git a/tests/test_issue_6.sh b/tests/test_issue_6.sh new file mode 100755 index 0000000000000000000000000000000000000000..1dfb075e665890d7efb60906625694a8c50138db --- /dev/null +++ b/tests/test_issue_6.sh @@ -0,0 +1,105 @@ +#!/bin/bash +# Test for https://github.com/IFCA/mpi-start/issues/1 + +oneTimeSetUp () { + export I2G_MPI_START_ENABLE_TESTING="TEST" + # source the mpi-start code to have all functions + . $I2G_MPI_START + mpi_start_check_options + export I2G_MPI_START_VERBOSE=1 +} + +setUp() { + export MPI_START_ETC_LIST=`$MYMKTEMP -d` + export MPI_LOADED=0 +} + +tearDown() { + rm -rf $MPI_START_ETC_LIST +} + +oneTimeTearDown () { + for f in $MPI_START_CLEANUP_FILES; do + [ -f "$f" ] && rm -f $f + [ -d "$f" ] && rm -rf $f + done +} + +testConfigDistReleaseArch() { + echo "export MPI_LOADED=1" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_OS_DIST_TYPE}${MPI_START_OS_RELEASE_MAJOR}-${MPI_START_ARCH} + assertEquals "0" "$MPI_LOADED" + mpi_start_load_mpi_config + assertEquals "1" "$MPI_LOADED" +} + +testConfigDistRelease() { + echo "export MPI_LOADED=1" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_OS_DIST_TYPE}${MPI_START_OS_RELEASE_MAJOR} + assertEquals "0" "$MPI_LOADED" + mpi_start_load_mpi_config + assertEquals "1" "$MPI_LOADED" +} + +testConfigDist() { + echo "export MPI_LOADED=1" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_OS_DIST_TYPE} + assertEquals "0" "$MPI_LOADED" + mpi_start_load_mpi_config + assertEquals "1" "$MPI_LOADED" +} + +testConfigUname() { + echo "export MPI_LOADED=1" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_UNAME} + assertEquals "0" "$MPI_LOADED" + mpi_start_load_mpi_config + assertEquals "1" "$MPI_LOADED" +} + +testConfigLocal() { + echo "export MPI_LOADED=1" > $MPI_START_ETC_LIST/mpi-config.local + assertEquals "0" "$MPI_LOADED" + mpi_start_load_mpi_config + assertEquals "1" "$MPI_LOADED" +} + +testConfigOrderDistReleaseArch() { + echo "export MPI_LOADED=1" > $MPI_START_ETC_LIST/mpi-config.local + echo "export MPI_LOADED_2=1" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_OS_DIST_TYPE}${MPI_START_OS_RELEASE_MAJOR}-${MPI_START_ARCH} + echo "export MPI_LOADED_2=2" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_OS_DIST_TYPE}${MPI_START_OS_RELEASE_MAJOR} + echo "export MPI_LOADED_2=3" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_OS_DIST_TYPE} + echo "export MPI_LOADED_2=4" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_UNAME} + assertEquals "0" "$MPI_LOADED" + mpi_start_load_mpi_config + assertEquals "1" "$MPI_LOADED" + assertEquals "1" "$MPI_LOADED_2" +} + +testConfigOrderDistRelease() { + echo "export MPI_LOADED=1" > $MPI_START_ETC_LIST/mpi-config.local + echo "export MPI_LOADED_2=2" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_OS_DIST_TYPE}${MPI_START_OS_RELEASE_MAJOR} + echo "export MPI_LOADED_2=3" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_OS_DIST_TYPE} + echo "export MPI_LOADED_2=4" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_UNAME} + assertEquals "0" "$MPI_LOADED" + mpi_start_load_mpi_config + assertEquals "1" "$MPI_LOADED" + assertEquals "2" "$MPI_LOADED_2" +} + +testConfigOrderDist() { + echo "export MPI_LOADED=1" > $MPI_START_ETC_LIST/mpi-config.local + echo "export MPI_LOADED_2=3" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_OS_DIST_TYPE} + echo "export MPI_LOADED_2=4" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_UNAME} + assertEquals "0" "$MPI_LOADED" + mpi_start_load_mpi_config + assertEquals "1" "$MPI_LOADED" + assertEquals "3" "$MPI_LOADED_2" +} + +testConfigOrderUname() { + echo "export MPI_LOADED=1" > $MPI_START_ETC_LIST/mpi-config.local + echo "export MPI_LOADED_2=4" > $MPI_START_ETC_LIST/mpi-config.${MPI_START_UNAME} + assertEquals "0" "$MPI_LOADED" + mpi_start_load_mpi_config + assertEquals "1" "$MPI_LOADED" + assertEquals "4" "$MPI_LOADED_2" +} + +. $SHUNIT2