#!/usr/bin/expect -f
# This file is part of Firejail project
# Copyright (C) 2014-2026 Firejail Authors
# License GPL v2


set timeout 10
spawn $env(SHELL)
match_max 100000

send -- "firejail --nosound speaker-test\r"
expect {
	timeout {puts "TESTING ERROR 1\n";exit}
	-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
	timeout {puts "TESTING ERROR 2\n";exit}
	"Parent is shutting down"
}
sleep 2

send -- "firejail --nosound aplay -l\r"
expect {
	timeout {puts "TESTING ERROR 3\n";exit}
	-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
	timeout {puts "TESTING ERROR 4\n";exit}
	"List of PLAYBACK" {puts "TESTING ERROR 3\n";exit}
	"no soundcards found"
}
expect {
	timeout {puts "TESTING ERROR 5\n";exit}
	"Parent is shutting down"
}
sleep 2


send -- "firejail --profile=./sound.profile speaker-test\r"
expect {
	timeout {puts "TESTING ERROR 11\n";exit}
	-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
	timeout {puts "TESTING ERROR 12\n";exit}
	"Parent is shutting down"
}
sleep 2

send -- "firejail --profile=./sound.profile aplay -l\r"
expect {
	timeout {puts "TESTING ERROR 13\n";exit}
	-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
	timeout {puts "TESTING ERROR 14\n";exit}
	"List of PLAYBACK" {puts "TESTING ERROR 3\n";exit}
	"no soundcards found"
}
expect {
	timeout {puts "TESTING ERROR 15\n";exit}
	"Parent is shutting down"
}
sleep 2


send -- "firejail aplay -l\r"
expect {
	timeout {puts "TESTING ERROR 23\n";exit}
	-re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
}
expect {
	timeout {puts "TESTING ERROR 24\n";exit}
	"List of PLAYBACK"
}
expect {
	timeout {puts "TESTING ERROR 25\n";exit}
	"Parent is shutting down"
}
after 100

puts "\nall done\n"
