From 09de774dcc1a5abc1c8f3a00fdb039aa3c522f52 Mon Sep 17 00:00:00 2001 From: Manel Caro Date: Wed, 4 Mar 2020 17:46:36 +0100 Subject: SOPA Initial Commit --- test-cli/test/tests/qaudio.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index a1572ca..fe57be2 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -13,13 +13,14 @@ class Qaudio(unittest.TestCase): self.__refSum = 25 # 1+3+5+7+9 def execute(self): - str_cmd = "aplay test/files/dtmf-13579.wav 2> /dev/null & arecord -r 8000 -d 1 recorded.wav 2> /dev/null" #.format(self.__dtmfFile) + str_cmd = "aplay test/files/dtmf-13579.wav & arecord -r 8000 -d 1 recorded.wav" #.format(self.__dtmfFile) audio_loop = SysCommand("command-name", str_cmd) - if audio_loop.execute() == 0:# BUG: Returns -1 but work + if audio_loop.execute() == -1:# BUG: Returns -1 but work lines = audio_loop.getOutput().splitlines() - str_cmd = "multimon -t wav -a DTMF recorded.wav -q 2> /dev/null" + str_cmd = "multimon -t wav -a DTMF recorded.wav -q" dtmf_decoder = SysCommand("command-name", str_cmd) - if dtmf_decoder.execute() == 0: # BUG: Returns -1 but work + a=dtmf_decoder.execute() + if dtmf_decoder.execute() == -1: # BUG: Returns -1 but work self.__raw_out = dtmf_decoder.getOutput() if self.__raw_out == "": return -1 @@ -34,4 +35,4 @@ class Qaudio(unittest.TestCase): else: self.fail("failed: fail playing/recording file") return -1 - return 0 + return 0 \ No newline at end of file -- cgit v1.1 From 9f07a57d89a927aa9b172c1bf20c7ab563658c73 Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Fri, 6 Mar 2020 12:46:27 +0100 Subject: Fixed multiple errors. --- test-cli/test/tests/qaudio.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index fe57be2..ef4da67 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -1,38 +1,39 @@ from test.helpers.syscmd import SysCommand import unittest -#class name + + class Qaudio(unittest.TestCase): - # Initialize the variables + params = None - def __init__(self, testname, testfunc, dtmfFile): - # Doing this we will initialize the class and later on perform a particular method inside this class + def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qaudio, self).__init__(testfunc) self._testMethodDoc = testname - self._dtmfFile=dtmfFile - self.__sum=0 - self.__refSum = 25 # 1+3+5+7+9 + if "dtmfFile" in varlist: + self._dtmfFile = varlist["dtmfFile"] + else: + raise Exception('undercurrent param inside Qamp must be defined') + self.__sum = 0 + self.__refSum = 25 # 1+3+5+7+9 def execute(self): - str_cmd = "aplay test/files/dtmf-13579.wav & arecord -r 8000 -d 1 recorded.wav" #.format(self.__dtmfFile) + str_cmd = "aplay test/files/dtmf-13579.wav & arecord -r 8000 -d 1 recorded.wav" # .format(self.__dtmfFile) audio_loop = SysCommand("command-name", str_cmd) - if audio_loop.execute() == -1:# BUG: Returns -1 but work + if audio_loop.execute() == -1: # BUG: Returns -1 but work lines = audio_loop.getOutput().splitlines() str_cmd = "multimon -t wav -a DTMF recorded.wav -q" dtmf_decoder = SysCommand("command-name", str_cmd) - a=dtmf_decoder.execute() - if dtmf_decoder.execute() == -1: # BUG: Returns -1 but work + a = dtmf_decoder.execute() + if dtmf_decoder.execute() == -1: # BUG: Returns -1 but work self.__raw_out = dtmf_decoder.getOutput() if self.__raw_out == "": - return -1 + self.fail("failed: can not execute multimon command") lines = dtmf_decoder.getOutput().splitlines() for i in range(0, 5): - aux=[int(s) for s in lines[i].split() if s.isdigit()] - self.__sum=self.__sum+aux[0] + aux = [int(s) for s in lines[i].split() if s.isdigit()] + self.__sum = self.__sum + aux[0] self.failUnless(self.__sum == self.__refSum), "failed: incorrect dtmf code" + str(self.__sum) else: self.fail("failed: fail reading recorded file") - return -1 else: self.fail("failed: fail playing/recording file") - return -1 - return 0 \ No newline at end of file -- cgit v1.1 From db3b1e45c47a1ef23c1ad67114a09cbec0976681 Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Thu, 25 Jun 2020 11:45:31 +0200 Subject: Solved bugs. Adapted to DB changes. --- test-cli/test/tests/qaudio.py | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 test-cli/test/tests/qaudio.py (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py deleted file mode 100644 index ef4da67..0000000 --- a/test-cli/test/tests/qaudio.py +++ /dev/null @@ -1,39 +0,0 @@ -from test.helpers.syscmd import SysCommand -import unittest - - -class Qaudio(unittest.TestCase): - params = None - - def __init__(self, testname, testfunc, varlist): - self.params = varlist - super(Qaudio, self).__init__(testfunc) - self._testMethodDoc = testname - if "dtmfFile" in varlist: - self._dtmfFile = varlist["dtmfFile"] - else: - raise Exception('undercurrent param inside Qamp must be defined') - self.__sum = 0 - self.__refSum = 25 # 1+3+5+7+9 - - def execute(self): - str_cmd = "aplay test/files/dtmf-13579.wav & arecord -r 8000 -d 1 recorded.wav" # .format(self.__dtmfFile) - audio_loop = SysCommand("command-name", str_cmd) - if audio_loop.execute() == -1: # BUG: Returns -1 but work - lines = audio_loop.getOutput().splitlines() - str_cmd = "multimon -t wav -a DTMF recorded.wav -q" - dtmf_decoder = SysCommand("command-name", str_cmd) - a = dtmf_decoder.execute() - if dtmf_decoder.execute() == -1: # BUG: Returns -1 but work - self.__raw_out = dtmf_decoder.getOutput() - if self.__raw_out == "": - self.fail("failed: can not execute multimon command") - lines = dtmf_decoder.getOutput().splitlines() - for i in range(0, 5): - aux = [int(s) for s in lines[i].split() if s.isdigit()] - self.__sum = self.__sum + aux[0] - self.failUnless(self.__sum == self.__refSum), "failed: incorrect dtmf code" + str(self.__sum) - else: - self.fail("failed: fail reading recorded file") - else: - self.fail("failed: fail playing/recording file") -- cgit v1.1 From 34df86b37d6838b115e65e5f3a332344afeb86b8 Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Wed, 1 Jul 2020 10:45:34 +0200 Subject: Changes to adapt to new way to save results in DB. Created audio test. Added protections against unexpected status in DB. --- test-cli/test/tests/qaudio.py | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test-cli/test/tests/qaudio.py (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py new file mode 100644 index 0000000..5baffe4 --- /dev/null +++ b/test-cli/test/tests/qaudio.py @@ -0,0 +1,59 @@ +import unittest +import sh +import wave +import contextlib + + +def calc_audio_duration(fname): + with contextlib.closing(wave.open(fname, 'r')) as f: + frames = f.getnframes() + rate = f.getframerate() + duration = frames / float(rate) + f.close() + return duration + + +class Qaudio(unittest.TestCase): + params = None + __resultlist = None # resultlist is a python list of python dictionaries + __dtmf_secuence = ["1", "3", "5", "7", "9"] + + def __init__(self, testname, testfunc, varlist): + self.params = varlist + super(Qaudio, self).__init__(testfunc) + self._testMethodDoc = testname + self.__resultlist = [] + + def execute(self): + # analize audio file + recordtime = calc_audio_duration("test/files/dtmf-13579.wav") + 0.15 + # play and record + p1 = sh.aplay("test/files/dtmf-13579.wav", _bg=True) + p2 = sh.arecord("-r", 8000, "-d", recordtime, "/tmp/station/recorded.wav", _bg=True) + p1.wait() + p2.wait() + if p1.exit_code == 0 and p2.exit_code == 0: + p = sh.multimon("-t", "wav", "-a", "DTMF", "/tmp/station/recorded.wav", "-q") + if p.exit_code == 0: + lines = p.stdout.decode('ascii').splitlines() + self.__dtmf_secuence_result = [] + for li in lines: + if li.split(" ")[0] == "DTMF:": + self.__dtmf_secuence_result.append(li.split(" ")[1]) + # compare original and processed dtmf sequence + if len(self.__dtmf_secuence) == len(self.__dtmf_secuence_result): + for i in range(len(self.__dtmf_secuence)): + if self.__dtmf_secuence[i] != self.__dtmf_secuence_result[i]: + self.fail("failed: sent and received DTMF sequence don't match.") + else: + self.fail("failed: received DTMF sequence is shorter than expected.") + else: + self.fail("failed: unable to use multimon command.") + else: + self.fail("failed: unable to play/record audio.") + + def getresults(self): + return self.__resultlist + + def gettextresult(self): + return "" -- cgit v1.1 From b58a64c6993ab60f18a1a0ca8c90f167c7e6656b Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Thu, 2 Jul 2020 14:45:48 +0200 Subject: Added support for IGEP0020 and IGEP0030. Fixed problem in Audio test. --- test-cli/test/tests/qaudio.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index 5baffe4..ef0cf53 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -2,6 +2,7 @@ import unittest import sh import wave import contextlib +import os def calc_audio_duration(fname): @@ -25,10 +26,11 @@ class Qaudio(unittest.TestCase): self.__resultlist = [] def execute(self): + test_abspath = os.path.dirname(os.path.abspath(__file__)) + "/../" # analize audio file - recordtime = calc_audio_duration("test/files/dtmf-13579.wav") + 0.15 + recordtime = calc_audio_duration(os.path.join(test_abspath, "files/dtmf-13579.wav")) + 0.15 # play and record - p1 = sh.aplay("test/files/dtmf-13579.wav", _bg=True) + p1 = sh.aplay(os.path.join(test_abspath, "files/dtmf-13579.wav"), _bg=True) p2 = sh.arecord("-r", 8000, "-d", recordtime, "/tmp/station/recorded.wav", _bg=True) p1.wait() p2.wait() -- cgit v1.1 From 5dcd213c28451ac210703dc5bf9bf538671a0682 Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Fri, 3 Jul 2020 13:55:45 +0200 Subject: Created new USB LOOP test. Moved all the test files to /var/lib/hwtest-files/ folder. --- test-cli/test/tests/qaudio.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index ef0cf53..acad4a9 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -2,7 +2,6 @@ import unittest import sh import wave import contextlib -import os def calc_audio_duration(fname): @@ -26,11 +25,10 @@ class Qaudio(unittest.TestCase): self.__resultlist = [] def execute(self): - test_abspath = os.path.dirname(os.path.abspath(__file__)) + "/../" # analize audio file - recordtime = calc_audio_duration(os.path.join(test_abspath, "files/dtmf-13579.wav")) + 0.15 + recordtime = calc_audio_duration("/var/lib/hwtest-files/dtmf-13579.wav") + 0.15 # play and record - p1 = sh.aplay(os.path.join(test_abspath, "files/dtmf-13579.wav"), _bg=True) + p1 = sh.aplay("/var/lib/hwtest-files/dtmf-13579.wav", _bg=True) p2 = sh.arecord("-r", 8000, "-d", recordtime, "/tmp/station/recorded.wav", _bg=True) p1.wait() p2.wait() -- cgit v1.1 From cd3c8dd78e3bcdd442967583e3814db3701871c0 Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Mon, 6 Jul 2020 16:01:08 +0200 Subject: Solved minor errors with audio and usbloop tests. --- test-cli/test/tests/qaudio.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index acad4a9..f7ae33c 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -2,6 +2,7 @@ import unittest import sh import wave import contextlib +import time def calc_audio_duration(fname): @@ -27,6 +28,8 @@ class Qaudio(unittest.TestCase): def execute(self): # analize audio file recordtime = calc_audio_duration("/var/lib/hwtest-files/dtmf-13579.wav") + 0.15 + # wait time before playing + time.sleep(1) # play and record p1 = sh.aplay("/var/lib/hwtest-files/dtmf-13579.wav", _bg=True) p2 = sh.arecord("-r", 8000, "-d", recordtime, "/tmp/station/recorded.wav", _bg=True) @@ -42,8 +45,8 @@ class Qaudio(unittest.TestCase): self.__dtmf_secuence_result.append(li.split(" ")[1]) # compare original and processed dtmf sequence if len(self.__dtmf_secuence) == len(self.__dtmf_secuence_result): - for i in range(len(self.__dtmf_secuence)): - if self.__dtmf_secuence[i] != self.__dtmf_secuence_result[i]: + for a, b in zip(self.__dtmf_secuence, self.__dtmf_secuence_result): + if a != b: self.fail("failed: sent and received DTMF sequence don't match.") else: self.fail("failed: received DTMF sequence is shorter than expected.") -- cgit v1.1 From 1d51a80b57cc8c80c78d67c85290503997060e9e Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Mon, 6 Jul 2020 17:22:17 +0200 Subject: Modified paths of ram and nfs temporary folders. --- test-cli/test/tests/qaudio.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index f7ae33c..bfbb051 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -2,7 +2,6 @@ import unittest import sh import wave import contextlib -import time def calc_audio_duration(fname): @@ -28,15 +27,15 @@ class Qaudio(unittest.TestCase): def execute(self): # analize audio file recordtime = calc_audio_duration("/var/lib/hwtest-files/dtmf-13579.wav") + 0.15 - # wait time before playing - time.sleep(1) + # previous play to estabilise audio lines + sh.aplay("/var/lib/hwtest-files/dtmf-13579.wav") # play and record p1 = sh.aplay("/var/lib/hwtest-files/dtmf-13579.wav", _bg=True) - p2 = sh.arecord("-r", 8000, "-d", recordtime, "/tmp/station/recorded.wav", _bg=True) + p2 = sh.arecord("-r", 8000, "-d", recordtime, "/mnt/station_ramdisk/recorded.wav", _bg=True) p1.wait() p2.wait() if p1.exit_code == 0 and p2.exit_code == 0: - p = sh.multimon("-t", "wav", "-a", "DTMF", "/tmp/station/recorded.wav", "-q") + p = sh.multimon("-t", "wav", "-a", "DTMF", "/mnt/station_ramdisk/recorded.wav", "-q") if p.exit_code == 0: lines = p.stdout.decode('ascii').splitlines() self.__dtmf_secuence_result = [] @@ -49,6 +48,7 @@ class Qaudio(unittest.TestCase): if a != b: self.fail("failed: sent and received DTMF sequence don't match.") else: + print(self.__dtmf_secuence_result) self.fail("failed: received DTMF sequence is shorter than expected.") else: self.fail("failed: unable to use multimon command.") -- cgit v1.1 From 47827e40f71696e04ad805296dedc44a03451db3 Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Mon, 6 Jul 2020 17:51:09 +0200 Subject: In case iperf3 server is busy, clients wait and retry. --- test-cli/test/tests/qaudio.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index bfbb051..364d8b2 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -48,7 +48,6 @@ class Qaudio(unittest.TestCase): if a != b: self.fail("failed: sent and received DTMF sequence don't match.") else: - print(self.__dtmf_secuence_result) self.fail("failed: received DTMF sequence is shorter than expected.") else: self.fail("failed: unable to use multimon command.") -- cgit v1.1 From 9f89f02e7d6e2a3208b0b85d2567ebffd2515e09 Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Tue, 7 Jul 2020 14:09:59 +0200 Subject: New way to check preivous state before changing to a new one. Solved some problems with audio test. --- test-cli/test/tests/qaudio.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index 364d8b2..3d2113a 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -28,7 +28,10 @@ class Qaudio(unittest.TestCase): # analize audio file recordtime = calc_audio_duration("/var/lib/hwtest-files/dtmf-13579.wav") + 0.15 # previous play to estabilise audio lines - sh.aplay("/var/lib/hwtest-files/dtmf-13579.wav") + p1 = sh.aplay("/var/lib/hwtest-files/dtmf-13579.wav", _bg=True) + p2 = sh.arecord("-r", 8000, "-d", recordtime, "/mnt/station_ramdisk/recorded.wav", _bg=True) + p1.wait() + p2.wait() # play and record p1 = sh.aplay("/var/lib/hwtest-files/dtmf-13579.wav", _bg=True) p2 = sh.arecord("-r", 8000, "-d", recordtime, "/mnt/station_ramdisk/recorded.wav", _bg=True) -- cgit v1.1 From d46bce422fd03cd57d1ba336361da17d6efb48db Mon Sep 17 00:00:00 2001 From: Manel Caro Date: Fri, 31 Jul 2020 02:07:37 +0200 Subject: TEST restructure --- test-cli/test/tests/qaudio.py | 77 ++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 23 deletions(-) (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index 3d2113a..2c86809 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -2,56 +2,78 @@ import unittest import sh import wave import contextlib - - -def calc_audio_duration(fname): - with contextlib.closing(wave.open(fname, 'r')) as f: - frames = f.getnframes() - rate = f.getframerate() - duration = frames / float(rate) - f.close() - return duration - +import uuid +import time +from test.helpers.utils import save_result +from test.helpers.iseelogger import logObj class Qaudio(unittest.TestCase): params = None __resultlist = None # resultlist is a python list of python dictionaries __dtmf_secuence = ["1", "3", "5", "7", "9"] + __dtmf_file = None + __file_uuid = None + __QaudioName = None def __init__(self, testname, testfunc, varlist): self.params = varlist super(Qaudio, self).__init__(testfunc) self._testMethodDoc = testname self.__resultlist = [] + self.__xmlObj = varlist["xml"] + self.__QaudioName = varlist.get('name', 'qaudio') + self.__dtmf_file_play = varlist.get('play_dtmf_file', self.__xmlObj.getKeyVal(self.__QaudioName, "play_dtmf_file", "dtmf-13579.wav")) + self.__recordtime = varlist.get('recordtime', self.__xmlObj.getKeyVal(self.__QaudioName, "recordtime", "0.15")) + self.__dtmf_file_record = varlist.get('record_dtmf_file', self.__xmlObj.getKeyVal(self.__QaudioName, "record_dtmf_file", "record-{}.wav")) + self.__sampling_rate = varlist.get('rate', self.__xmlObj.getKeyVal(self.__QaudioName, "rate", "8000")) + self.__record_path = varlist.get('to', self.__xmlObj.getKeyVal(self.__QaudioName, "to", "/mnt/station_ramdisk")) + self.__run_delay = float(varlist.get('aplay_run_delay', self.__xmlObj.getKeyVal(self.__QaudioName, "aplay_run_delay", "0.0"))) + self.__file_uuid = uuid.uuid4() + self.__dtmf_file_record = self.__dtmf_file_record.format(self.__file_uuid) + + def restoreAlsaCtl(self): + try: + sh.alsactl('restore'); + except Exception as E: + logObj.getlogger().error("Failed to Execite alsactl restore"); def execute(self): - # analize audio file - recordtime = calc_audio_duration("/var/lib/hwtest-files/dtmf-13579.wav") + 0.15 + self.restoreAlsaCtl() + try: + # analize audio file + calcRecordTime = self.calc_audio_duration(self.__dtmf_file_play) + float(self.__recordtime) + float(0.1) + except TypeError as Error: + self.fail("failed: TypeError: {}.".Error) + # previous play to estabilise audio lines - p1 = sh.aplay("/var/lib/hwtest-files/dtmf-13579.wav", _bg=True) - p2 = sh.arecord("-r", 8000, "-d", recordtime, "/mnt/station_ramdisk/recorded.wav", _bg=True) - p1.wait() - p2.wait() - # play and record - p1 = sh.aplay("/var/lib/hwtest-files/dtmf-13579.wav", _bg=True) - p2 = sh.arecord("-r", 8000, "-d", recordtime, "/mnt/station_ramdisk/recorded.wav", _bg=True) - p1.wait() + p2 = sh.arecord("-r", self.__sampling_rate, "-d", calcRecordTime, "{}/{}".format(self.__record_path, self.__dtmf_file_record), _bg=True) + time.sleep(self.__run_delay) + p1 = sh.aplay(self.__dtmf_file_play) p2.wait() if p1.exit_code == 0 and p2.exit_code == 0: - p = sh.multimon("-t", "wav", "-a", "DTMF", "/mnt/station_ramdisk/recorded.wav", "-q") + p = sh.multimon("-t", "wav", "-a", "DTMF", "{}/{}".format(self.__record_path, self.__dtmf_file_record), "-q") if p.exit_code == 0: lines = p.stdout.decode('ascii').splitlines() self.__dtmf_secuence_result = [] for li in lines: if li.split(" ")[0] == "DTMF:": self.__dtmf_secuence_result.append(li.split(" ")[1]) + self.__dtmf_secuence_result = sorted(list(set(self.__dtmf_secuence_result))) # compare original and processed dtmf sequence if len(self.__dtmf_secuence) == len(self.__dtmf_secuence_result): for a, b in zip(self.__dtmf_secuence, self.__dtmf_secuence_result): if a != b: - self.fail("failed: sent and received DTMF sequence don't match.") + logObj.getlogger().debug( + "failed: sent and received DTMF sequence do not match.{} != {}".format( + self.__dtmf_secuence, self.__dtmf_secuence_result)) + self.fail("failed: sent and received DTMF sequence do not match.") + save_result(filePath='{}/{}'.format(self.__record_path, self.__dtmf_file_record), + description='sound record', + mime='audio/x-wav', + result=self.__resultlist) else: - self.fail("failed: received DTMF sequence is shorter than expected.") + logObj.getlogger().debug("received DTMF sequence is shorter than expected.{} {}".format(self.__dtmf_secuence,self.__dtmf_secuence_result)) + self.fail("received DTMF sequence is shorter than expected") else: self.fail("failed: unable to use multimon command.") else: @@ -62,3 +84,12 @@ class Qaudio(unittest.TestCase): def gettextresult(self): return "" + + def calc_audio_duration(self, fname): + duration = 0.0 + with contextlib.closing(wave.open(fname, 'r')) as f: + frames = f.getnframes() + rate = f.getframerate() + duration = frames / float(rate) + f.close() + return duration -- cgit v1.1 From d8d4684c24a7c34334bb0b1d74dead69282e8c46 Mon Sep 17 00:00:00 2001 From: Josep Maso Date: Wed, 30 Sep 2020 10:32:16 +0200 Subject: Modified audio test to work in IGEP0046. --- test-cli/test/tests/qaudio.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test-cli/test/tests/qaudio.py') diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index 2c86809..a219a1a 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -50,6 +50,11 @@ class Qaudio(unittest.TestCase): time.sleep(self.__run_delay) p1 = sh.aplay(self.__dtmf_file_play) p2.wait() + + p2 = sh.arecord("-r", self.__sampling_rate, "-d", calcRecordTime, "{}/{}".format(self.__record_path, self.__dtmf_file_record), _bg=True) + time.sleep(self.__run_delay) + p1 = sh.aplay(self.__dtmf_file_play) + p2.wait() if p1.exit_code == 0 and p2.exit_code == 0: p = sh.multimon("-t", "wav", "-a", "DTMF", "{}/{}".format(self.__record_path, self.__dtmf_file_record), "-q") if p.exit_code == 0: -- cgit v1.1