All of lore.kernel.org
 help / color / mirror / Atom feed
From: han.lu@intel.com
To: tiwai@suse.de, liam.r.girdwood@linux.intel.com,
	bernard.gautier@intel.com, edward.c.popescu@intel.com,
	alsa-devel@alsa-project.org
Cc: "Lu, Han" <han.lu@intel.com>
Subject: [PATCH 10/10] alsabat: add bash test script
Date: Wed,  2 Mar 2016 16:53:20 +0800	[thread overview]
Message-ID: <fb7df8bc2b879986b55924073fe6fc70c2cd2197.1456907242.git.han.lu@intel.com> (raw)
In-Reply-To: <cover.1456907242.git.han.lu@intel.com>
In-Reply-To: <cover.1456907242.git.han.lu@intel.com>

From: "Lu, Han" <han.lu@intel.com>

Add bash script for alsabat feature test.
Examples for alsa tests:
        ./bat/testbat.sh
Examples for tinyalsa tests:
        ./bat/testbat.sh plughw:1,0 plughw:1,0 1

Signed-off-by: Lu, Han <han.lu@intel.com>

diff --git a/bat/testbat.sh b/bat/testbat.sh
new file mode 100644
index 0000000..93b9f70
--- /dev/null
+++ b/bat/testbat.sh
@@ -0,0 +1,160 @@
+#!/bin/bash
+
+exe="alsabat"
+file_sin="default.wav"
+file_sin_dual="default_dual.wav"
+logdir="tmp"
+# default devices
+dev_playback="default"
+dev_capture="default"
+# features passes vs. features all
+feature_pass=0
+feature_cnt=0
+
+commands="$exe -P $dev_playback -C $dev_capture"
+
+init_counter () {
+	feature_pass=0
+	feature_all=0
+}
+
+evaluate_result () {
+	feature_cnt=$((feature_cnt+1))
+	if [ $1 -eq 0 ]; then
+		feature_pass=$((feature_pass+1))
+		echo "pass"
+	else
+		echo "fail"
+	fi
+}
+
+print_result () {
+	echo "[$feature_pass/$feature_cnt] features passes."
+}
+
+feature_test () {
+	echo "============================================"
+	echo "$feature_cnt: ALSA $2"
+	echo "-------------------------------------------"
+	echo "$commands $1 --log=$logdir/$feature_cnt.log"
+	$commands $1 --log=$logdir/$feature_cnt.log
+	evaluate_result $?
+	echo "$commands $1" >> $logdir/$((feature_cnt-1)).log
+}
+
+# test items
+feature_list_test () {
+	commands="$exe"
+	feature_test "--saveplay ${file_sin}" \
+			"generate test file with default params"
+	sleep 5
+	feature_test "-P $dev_playback" "single line mode, playback"
+	feature_test "-C $dev_capture --standalone" "single line mode, capture"
+	commands="$exe -P $dev_playback -C $dev_capture"
+	feature_test "--file ${file_sin}" "play wav file and detect"
+	feature_test "" "generate sine wave and detect"
+	feature_test "-c1" "configurable channel number: 1"
+	feature_test "-c2 -F 19:16757" "configurable channel number: 2"
+	feature_test "-r44100" "configurable sample rate: 44100"
+	feature_test "-r48000" "configurable sample rate: 48000"
+	feature_test "-n16387" "configurable duration: in samples"
+	feature_test "-n2.5s" "configurable duration: in seconds"
+	feature_test "-f U8 --saveplay U8.wav" "configurable data depth: 8 bit"
+	feature_test "-f S16_LE --saveplay S16_LE.wav" \
+			"configurable data depth: 16 bit"
+	feature_test "-f S24_3LE --saveplay S24_3LE.wav" \
+			"configurable data depth: 24 bit"
+	feature_test "-f S32_LE --saveplay S32_LE.wav" \
+			"configurable data depth: 32 bit"
+	feature_test "-f cd --saveplay cd.wav" "configurable data depth: cd"
+	feature_test "-f dat --saveplay dat.wav" "configurable data depth: dat"
+	tmpfreq=17583
+	feature_test "-F $tmpfreq --standalone" \
+			"standalone mode: play and capture"
+	latestfile=`ls -t1 /tmp/bat.wav.* | head -n 1`
+	feature_test "--local -F $tmpfreq --file $latestfile" \
+			"local mode: analyze local file"
+
+	print_result
+}
+
+feature_test_tiny () {
+	echo "============================================"
+	echo "$feature_cnt: tinyalsa $2"
+	echo "-------------------------------------------"
+	echo "$commands -c2 -t $1 --log=$logdir/$feature_cnt.log"
+	$commands -c2 -t $1 --log=$logdir/$feature_cnt.log
+	evaluate_result $?
+	echo "$commands -c2 -t $1" >> $logdir/$((feature_cnt-1)).log
+}
+
+# tinyalsa test items; device may not support "default" name nor some formats
+feature_list_test_tiny () {
+	commands="$exe"
+	feature_test_tiny "-P $dev_playback" "single line mode, playback"
+	feature_test_tiny "-C $dev_capture --standalone" \
+			"single line mode, capture"
+	commands="$exe -P $dev_playback -C $dev_capture"
+	feature_test_tiny "--saveplay ${file_sin_dual}" \
+			"generate sine wave and detect"
+	feature_test_tiny "--file ${file_sin_dual}" "play wav file and detect"
+	feature_test_tiny "-F 19:16757" "configurable channel number: 2"
+	feature_test_tiny "-r44100" "configurable sample rate: 44100"
+	feature_test_tiny "-r48000" "configurable sample rate: 48000"
+	feature_test_tiny "-n16387" "configurable duration: in samples"
+	feature_test_tiny "-n2.5s" "configurable duration: in seconds"
+	feature_test_tiny "-f S16_LE --saveplay S16_LE.wav" \
+			"configurable data depth: 16 bit"
+	feature_test_tiny "-f S32_LE --saveplay S32_LE.wav" \
+			"configurable data depth: 32 bit"
+	feature_test_tiny "-f cd --saveplay cd.wav" \
+			"configurable data depth: cd"
+	feature_test_tiny "-f dat --saveplay dat.wav" \
+			"configurable data depth: dat"
+	tmpfreq=17583
+	feature_test_tiny "-F $tmpfreq --standalone" \
+			"standalone mode: play and capture"
+	latestfile=`ls -t1 /tmp/bat.wav.* | head -n 1`
+	feature_test_tiny "--local -F $tmpfreq --file $latestfile" \
+			"local mode: analyze local file"
+
+	print_result
+}
+
+echo "*******************************************"
+echo "                BAT Test                   "
+echo "-------------------------------------------"
+
+# get device
+echo "usage:"
+echo "  $0 <sound card>"
+echo "  $0 <device-playback> <device-capture> <1 for tinyalsa, blank for alsa>"
+
+use_tinyalsa="0"
+
+if [ $# -eq 3 ]; then
+	dev_playback=$1
+	dev_capture=$2
+	use_tinyalsa=$3
+elif [ $# -eq 2 ]; then
+	dev_playback=$1
+	dev_capture=$2
+elif [ $# -eq 1 ]; then
+	dev_playback=$1
+	dev_capture=$1
+fi
+
+echo "current setting:"
+echo "  $0 $dev_playback $dev_capture $3"
+
+# run
+logdir="tmp"
+mkdir -p $logdir
+init_counter
+if [ $use_tinyalsa = "1" ]; then
+	feature_list_test_tiny
+else
+	feature_list_test
+fi
+
+echo "*******************************************"
-- 
2.5.0

  parent reply	other threads:[~2016-03-02  8:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-02  8:53 [PATCH 00/10] *** alsabat features and fixes *** han.lu
2016-03-02  8:53 ` [PATCH 01/10] alsabat: add default device name for playback and capture han.lu
2016-03-04 20:57   ` Takashi Iwai
2016-03-07  1:24     ` Lu, Han
2016-03-08 10:15       ` Takashi Iwai
2016-03-02  8:53 ` [PATCH 02/10] alsabat: add standalone mode han.lu
2016-03-08 10:18   ` Takashi Iwai
2016-03-15  3:45     ` Lu, Han
2016-03-02  8:53 ` [PATCH 03/10] alsabat: add tinyalsa support han.lu
2016-03-11 14:13   ` Takashi Iwai
2016-03-15  3:50     ` Lu, Han
2016-03-02  8:53 ` [PATCH 04/10] alsabat: clean the thread loopback of alsa capture han.lu
2016-03-02  8:53 ` [PATCH 05/10] alsabat: refactor wav file process han.lu
2016-03-02  8:53 ` [PATCH 06/10] alsabat: use common data generator function han.lu
2016-03-02  8:53 ` [PATCH 07/10] alsabat: add interrupt handler for shutdown han.lu
2016-03-02  8:53 ` [PATCH 08/10] alsabat: fix an incorrect print han.lu
2016-03-02  8:53 ` [PATCH 09/10] alsabat: use variable for thread return value han.lu
2016-03-11 13:34   ` Takashi Iwai
2016-03-14  9:15     ` Lu, Han
2016-03-14  9:21       ` Takashi Iwai
2016-03-14  9:36         ` Lu, Han
2016-03-14  9:43           ` Takashi Iwai
2016-03-14  9:53             ` Lu, Han
2016-03-02  8:53 ` han.lu [this message]
2016-03-04 20:58   ` [PATCH 10/10] alsabat: add bash test script Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fb7df8bc2b879986b55924073fe6fc70c2cd2197.1456907242.git.han.lu@intel.com \
    --to=han.lu@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bernard.gautier@intel.com \
    --cc=edward.c.popescu@intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.