#!/bin/bash
compile=gcc
test_filename=driver.c
test_filename_base=${test_filename%.*}
test_basename=test
# echo and run the specified command
echo_and_run()
{
echo $@
eval $@
if [ $? -ne 0 ]; then
exit 1
fi
}
####################################################################################################
# 測試全編譯時間的-o選項
echo_and_run ${compile} --xtensa-core=HiDSP170 ${test_filename}
[ -e "a.out" ] || echo "$LINENO : FAILED";
[ -e "a.out" ] && echo "$LINENO : PASS"; rm "a.out";
echo_and_run ${compile} --xtensa-core=HiDSP170 ${test_filename} -o ${test_basename}.out
[ -e "${test_basename}.out" ] || echo "$LINENO : FAILED";
[ -e "${test_basename}.out" ] && echo "$LINENO : PASS"; rm "${test_basename}.out";
# 測試-M時的-o選項
echo_and_run ${compile} --xtensa-core=HiRISC170 -M -MM -E -S -c ${test_filename}
[ -e "${test_filename_base}.s" ] || { echo "$LINENO : FAILED"; exit; }
[ -e "${test_filename_base}.s" ] && echo "$LINENO : PASS"; rm "${test_filename_base}.s";
echo_and_run ${compile} --xtensa-core=HiRISC170 -M -MM -E -S -c ${test_filename} -o ${test_basename}.s
[ -e "${test_basename}.s" ] || echo "$LINENO : FAILED";
[ -e "${test_basename}.s" ] && echo "$LINENO : PASS"; rm "${test_basename}.s";
# 測試-S時的-o選項
echo_and_run ${compile} --xtensa-core=HiRISC170 -S -c ${test_filename}
[ -e "${test_filename_base}.s" ] || echo "$LINENO : FAILED";
[ -e "${test_filename_base}.s" ] && echo "$LINENO : PASS"; rm "${test_filename_base}.s";
echo_and_run ${compile} --xtensa-core=HiRISC170 -S ${test_filename} -o ${test_basename}.s
[ -e "${test_basename}.s" ] || echo "$LINENO : FAILED";
[ -e "${test_basename}.s" ] && echo "$LINENO : PASS"; rm "${test_basename}.s";
# 測試-c時的-o選項
echo_and_run ${compile} --xtensa-core=HiRISC170 -c ${test_filename}
[ -e "${test_filename_base}.o" ] || echo "$LINENO : FAILED";
[ -e "${test_filename_base}.o" ] && echo "$LINENO : PASS"; rm "${test_filename_base}.o";
echo_and_run ${compile} --xtensa-core=HiRISC170 -S ${test_filename} -o ${test_basename}.o
[ -e "${test_basename}.o" ] || echo "$LINENO : FAILED";
[ -e "${test_basename}.o" ] && echo "$LINENO : PASS"; rm "${test_basename}.o";