From 18d75029dc8a275af7fca62daee580098f572c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maarit=20H=C3=A4rk=C3=B6nen?= Date: Tue, 10 Dec 2024 14:09:57 +0200 Subject: [PATCH] Add audio tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maarit Härkönen --- .../test-suites/audio-tests/audio.robot | 60 +++++++++++++++++++ flake.nix | 1 + pkgs/ghaf-robot/default.nix | 2 + 3 files changed, 63 insertions(+) create mode 100644 Robot-Framework/test-suites/audio-tests/audio.robot diff --git a/Robot-Framework/test-suites/audio-tests/audio.robot b/Robot-Framework/test-suites/audio-tests/audio.robot new file mode 100644 index 00000000..c40d5873 --- /dev/null +++ b/Robot-Framework/test-suites/audio-tests/audio.robot @@ -0,0 +1,60 @@ +# SPDX-FileCopyrightText: 2022-2024 Technology Innovation Institute (TII) +# SPDX-License-Identifier: Apache-2.0 + +*** Settings *** +Documentation Testing audio applicaton +Force Tags audio lenovo-x1 +Resource ../../__framework__.resource +Resource ../../resources/serial_keywords.resource +Resource ../../resources/common_keywords.resource +Resource ../../resources/connection_keywords.resource +Resource ../../resources/ssh_keywords.resource +Resource ../../config/variables.robot +Suite Setup Initialize Variables And Connect +Suite Teardown Close All Connections +Test Timeout 2 minutes + + +*** Test Cases *** +Record Audio And Verify + [Documentation] Record short audio with pulseaudio tool. Verify audio clip is bigger than default empty file (40Kb) + [Teardown] Execute Command rm /tmp/test*.wav sudo=True sudo_password=${PASSWORD} + [Tags] SSRCSP-T247 + Connect to netvm + FOR ${vm} IN ${CHROME_VM} ${BUSINESS_VM} + Connect to VM ${vm} + # Execute Command timeouts in business-vm, but it is executing the command + Log To Console Recording audio file + Run Keyword And Ignore Error Execute Command parecord -r /tmp/test_${vm}.wav timeout=10 + Sleep 5 + Execute Command pkill parecord timeout=10 sudo=True sudo_password=${PASSWORD} + Sleep 1 + SSHLibrary.Get File /tmp/test_${vm}.wav test_${vm}.wav + Check Audio File test_${vm}.wav + END + +Check Audio devices + [Documentation] List audio sinks and sources in business-vm and chrome-vm and check status is running + [Tags] SSRCSP-T246 + Connect to netvm + FOR ${vm} IN ${CHROME_VM} ${BUSINESS_VM} + Connect to VM ${vm} + ${sources} Execute Command pactl list sources + ${sinks} Execute Command pactl list sinks + Should Not Be Empty ${sources} + Should Not Be Empty ${sinks} + END + + +*** Keywords *** +Check Audio File + [Documentation] Check some basic audio data + [Arguments] ${audiofile} ${expected_duration}=5 sec + ${out} Run ffmpeg -i ${audiofile} + ${duration} Get Regexp Matches ${out} (?im)(Duration: )(\\d{1,2}:\\d{1,2}:\\d{1,2}.\\d{1,3}) 2 + ${bitrate} Get Regexp Matches ${out} (?im)(bitrate: )(\\d{1,4}) 2 + Should Not Be Empty ${duration}[0] + Should Not Be Empty ${bitrate}[0] + ${actual_duration} Convert Time ${duration}[0] + ${expected_duration} Convert Time ${expected_duration} + Should Be True ${actual_duration} > ${expected_duration} diff --git a/flake.nix b/flake.nix index d3f153e0..94ea56da 100644 --- a/flake.nix +++ b/flake.nix @@ -44,6 +44,7 @@ file grafana-loki imagemagick + ffmpeg iperf (python3.withPackages (ps: with ps; [ diff --git a/pkgs/ghaf-robot/default.nix b/pkgs/ghaf-robot/default.nix index f10120f0..919a2db1 100644 --- a/pkgs/ghaf-robot/default.nix +++ b/pkgs/ghaf-robot/default.nix @@ -2,6 +2,7 @@ PyP100, iperf, imagemagick, + ffmpeg, plugp100, python3, robotframework-advancedlogging, @@ -16,6 +17,7 @@ writeShellApplication { runtimeInputs = [ iperf imagemagick + ffmpeg (python3.withPackages (ps: [ # These are taken from nixpkgs ps.robotframework