Blame bat/tests/analog_audio_playback_and_capture.sh

Packit Service a9274b
#!/bin/bash
Packit Service a9274b
Packit Service a9274b
#/*
Packit Service a9274b
# * Copyright (C) 2013-2016 Intel Corporation
Packit Service a9274b
# *
Packit Service a9274b
# * This program is free software; you can redistribute it and/or modify
Packit Service a9274b
# * it under the terms of the GNU General Public License as published by
Packit Service a9274b
# * the Free Software Foundation; either version 2 of the License, or
Packit Service a9274b
# * (at your option) any later version.
Packit Service a9274b
# *
Packit Service a9274b
# * This program is distributed in the hope that it will be useful,
Packit Service a9274b
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service a9274b
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service a9274b
# * GNU General Public License for more details.
Packit Service a9274b
# *
Packit Service a9274b
# */
Packit Service a9274b
Packit Service a9274b
#set test freq table (HZ)
Packit Service a9274b
freq_table="10 31 73 155 380 977 1932 4119 8197 16197"
Packit Service a9274b
Packit Service a9274b
#set test number of channels
Packit Service a9274b
test_channel=2
Packit Service a9274b
Packit Service a9274b
#get Analog audio card number
Packit Service a9274b
card_number=$(aplay -l | grep "Analog" | cut -b 6)
Packit Service a9274b
if [ "$card_number" = "" ]; then
Packit Service a9274b
        echo "Can not get Analog card number."
Packit Service a9274b
        exit 1
Packit Service a9274b
fi
Packit Service a9274b
Packit Service a9274b
#get Analog audio device number
Packit Service a9274b
device_number=$(aplay -l | grep "Analog"| cut -d " " -f 8 |cut -b 1)
Packit Service a9274b
if [ "$device_number" = "" ]; then
Packit Service a9274b
        echo "Can not get Analog device number"
Packit Service a9274b
        exit 1
Packit Service a9274b
fi
Packit Service a9274b
Packit Service a9274b
Packit Service a9274b
device="hw:$card_number,$device_number"
Packit Service a9274b
echo $device
Packit Service a9274b
Packit Service a9274b
#get Analog audio record card number
Packit Service a9274b
record_card_number=$(arecord -l | grep "Analog" | cut -b 6)
Packit Service a9274b
if [ "$record_card_number" = "" ]; then
Packit Service a9274b
        echo "Can not get record card number."
Packit Service a9274b
        exit 1
Packit Service a9274b
fi
Packit Service a9274b
Packit Service a9274b
#get Analog audio record device number
Packit Service a9274b
record_device_number=$(arecord -l | grep "Analog"| cut -d " " -f 8 |cut -b 1)
Packit Service a9274b
echo $record_device_number
Packit Service a9274b
if [ "$record_device_number" = "" ]; then
Packit Service a9274b
        echo "Can not get record device number"
Packit Service a9274b
        exit 1
Packit Service a9274b
fi
Packit Service a9274b
Packit Service a9274b
#Notice: to loopback the analog audio output to the analog audio input
Packit Service a9274b
record_device="hw:$record_card_number,$record_device_number"
Packit Service a9274b
test_flag=0
Packit Service a9274b
Packit Service a9274b
echo  -e "\e[31m Notice: to loopback the analog audio output to \
Packit Service a9274b
the analog audio input"
Packit Service a9274b
echo -e "\e[0m"
Packit Service a9274b
read -p "Press enter to continue"
Packit Service a9274b
Packit Service a9274b
#call alsabat to do the test for each frequency in the freq_table
Packit Service a9274b
for freq in $freq_table
Packit Service a9274b
	do
Packit Service a9274b
	alsabat -P $device -C plug$record_device -c $test_channel -F $freq
Packit Service a9274b
		if [ $? = 0 ]; then
Packit Service a9274b
			echo "Test target frequency:$freq for Analog playback -- Passed \
Packit Service a9274b
" >> $ABAT_TEST_LOG_FILE
Packit Service a9274b
			echo "Test target frequency:$freq for Analog capture -- Passed \
Packit Service a9274b
" >> $ABAT_TEST_LOG_FILE
Packit Service a9274b
		else
Packit Service a9274b
			echo "Test target frequency:$freq for Analog playback -- Failed \
Packit Service a9274b
" >> $ABAT_TEST_LOG_FILE
Packit Service a9274b
			echo "Test target frequency:$freq for Analog capture -- Failed \
Packit Service a9274b
" >> $ABAT_TEST_LOG_FILE
Packit Service a9274b
			test_flag=1
Packit Service a9274b
		fi
Packit Service a9274b
	done
Packit Service a9274b
Packit Service a9274b
exit $test_flag