ftrn_test.sh 3.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
#!/bin/bash

# $1 - test list

TEST_LIST=$1
echo "Type in 6 digit serial from the sticker"
read -n 6 SN

echo " "
echo "To confirm serial $SN press Enter or Escape to finish"
read -s -n 1 ANS
echo " "
if [ "$ANS" == $'\e' ]; then
  echo "END TEST: $(date)"
  exit
fi

read -p "Check that fan is ON and blowing over FPGA. Press Enter" -n 1
read -p "Check that Display is attached to the board. Press Enter" -n 1
read -p "Check SFP is inserted and that WR fiber is connected to WR master. Press Enter" -n 1
read -p "Check LEMO cables are connected to IO1 and IO3. Press Enter" -n 1


#set paths
PTS=$(pwd)
export $PTS

TEST_LOG_DIR=/home/$(whoami)/Desktop/board_test_reports

TEST_DELIM1='###############################################################################';
TEST_DELIM2='-------------------------------------------------------------------------------';


# assemble folder name for the board with serial SN
SN_LOG_NAME="amc"
SN_LOG_NAME+="_sn-$SN"

echo "SN_LOG_NAME : $SN_LOG_NAME"
SN_LOG_FOLDER="$TEST_LOG_DIR/$SN_LOG_NAME"

if [[ -d $SN_LOG_FOLDER ]];then
  echo "Using existing folder : $SN_LOG_FOLDER"
else 
  echo "Creating SN report folder : $SN_LOG_FOLDER"
  mkdir $SN_LOG_FOLDER
fi


# assemble folder and file name	for the test
TEST_START=`date +%s`
TEST_TIME=`date "+%y-%m-%d_%H-%M-%S"`

SN_TIME_LOG="$SN_LOG_NAME_$TEST_TIME"
echo "SN_TIME_LOG : $SN_TIME_LOG"

LOG_FOLDER+="$SN_LOG_FOLDER/$SN_TIME_LOG"
mkdir $LOG_FOLDER
echo "LOG_FOLDER : $LOG_FOLDER"

LOG_FILE="$LOG_FOLDER/$SN_TIME_LOG.log"
echo "LOG_FILE: $LOG_FILE"

# create log file
touch $LOG_FILE


date | tee $LOG_FILE
echo "SN   : $SN"      | tee -a $LOG_FILE

#TESTS
#------------------------------------------------------------------------------
# ';' is the delimiter here, and there are three fields on each line in the file
# IFS set below is restricted to the context of `read`, it doesn't affect any other code
while IFS=';' read -r cmd testname folder testfile param1 param2 param3; do
  # process the fields 
  # if the line has less than three fields, the missing fields will be set to an empty string 
  # if the line has more than three fields, `field3` will get all the values, including the 
  # third field plus the delimiter(s) 
  
  
#  echo "$cmd : $testname : $folder : $testfile : $param1 : $param2 : $param3;"
  
  if [ "$cmd" == "x" ];then # xecute command
  
    echo $TEST_DELIM1  | tee -a $LOG_FILE  
    echo "START : $(date)" | tee -a $LOG_FILE 
    
    if [ "$param1" == "PTS" ];then
      param1=$PTS
    fi

    TESTLOG=$LOG_FOLDER/$testfile
    TESTLOG+="_out.txt"
    testfile+=".sh"
    printf "$testname\n" | tee -a $LOG_FILE  #| tee -a $TESTLOG
    cd $folder
    rm -f resp.txt # delete previous test report
    
    ./$testfile $param1 $param2 $param3  < /dev/tty # | tee resp_main.txt
    RESP=`cat resp.txt`
    sleep 0.5
    
    cd $PTS
    printf "%s\n" "$RESP" > $TESTLOG
 
    PTS_STATUS=`echo "$RESP" | grep "PTS_STATUS:"`
    printf "%s\n" "$PTS_STATUS" | tee -a $LOG_FILE
    printf "END : $(date)\n\n"  | tee -a $LOG_FILE
    
    if [[ $PTS_STATUS != 'PTS_STATUS: OK' ]]; then    
        printf "\nLast test failed. Press ENTER to continue or ESC to stop.\n" | tee -a $LOG_FILE
        read -n 1 -s ANS < /dev/tty
        if [ "$ANS" == $'\e' ]; then
          TEST_END=`date +%s`
          echo "Test finished at $((TEST_END-$TEST_START)) seconds."
          echo "END TEST: $(date)"  | tee -a $LOG_FILE
          ./pcie-wb/ftrninsmod.sh $PTS r
          exit
        fi
    fi
  fi

done < $TEST_LIST

TEST_END=`date +%s`
echo "Test complete in $((TEST_END-$TEST_START)) seconds."
echo "END TEST: $(date)"  | tee -a $LOG_FILE
./pcie-wb/ftrninsmod.sh $PTS r
echo " "