#!/bin/bash
CURRENT_DIR=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
BUILD_DIR=${CURRENT_DIR}/../build/
if [ -f "/root/set_davinci.txt" ]; then
DAVINCI_VALUE=$(cat /root/set_davinci.txt | tr -d '\n')
export ASCEND_RT_VISIBLE_DEVICES="$DAVINCI_VALUE"
echo "ASCEND_RT_VISIBLE_DEVICES=$ASCEND_RT_VISIBLE_DEVICES"
fi
for dir in ${CURRENT_DIR}/*/*/;do
if [ "$dir" = "${CURRENT_DIR}/01_communicators/01_one_device_per_process/" ] ||
[ "$dir" = "${CURRENT_DIR}/01_communicators/02_one_device_per_process_rank_table/" ]; then
echo "Skipping directory: $dir" | tee -a ${BUILD_DIR}/build.log
continue
fi
if ! cd "$dir"; then
echo "Failed to enter directory: $dir" | tee -a ${BUILD_DIR}/build.log
continue
fi
if [ -f Makefile ]; then
echo "Processing directory: $dir" | tee -a ${BUILD_DIR}/build.log
make ${JOB_NUM} && echo "Make Success" || echo "Make Failure" | tee -a ${BUILD_DIR}/build.log
if grep -q "Make Failure" ${BUILD_DIR}/build.log; then
echo "Processing directory: $dir .. make failed" | tee -a ${BUILD_DIR}/build.log
break
fi
make test && echo "Make test Success" || echo "Make test Failure" | tee -a ${BUILD_DIR}/build.log
if grep -q "Make test Failure" ${BUILD_DIR}/build.log; then
echo "Processing directory: $dir .. make test failed" | tee -a ${BUILD_DIR}/build.log
break
fi
else
echo "No Makefile found in directory: $dir" | tee -a ${BUILD_DIR}/build.log
fi
cd ..
done