nixos/tests/speechd: init (#563434)

This commit is contained in:
Jan Tojnar
2026-09-25 14:03:39 +00:00
committed by GitHub
3 changed files with 53 additions and 0 deletions

View File

@@ -1726,6 +1726,7 @@ in
sonic-server = runTest ./sonic-server.nix;
spacecookie = runTest ./spacecookie.nix;
spark = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./spark { };
speechd = runTest ./speechd.nix;
speedtest-tracker = runTest ./speedtest-tracker.nix;
spiped = runTest ./spiped.nix;
spire = runTest ./spire.nix;

49
nixos/tests/speechd.nix Normal file
View File

@@ -0,0 +1,49 @@
{ lib, ... }:
{
name = "speechd";
meta.maintainers = [ lib.maintainers.h7x4 ];
nodes.machine =
{ pkgs, ... }:
{
imports = [ ./common/user-account.nix ];
environment.systemPackages = [ pkgs.speechd ];
# Without a real sound card, libao (speech-dispatcher's audio backend)
# fails to open any device. libao's built-in "null" driver always succeeds.
environment.etc."libao.conf".text = ''
default_driver=null
'';
services.speechd = {
enable = true;
config = ''
AddModule "testmodule" "sd_generic" "testmodule.conf"
DefaultModule "testmodule"
'';
modules.testmodule = ''
AddVoice "en" "male1" "testmodule_voice"
GenericLanguage "en" "en"
GenericExecuteSynth "echo \'$DATA\' >> /tmp/speechd-spoken.txt"
'';
};
};
testScript =
{ nodes, ... }:
let
user = nodes.machine.users.users.alice;
uid = toString user.uid;
aliceRun = command: "su - ${user.name} -c 'XDG_RUNTIME_DIR=/run/user/${uid} ${command}'";
in
''
machine.wait_for_unit("multi-user.target")
machine.succeed("loginctl enable-linger ${user.name}")
machine.wait_for_unit("user@${uid}.service")
machine.wait_for_unit("speech-dispatcher.socket", "${user.name}")
machine.succeed("${aliceRun "spd-say 'hello'"}")
machine.wait_until_succeeds("grep -q 'hello' /tmp/speechd-spoken.txt")
'';
}

View File

@@ -33,6 +33,7 @@
withPico ? true,
picotts,
libsOnly ? false,
nixosTests,
}:
let
@@ -152,6 +153,8 @@ stdenv.mkDerivation (finalAttrs: {
enableParallelBuilding = true;
passthru.tests.nixos = nixosTests.speechd;
meta = {
description =
"Common interface to speech synthesis" + lib.optionalString libsOnly " - client libraries only";