From 7578e86ef8ddb78da44d426b94def77366627e0e Mon Sep 17 00:00:00 2001 From: smitsohu Date: Wed, 9 Feb 2022 18:04:36 +0100 Subject: testing: fix expect matching of numbers The sandbox timestamp should not be available for matching when output is already expected from the next command (this is only a problem if numeric output if expected from the first command in the sandbox). A possible alternative would be to flush the expect output buffer with 'expect "*"' after the sandbox is up. --- test/environment/allow-debuggers.exp | 2 +- test/environment/csh.exp | 2 +- test/environment/dash.exp | 2 +- test/environment/deterministic-exit-code.exp | 4 ++-- test/environment/dns.exp | 8 ++++---- test/environment/doubledash.exp | 4 ++-- test/environment/env.exp | 4 ++-- test/environment/extract_command.exp | 2 +- test/environment/firejail-in-firejail.exp | 2 +- test/environment/hostfile.exp | 2 +- test/environment/ibus.exp | 2 +- test/environment/keep-fd.exp | 10 +++++----- test/environment/machineid.exp | 2 +- test/environment/nice.exp | 6 +++--- test/environment/rlimit-join.exp | 8 ++++++-- test/environment/rlimit-profile.exp | 2 +- test/environment/rlimit.exp | 2 +- test/environment/shell-none.exp | 4 ++-- test/environment/sound.exp | 10 +++++----- test/environment/timeout.exp | 2 +- test/environment/umask.exp | 2 +- test/environment/zsh.exp | 2 +- 22 files changed, 44 insertions(+), 40 deletions(-) (limited to 'test/environment') diff --git a/test/environment/allow-debuggers.exp b/test/environment/allow-debuggers.exp index 412e24e9b..f972b5788 100755 --- a/test/environment/allow-debuggers.exp +++ b/test/environment/allow-debuggers.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail --allow-debuggers\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" { puts "\n"} + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" { puts "\n"} "is disabled on Linux kernels prior to 4.8" { puts "TESTING SKIP: kernel too old\n"; exit } } after 100 diff --git a/test/environment/csh.exp b/test/environment/csh.exp index eedb1bab7..31bfbfa40 100755 --- a/test/environment/csh.exp +++ b/test/environment/csh.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail --private --shell=/bin/csh\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 diff --git a/test/environment/dash.exp b/test/environment/dash.exp index c2ece31f0..4dd5cac9f 100755 --- a/test/environment/dash.exp +++ b/test/environment/dash.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail --private --tracelog --shell=/bin/dash\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 diff --git a/test/environment/deterministic-exit-code.exp b/test/environment/deterministic-exit-code.exp index d7585c401..9f5be2c3d 100755 --- a/test/environment/deterministic-exit-code.exp +++ b/test/environment/deterministic-exit-code.exp @@ -10,7 +10,7 @@ match_max 100000 send -- "firejail\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 @@ -32,7 +32,7 @@ after 100 send -- "firejail --deterministic-exit-code\r" expect { timeout {puts "TESTING ERROR 3\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 diff --git a/test/environment/dns.exp b/test/environment/dns.exp index 1fe6449b7..b5a8c119b 100755 --- a/test/environment/dns.exp +++ b/test/environment/dns.exp @@ -30,7 +30,7 @@ expect { } expect { timeout {puts "TESTING ERROR 1.5\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } expect { timeout {puts "TESTING ERROR 1.6\n";exit} @@ -47,7 +47,7 @@ expect { "DNS server 8.8.8.8" {puts "TESTING ERROR 2.3\n";exit} "DNS server 4.2.2.1" {puts "TESTING ERROR 2.4\n";exit} "DNS server ::2" {puts "TESTING ERROR 2.5\n";exit} - "Child process initialized" {puts "TESTING ERROR 2.6\n";exit} + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" {puts "TESTING ERROR 2.6\n";exit} "Parent is shutting down, bye..." {puts "TESTING ERROR 2.7\n";exit} "root" } @@ -56,7 +56,7 @@ after 100 send -- "firejail --dns=8.8.4.4 --dns=8.8.8.8 --dns=4.2.2.1 --dns=::2\r" expect { timeout {puts "TESTING ERROR 3\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 @@ -85,7 +85,7 @@ sleep 1 send -- "firejail --profile=dns.profile\r" expect { timeout {puts "TESTING ERROR 5.1\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 diff --git a/test/environment/doubledash.exp b/test/environment/doubledash.exp index 1a9ecebe1..dd2725426 100755 --- a/test/environment/doubledash.exp +++ b/test/environment/doubledash.exp @@ -10,7 +10,7 @@ match_max 100000 send -- "firejail -- ls -- -testdir\r" expect { timeout {puts "TESTING ERROR 1\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } expect { timeout {puts "TESTING ERROR 2\n";exit} @@ -26,7 +26,7 @@ sleep 1 send -- "firejail --name=testing -- -testdir/bash\r" expect { timeout {puts "TESTING ERROR 4\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 3 diff --git a/test/environment/env.exp b/test/environment/env.exp index b5ebe883c..9394f2066 100755 --- a/test/environment/env.exp +++ b/test/environment/env.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail --env=ENV1=env1 --env=ENV2=env2 --env=ENV3=env3\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 @@ -37,7 +37,7 @@ after 100 send -- "firejail --profile=env.profile\r" expect { timeout {puts "TESTING ERROR 4\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 send -- "env | grep LD_LIBRARY_PATH\r" diff --git a/test/environment/extract_command.exp b/test/environment/extract_command.exp index e719e6658..45ff1f291 100755 --- a/test/environment/extract_command.exp +++ b/test/environment/extract_command.exp @@ -14,7 +14,7 @@ expect { } expect { timeout {puts "TESTING ERROR 2\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } expect { timeout {puts "TESTING ERROR 2\n";exit} diff --git a/test/environment/firejail-in-firejail.exp b/test/environment/firejail-in-firejail.exp index 10d5c9074..4a60d5611 100755 --- a/test/environment/firejail-in-firejail.exp +++ b/test/environment/firejail-in-firejail.exp @@ -10,7 +10,7 @@ match_max 100000 send -- "firejail\r" expect { timeout {puts "TESTING ERROR 1\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 diff --git a/test/environment/hostfile.exp b/test/environment/hostfile.exp index 709eb5d36..ccc8d049e 100755 --- a/test/environment/hostfile.exp +++ b/test/environment/hostfile.exp @@ -15,7 +15,7 @@ expect { } expect { timeout {puts "TESTING ERROR 2\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } after 100 diff --git a/test/environment/ibus.exp b/test/environment/ibus.exp index e6095dc44..e9dd290a1 100755 --- a/test/environment/ibus.exp +++ b/test/environment/ibus.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } after 100 diff --git a/test/environment/keep-fd.exp b/test/environment/keep-fd.exp index 222234ceb..440cbd860 100755 --- a/test/environment/keep-fd.exp +++ b/test/environment/keep-fd.exp @@ -47,7 +47,7 @@ after 100 send -- "firejail --noprofile\r" expect { timeout {puts "TESTING ERROR 2\n";exit} - "Child process initialized" + -re {Child process initialized in [0-9]+.[0-9]+ ms} } after 100 @@ -83,7 +83,7 @@ after 500 send -- "firejail --noprofile --keep-fd=\$READ_FD\r" expect { timeout {puts "TESTING ERROR 6\n";exit} - "Child process initialized" + -re {Child process initialized in [0-9]+.[0-9]+ ms} } after 100 @@ -119,7 +119,7 @@ after 500 send -- "firejail --noprofile --keep-fd=\$WRITE_FD\r" expect { timeout {puts "TESTING ERROR 10\n";exit} - "Child process initialized" + -re {Child process initialized in [0-9]+.[0-9]+ ms} } after 100 @@ -155,7 +155,7 @@ after 500 send -- "firejail --noprofile --keep-fd=\$READ_FD,\$WRITE_FD\r" expect { timeout {puts "TESTING ERROR 14\n";exit} - "Child process initialized" + -re {Child process initialized in [0-9]+.[0-9]+ ms} } after 100 @@ -191,7 +191,7 @@ after 500 send -- "firejail --noprofile --keep-fd=all\r" expect { timeout {puts "TESTING ERROR 18\n";exit} - "Child process initialized" + -re {Child process initialized in [0-9]+.[0-9]+ ms} } after 100 diff --git a/test/environment/machineid.exp b/test/environment/machineid.exp index b7eb5c911..2392dc9d6 100755 --- a/test/environment/machineid.exp +++ b/test/environment/machineid.exp @@ -15,7 +15,7 @@ expect { } expect { timeout {puts "TESTING ERROR 1\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } after 100 send -- "exit\r" diff --git a/test/environment/nice.exp b/test/environment/nice.exp index 69e641448..823d10c67 100755 --- a/test/environment/nice.exp +++ b/test/environment/nice.exp @@ -10,7 +10,7 @@ match_max 100000 send -- "firejail --nice=15\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 @@ -39,7 +39,7 @@ after 100 send -- "firejail --profile=nice.profile\r" expect { timeout {puts "TESTING ERROR 10\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 @@ -70,7 +70,7 @@ after 100 send -- "firejail --nice=-5\r" expect { timeout {puts "TESTING ERROR 17\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 diff --git a/test/environment/rlimit-join.exp b/test/environment/rlimit-join.exp index 42a8df390..9e7161241 100755 --- a/test/environment/rlimit-join.exp +++ b/test/environment/rlimit-join.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail --noprofile --name=\"rlimit testing\"\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 @@ -21,11 +21,15 @@ expect { timeout {puts "TESTING ERROR 1\n";exit} "Switching to pid" } +expect { + timeout {puts "TESTING ERROR 2\n";exit} + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" +} sleep 1 send -- "cat /proc/self/limits\r" expect { - timeout {puts "TESTING ERROR 2\n";exit} + timeout {puts "TESTING ERROR 3\n";exit} "Max open files 1234 1234" } after 100 diff --git a/test/environment/rlimit-profile.exp b/test/environment/rlimit-profile.exp index d0365d5e3..762f70ba9 100755 --- a/test/environment/rlimit-profile.exp +++ b/test/environment/rlimit-profile.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail --profile=rlimit.profile\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 diff --git a/test/environment/rlimit.exp b/test/environment/rlimit.exp index 3bdbab4c2..acc87277b 100755 --- a/test/environment/rlimit.exp +++ b/test/environment/rlimit.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail --rlimit-fsize=1024 --rlimit-nproc=1000 --rlimit-nofile=500 --rlimit-sigpending=200 --rlimit-as=1234567890\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 diff --git a/test/environment/shell-none.exp b/test/environment/shell-none.exp index 0af1bb88b..512e2efc2 100755 --- a/test/environment/shell-none.exp +++ b/test/environment/shell-none.exp @@ -24,7 +24,7 @@ after 100 send -- "firejail --shell=none ls\r" expect { timeout {puts "TESTING ERROR 2\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } expect { timeout {puts "TESTING ERROR 3\n";exit} @@ -35,7 +35,7 @@ after 100 send -- "firejail --profile=shell-none.profile ls\r" expect { timeout {puts "TESTING ERROR 4\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } expect { timeout {puts "TESTING ERROR 5\n";exit} diff --git a/test/environment/sound.exp b/test/environment/sound.exp index 784cdfe1b..7ee1c74d7 100755 --- a/test/environment/sound.exp +++ b/test/environment/sound.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail --nosound speaker-test\r" expect { timeout {puts "TESTING ERROR 1\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } expect { timeout {puts "TESTING ERROR 2\n";exit} @@ -22,7 +22,7 @@ sleep 2 send -- "firejail --nosound aplay -l\r" expect { timeout {puts "TESTING ERROR 3\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } expect { timeout {puts "TESTING ERROR 4\n";exit} @@ -39,7 +39,7 @@ sleep 2 send -- "firejail --profile=sound.profile speaker-test\r" expect { timeout {puts "TESTING ERROR 11\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } expect { timeout {puts "TESTING ERROR 12\n";exit} @@ -50,7 +50,7 @@ sleep 2 send -- "firejail --profile=sound.profile aplay -l\r" expect { timeout {puts "TESTING ERROR 13\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } expect { timeout {puts "TESTING ERROR 14\n";exit} @@ -67,7 +67,7 @@ sleep 2 send -- "firejail aplay -l\r" expect { timeout {puts "TESTING ERROR 23\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } expect { timeout {puts "TESTING ERROR 24\n";exit} diff --git a/test/environment/timeout.exp b/test/environment/timeout.exp index 901bed2e8..b38881c81 100755 --- a/test/environment/timeout.exp +++ b/test/environment/timeout.exp @@ -10,7 +10,7 @@ match_max 100000 send -- "time firejail --timeout=00:00:05\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 diff --git a/test/environment/umask.exp b/test/environment/umask.exp index d336ed2cd..46bd80a92 100755 --- a/test/environment/umask.exp +++ b/test/environment/umask.exp @@ -10,7 +10,7 @@ match_max 100000 send -- "firejail --noprofile\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 diff --git a/test/environment/zsh.exp b/test/environment/zsh.exp index 13eee3433..9f871ea54 100755 --- a/test/environment/zsh.exp +++ b/test/environment/zsh.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail --private --shell=/bin/zsh\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "Child process initialized" + -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" } sleep 1 -- cgit v1.2.3-54-g00ecf