1#!/bin/bash 2 3#/* 4# * Copyright (C) 2013-2016 Intel Corporation 5# * 6# * This program is free software; you can redistribute it and/or modify 7# * it under the terms of the GNU General Public License as published by 8# * the Free Software Foundation; either version 2 of the License, or 9# * (at your option) any later version. 10# * 11# * This program is distributed in the hope that it will be useful, 12# * but WITHOUT ANY WARRANTY; without even the implied warranty of 13# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# * GNU General Public License for more details. 15# * 16# */ 17 18#set test freq table (HZ) 19freq_table="10 31 73 155 380 977 1932 4119 8197 16197" 20 21#set test number of channels 22test_channel=2 23 24#get Analog audio card number 25card_number=$(aplay -l | grep "Analog" | cut -b 6) 26if [ "$card_number" = "" ]; then 27 echo "Can not get Analog card number." 28 exit 1 29fi 30 31#get Analog audio device number 32device_number=$(aplay -l | grep "Analog"| cut -d " " -f 8 |cut -b 1) 33if [ "$device_number" = "" ]; then 34 echo "Can not get Analog device number" 35 exit 1 36fi 37 38 39device="hw:$card_number,$device_number" 40echo $device 41 42#get Analog audio record card number 43record_card_number=$(arecord -l | grep "Analog" | cut -b 6) 44if [ "$record_card_number" = "" ]; then 45 echo "Can not get record card number." 46 exit 1 47fi 48 49#get Analog audio record device number 50record_device_number=$(arecord -l | grep "Analog"| cut -d " " -f 8 |cut -b 1) 51echo $record_device_number 52if [ "$record_device_number" = "" ]; then 53 echo "Can not get record device number" 54 exit 1 55fi 56 57#Notice: to loopback the analog audio output to the analog audio input 58record_device="hw:$record_card_number,$record_device_number" 59test_flag=0 60 61echo -e "\e[31m Notice: to loopback the analog audio output to \ 62the analog audio input" 63echo -e "\e[0m" 64read -p "Press enter to continue" 65 66#call alsabat to do the test for each frequency in the freq_table 67for freq in $freq_table 68 do 69 alsabat -P $device -C plug$record_device -c $test_channel -F $freq 70 if [ $? = 0 ]; then 71 echo "Test target frequency:$freq for Analog playback -- Passed \ 72" >> $ABAT_TEST_LOG_FILE 73 echo "Test target frequency:$freq for Analog capture -- Passed \ 74" >> $ABAT_TEST_LOG_FILE 75 else 76 echo "Test target frequency:$freq for Analog playback -- Failed \ 77" >> $ABAT_TEST_LOG_FILE 78 echo "Test target frequency:$freq for Analog capture -- Failed \ 79" >> $ABAT_TEST_LOG_FILE 80 test_flag=1 81 fi 82 done 83 84exit $test_flag 85