3
0
Fork 0
forked from mirrors/nixpkgs

nixosTests: Redirect stdout to stderr when detaching

Avoids blocking on stdout.
This commit is contained in:
Robert Hensing 2021-11-05 01:43:22 +01:00
parent 698fb089d8
commit 739c51ae4e
34 changed files with 44 additions and 44 deletions

View file

@ -119,7 +119,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
with subtest("Stop a container early"): with subtest("Stop a container early"):
machine.succeed(f"nixos-container stop {id1}") machine.succeed(f"nixos-container stop {id1}")
machine.succeed(f"nixos-container start {id1} &") machine.succeed(f"nixos-container start {id1} >&2 &")
machine.wait_for_console_text("Stage 2") machine.wait_for_console_text("Stage 2")
machine.succeed(f"nixos-container stop {id1}") machine.succeed(f"nixos-container stop {id1}")
machine.wait_for_console_text(f"Container {id1} exited successfully") machine.wait_for_console_text(f"Container {id1} exited successfully")

View file

@ -38,7 +38,7 @@ in {
sender.execute("echo Hello World > testfile01.txt") sender.execute("echo Hello World > testfile01.txt")
sender.execute("echo Hello Earth > testfile02.txt") sender.execute("echo Hello Earth > testfile02.txt")
sender.execute( sender.execute(
"croc --pass ${pass} --relay relay send --code topSecret testfile01.txt testfile02.txt &" "croc --pass ${pass} --relay relay send --code topSecret testfile01.txt testfile02.txt >&2 &"
) )
# receive the testfiles and check them # receive the testfiles and check them

View file

@ -33,7 +33,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
) )
# connects to the daemon # connects to the daemon
machine.succeed("emacsclient --create-frame $EDITOR &") machine.succeed("emacsclient --create-frame $EDITOR >&2 &")
# checks that Emacs shows the edited filename # checks that Emacs shows the edited filename
machine.wait_for_text("emacseditor") machine.wait_for_text("emacseditor")

View file

@ -88,7 +88,7 @@ import ./make-test-python.nix ({ pkgs, ...} :
machine.screenshot("wizard12") machine.screenshot("wizard12")
with subtest("Run Terminology"): with subtest("Run Terminology"):
machine.succeed("terminology &") machine.succeed("terminology >&2 &")
machine.sleep(5) machine.sleep(5)
machine.send_chars("ls --color -alF\n") machine.send_chars("ls --color -alF\n")
machine.sleep(2) machine.sleep(2)

View file

@ -13,7 +13,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
'' ''
machine.wait_for_unit("multi-user.target") machine.wait_for_unit("multi-user.target")
machine.succeed("etesync-dav --version") machine.succeed("etesync-dav --version")
machine.execute("etesync-dav &") machine.execute("etesync-dav >&2 &")
machine.wait_for_open_port(37358) machine.wait_for_open_port(37358)
with subtest("Check that the web interface is accessible"): with subtest("Check that the web interface is accessible"):
assert "Add User" in machine.succeed("curl -s http://localhost:37358/.web/add/") assert "Add User" in machine.succeed("curl -s http://localhost:37358/.web/add/")

View file

@ -91,7 +91,7 @@ import ./make-test-python.nix ({ pkgs, firefoxPackage, ... }: {
with subtest("Wait until Firefox has finished loading the Valgrind docs page"): with subtest("Wait until Firefox has finished loading the Valgrind docs page"):
machine.execute( machine.execute(
"xterm -e 'firefox file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' &" "xterm -e 'firefox file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' >&2 &"
) )
machine.wait_for_window("Valgrind") machine.wait_for_window("Valgrind")
machine.sleep(40) machine.sleep(40)
@ -99,7 +99,7 @@ import ./make-test-python.nix ({ pkgs, firefoxPackage, ... }: {
with subtest("Check whether Firefox can play sound"): with subtest("Check whether Firefox can play sound"):
with audio_recording(machine): with audio_recording(machine):
machine.succeed( machine.succeed(
"firefox file://${pkgs.sound-theme-freedesktop}/share/sounds/freedesktop/stereo/phone-incoming-call.oga &" "firefox file://${pkgs.sound-theme-freedesktop}/share/sounds/freedesktop/stereo/phone-incoming-call.oga >&2 &"
) )
wait_for_sound(machine) wait_for_sound(machine)
machine.copy_from_vm("/tmp/record.wav") machine.copy_from_vm("/tmp/record.wav")

View file

@ -22,7 +22,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
# Add a dummy sound card, or the program won't start # Add a dummy sound card, or the program won't start
machine.execute("modprobe snd-dummy") machine.execute("modprobe snd-dummy")
machine.execute("ft2-clone &") machine.execute("ft2-clone >&2 &")
machine.wait_for_window(r"Fasttracker") machine.wait_for_window(r"Fasttracker")
machine.sleep(5) machine.sleep(5)

View file

@ -110,7 +110,7 @@ in makeTest {
) )
# Hibernate machine # Hibernate machine
hibernate.execute("systemctl hibernate &", check_return=False) hibernate.execute("systemctl hibernate >&2 &", check_return=False)
hibernate.wait_for_shutdown() hibernate.wait_for_shutdown()
# Restore machine from hibernation, validate our ramfs file is there. # Restore machine from hibernation, validate our ramfs file is there.

View file

@ -26,7 +26,7 @@ import ./make-test-python.nix ({ pkgs, ...} :
machine.wait_for_x() machine.wait_for_x()
# start KeePassXC window # start KeePassXC window
machine.execute("su - alice -c keepassxc &") machine.execute("su - alice -c keepassxc >&2 &")
machine.wait_for_text("KeePassXC ${pkgs.keepassxc.version}") machine.wait_for_text("KeePassXC ${pkgs.keepassxc.version}")
machine.screenshot("KeePassXC") machine.screenshot("KeePassXC")

View file

@ -18,7 +18,7 @@ import ./make-test-python.nix ({ pkgs, lib, ...} : {
testScript = testScript =
'' ''
machine.wait_for_unit("multi-user.target") machine.wait_for_unit("multi-user.target")
machine.execute("systemctl kexec &", check_return=False) machine.execute("systemctl kexec >&2 &", check_return=False)
machine.connected = False machine.connected = False
machine.wait_for_unit("multi-user.target") machine.wait_for_unit("multi-user.target")
''; '';

View file

@ -46,7 +46,7 @@ let
# set up process that expects all the keys to be entered # set up process that expects all the keys to be entered
machine.succeed( machine.succeed(
"{} {} {} {} &".format( "{} {} {} {} >&2 &".format(
cmd, cmd,
"${testReader}", "${testReader}",
len(inputs), len(inputs),

View file

@ -89,7 +89,7 @@ in
""" """
Sends a message as Alice to Bob Sends a message as Alice to Bob
""" """
bob.execute("nc -lu ::0 1234 >/tmp/msg &") bob.execute("nc -lu ::0 1234 >/tmp/msg >&2 &")
alice.sleep(1) alice.sleep(1)
alice.succeed(f"echo '{msg}' | nc -uw 0 bob 1234") alice.succeed(f"echo '{msg}' | nc -uw 0 bob 1234")
bob.succeed(f"grep '{msg}' /tmp/msg") bob.succeed(f"grep '{msg}' /tmp/msg")
@ -100,7 +100,7 @@ in
Starts eavesdropping on Alice and Bob Starts eavesdropping on Alice and Bob
""" """
match = "src host alice and dst host bob" match = "src host alice and dst host bob"
eve.execute(f"tcpdump -i br0 -c 1 -Avv {match} >/tmp/log &") eve.execute(f"tcpdump -i br0 -c 1 -Avv {match} >/tmp/log >&2 &")
start_all() start_all()
@ -120,7 +120,7 @@ in
alice.succeed("ipsec verify 1>&2") alice.succeed("ipsec verify 1>&2")
with subtest("Alice and Bob can start the tunnel"): with subtest("Alice and Bob can start the tunnel"):
alice.execute("ipsec auto --start tunnel &") alice.execute("ipsec auto --start tunnel >&2 &")
bob.succeed("ipsec auto --start tunnel") bob.succeed("ipsec auto --start tunnel")
# apparently this is needed to "wake" the tunnel # apparently this is needed to "wake" the tunnel
bob.execute("ping -c1 alice") bob.execute("ping -c1 alice")

View file

@ -14,7 +14,7 @@ import ../make-test-python.nix {
) )
# Start the daemon and wait until it is ready # Start the daemon and wait until it is ready
machine.execute("lorri daemon > lorri.stdout 2> lorri.stderr &") machine.execute("lorri daemon > lorri.stdout 2> lorri.stderr >&2 &")
machine.wait_until_succeeds("grep --fixed-strings 'ready' lorri.stdout") machine.wait_until_succeeds("grep --fixed-strings 'ready' lorri.stdout")
# Ping the daemon # Ping the daemon

View file

@ -29,7 +29,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
# Create a secret file and send it to Bob # Create a secret file and send it to Bob
client_alice.succeed("echo mysecret > secretfile") client_alice.succeed("echo mysecret > secretfile")
client_alice.succeed("wormhole --relay-url=ws://server:4000/v1 send -0 secretfile &") client_alice.succeed("wormhole --relay-url=ws://server:4000/v1 send -0 secretfile >&2 &")
# Retrieve a secret file from Alice and check its content # Retrieve a secret file from Alice and check its content
client_bob.succeed("wormhole --relay-url=ws://server:4000/v1 receive -0 --accept-file") client_bob.succeed("wormhole --relay-url=ws://server:4000/v1 receive -0 --accept-file")

View file

@ -20,7 +20,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
let user = nodes.client.config.users.users.alice; let user = nodes.client.config.users.users.alice;
in '' in ''
client.wait_for_x() client.wait_for_x()
client.execute("su - alice -c minecraft-launcher &") client.execute("su - alice -c minecraft-launcher >&2 &")
client.wait_for_text("Create a new Microsoft account") client.wait_for_text("Create a new Microsoft account")
client.sleep(10) client.sleep(10)
client.screenshot("launcher") client.screenshot("launcher")

View file

@ -21,7 +21,7 @@ in
}; };
testScript = '' testScript = ''
machine.execute("set -m; mpv --script-opts=webui-port=${port} --idle=yes &") machine.execute("set -m; mpv --script-opts=webui-port=${port} --idle=yes >&2 &")
machine.wait_for_open_port(${port}) machine.wait_for_open_port(${port})
assert "<title>simple-mpv-webui" in machine.succeed("curl -s localhost:${port}") assert "<title>simple-mpv-webui" in machine.succeed("curl -s localhost:${port}")
''; '';

View file

@ -38,8 +38,8 @@ in
client1.wait_for_x() client1.wait_for_x()
client2.wait_for_x() client2.wait_for_x()
client1.execute("mumble mumble://client1:testpassword\@server/test &") client1.execute("mumble mumble://client1:testpassword\@server/test >&2 &")
client2.execute("mumble mumble://client2:testpassword\@server/test &") client2.execute("mumble mumble://client2:testpassword\@server/test >&2 &")
# cancel client audio configuration # cancel client audio configuration
client1.wait_for_window(r"Audio Tuning Wizard") client1.wait_for_window(r"Audio Tuning Wizard")

View file

@ -44,7 +44,7 @@ in
) )
# Start MuseScore window # Start MuseScore window
machine.execute("DISPLAY=:0.0 mscore &") machine.execute("DISPLAY=:0.0 mscore >&2 &")
# Wait until MuseScore has launched # Wait until MuseScore has launched
machine.wait_for_window("MuseScore") machine.wait_for_window("MuseScore")

View file

@ -66,7 +66,7 @@ in
client2.succeed("time flock -n -s /data/lock true") client2.succeed("time flock -n -s /data/lock true")
with subtest("client 2 fails to acquire lock held by client 1"): with subtest("client 2 fails to acquire lock held by client 1"):
client1.succeed("flock -x /data/lock -c 'touch locked; sleep 100000' &") client1.succeed("flock -x /data/lock -c 'touch locked; sleep 100000' >&2 &")
client1.wait_for_file("locked") client1.wait_for_file("locked")
client2.fail("flock -n -s /data/lock true") client2.fail("flock -n -s /data/lock true")

View file

@ -76,7 +76,7 @@ import ./make-test-python.nix {
server.wait_for_unit("nginx.service") server.wait_for_unit("nginx.service")
client.wait_for_unit("multi-user.target") client.wait_for_unit("multi-user.target")
client.execute("test-runner &") client.execute("test-runner >&2 &")
client.wait_for_file("/tmp/passed_stage1") client.wait_for_file("/tmp/passed_stage1")
server.succeed( server.succeed(

View file

@ -78,7 +78,7 @@ let
# Put newlines on console, to flush the console reader's line buffer # Put newlines on console, to flush the console reader's line buffer
# in case nixops' last output did not end in a newline, as is the case # in case nixops' last output did not end in a newline, as is the case
# with a status line (if implemented?) # with a status line (if implemented?)
deployer.succeed("while sleep 60s; do echo [60s passed] >/dev/console; done &") deployer.succeed("while sleep 60s; do echo [60s passed]; done >&2 &")
deployer_do("cd ~/unicorn; ssh -oStrictHostKeyChecking=accept-new root@server echo hi") deployer_do("cd ~/unicorn; ssh -oStrictHostKeyChecking=accept-new root@server echo hi")

View file

@ -38,8 +38,8 @@ in {
client1.wait_for_x() client1.wait_for_x()
client2.wait_for_x() client2.wait_for_x()
client1.execute("openarena +set r_fullscreen 0 +set name Foo +connect server &") client1.execute("openarena +set r_fullscreen 0 +set name Foo +connect server >&2 &")
client2.execute("openarena +set r_fullscreen 0 +set name Bar +connect server &") client2.execute("openarena +set r_fullscreen 0 +set name Bar +connect server >&2 &")
server.wait_until_succeeds( server.wait_until_succeeds(
"journalctl -u openarena -e | grep -q 'Foo.*entered the game'" "journalctl -u openarena -e | grep -q 'Foo.*entered the game'"

View file

@ -14,7 +14,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
testScript = '' testScript = ''
machine.wait_for_x() machine.wait_for_x()
machine.succeed("gnome-calculator &") machine.succeed("gnome-calculator >&2 &")
machine.wait_for_window("gnome-calculator") machine.wait_for_window("gnome-calculator")
machine.succeed( machine.succeed(
"xdotool search --sync --onlyvisible --class gnome-calculator " "xdotool search --sync --onlyvisible --class gnome-calculator "

View file

@ -22,7 +22,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
# Add a dummy sound card, or the program won't start # Add a dummy sound card, or the program won't start
machine.execute("modprobe snd-dummy") machine.execute("modprobe snd-dummy")
machine.execute("pt2-clone &") machine.execute("pt2-clone >&2 &")
machine.wait_for_window(r"ProTracker") machine.wait_for_window(r"ProTracker")
machine.sleep(5) machine.sleep(5)

View file

@ -19,7 +19,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
testScript = testScript =
'' ''
machine.wait_for_x() machine.wait_for_x()
machine.execute("shattered-pixel-dungeon &") machine.execute("shattered-pixel-dungeon >&2 &")
machine.wait_for_window(r"Shattered Pixel Dungeon") machine.wait_for_window(r"Shattered Pixel Dungeon")
machine.sleep(5) machine.sleep(5)
if "Enter" not in machine.get_screen_text(): if "Enter" not in machine.get_screen_text():

View file

@ -41,7 +41,7 @@ in {
machine.wait_for_x() machine.wait_for_x()
# start signal desktop # start signal desktop
machine.execute("su - alice -c signal-desktop &") machine.execute("su - alice -c signal-desktop >&2 &")
# Wait for the Signal window to appear. Since usually the tests # Wait for the Signal window to appear. Since usually the tests
# are run sandboxed and therfore with no internet, we can not wait # are run sandboxed and therfore with no internet, we can not wait

View file

@ -16,7 +16,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
testScript = '' testScript = ''
machine.wait_for_x() machine.wait_for_x()
machine.succeed("soapui &") machine.succeed("soapui >&2 &")
machine.wait_for_window(r"SoapUI \d+\.\d+\.\d+") machine.wait_for_window(r"SoapUI \d+\.\d+\.\d+")
machine.sleep(1) machine.sleep(1)
machine.screenshot("soapui") machine.screenshot("soapui")

View file

@ -35,13 +35,13 @@ makeTest {
for host in [server, client]: for host in [server, client]:
host.succeed("echo foobar | vncpasswd -f > vncpasswd") host.succeed("echo foobar | vncpasswd -f > vncpasswd")
server.succeed("Xvnc -geometry 720x576 :1 -PasswordFile vncpasswd &") server.succeed("Xvnc -geometry 720x576 :1 -PasswordFile vncpasswd >&2 &")
server.wait_until_succeeds("nc -z localhost 5901", timeout=10) server.wait_until_succeeds("nc -z localhost 5901", timeout=10)
server.succeed("DISPLAY=:1 xwininfo -root | grep 720x576") server.succeed("DISPLAY=:1 xwininfo -root | grep 720x576")
server.execute("DISPLAY=:1 display -size 360x200 -font sans -gravity south label:'HELLO VNC WORLD' &") server.execute("DISPLAY=:1 display -size 360x200 -font sans -gravity south label:'HELLO VNC WORLD' >&2 &")
client.wait_for_x() client.wait_for_x()
client.execute("vncviewer server:1 -PasswordFile vncpasswd &") client.execute("vncviewer server:1 -PasswordFile vncpasswd >&2 &")
client.wait_for_window(r"VNC") client.wait_for_window(r"VNC")
client.screenshot("screenshot") client.screenshot("screenshot")
text = client.get_screen_text() text = client.get_screen_text()

View file

@ -97,7 +97,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
) )
machine.execute( machine.execute(
# Note trailing & for backgrounding. # Note trailing & for backgrounding.
f"({xvnc_command} | tee /tmp/Xvnc.stdout) 3>&1 1>&2 2>&3 | tee /tmp/Xvnc.stderr &", f"({xvnc_command} | tee /tmp/Xvnc.stdout) 3>&1 1>&2 2>&3 | tee /tmp/Xvnc.stderr >&2 &",
) )
@ -119,7 +119,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
def test_glxgears_failing_with_bad_driver_path(): def test_glxgears_failing_with_bad_driver_path():
machine.execute( machine.execute(
# Note trailing & for backgrounding. # Note trailing & for backgrounding.
"(env DISPLAY=:0 LIBGL_DRIVERS_PATH=/nonexistent glxgears -info | tee /tmp/glxgears-should-fail.stdout) 3>&1 1>&2 2>&3 | tee /tmp/glxgears-should-fail.stderr &" "(env DISPLAY=:0 LIBGL_DRIVERS_PATH=/nonexistent glxgears -info | tee /tmp/glxgears-should-fail.stdout) 3>&1 1>&2 2>&3 | tee /tmp/glxgears-should-fail.stderr >&2 &"
) )
machine.wait_until_succeeds("test -f /tmp/glxgears-should-fail.stderr") machine.wait_until_succeeds("test -f /tmp/glxgears-should-fail.stderr")
wait_until_terminated_or_succeeds( wait_until_terminated_or_succeeds(
@ -136,7 +136,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: {
def test_glxgears_prints_renderer(): def test_glxgears_prints_renderer():
machine.execute( machine.execute(
# Note trailing & for backgrounding. # Note trailing & for backgrounding.
"(env DISPLAY=:0 glxgears -info | tee /tmp/glxgears.stdout) 3>&1 1>&2 2>&3 | tee /tmp/glxgears.stderr &" "(env DISPLAY=:0 glxgears -info | tee /tmp/glxgears.stdout) 3>&1 1>&2 2>&3 | tee /tmp/glxgears.stderr >&2 &"
) )
machine.wait_until_succeeds("test -f /tmp/glxgears.stderr") machine.wait_until_succeeds("test -f /tmp/glxgears.stderr")
wait_until_terminated_or_succeeds( wait_until_terminated_or_succeeds(

View file

@ -16,7 +16,7 @@ import ./make-test-python.nix ({ pkgs, ... }: {
testScript = '' testScript = ''
machine.wait_for_x() machine.wait_for_x()
machine.succeed("tuxguitar &") machine.succeed("tuxguitar >&2 &")
machine.wait_for_window("TuxGuitar - Untitled.tg") machine.wait_for_window("TuxGuitar - Untitled.tg")
machine.sleep(1) machine.sleep(1)
machine.screenshot("tuxguitar") machine.screenshot("tuxguitar")

View file

@ -430,7 +430,7 @@ in mapAttrs (mkVBoxTest false vboxVMs) {
create_vm_simple() create_vm_simple()
machine.succeed(ru("VirtualBox &")) machine.succeed(ru("VirtualBox >&2 &"))
machine.wait_until_succeeds(ru("xprop -name 'Oracle VM VirtualBox Manager'")) machine.wait_until_succeeds(ru("xprop -name 'Oracle VM VirtualBox Manager'"))
machine.sleep(5) machine.sleep(5)
machine.screenshot("gui_manager_started") machine.screenshot("gui_manager_started")

View file

@ -31,7 +31,7 @@ import ./make-test-python.nix ({ pkgs, ...} :
# Start VSCodium with a file that doesn't exist yet # Start VSCodium with a file that doesn't exist yet
machine.fail("ls /home/alice/foo.txt") machine.fail("ls /home/alice/foo.txt")
machine.succeed("su - alice -c 'codium foo.txt' &") machine.succeed("su - alice -c 'codium foo.txt' >&2 &")
# Wait for the window to appear # Wait for the window to appear
machine.wait_for_text("VSCodium") machine.wait_for_text("VSCodium")

View file

@ -32,13 +32,13 @@ import ./make-test-python.nix ({ pkgs, ...} : {
client.sleep(5) client.sleep(5)
client.execute("xterm &") client.execute("xterm >&2 &")
client.sleep(1) client.sleep(1)
client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password}\n") client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password}\n")
client.sleep(5) client.sleep(5)
client.screenshot("localrdp") client.screenshot("localrdp")
client.execute("xterm &") client.execute("xterm >&2 &")
client.sleep(1) client.sleep(1)
client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password}\n") client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password}\n")
client.sleep(5) client.sleep(5)

View file

@ -13,7 +13,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
testScript = testScript =
'' ''
machine.wait_for_x() machine.wait_for_x()
machine.succeed("DISPLAY=:0 xterm -title testterm -class testterm -fullscreen &") machine.succeed("DISPLAY=:0 xterm -title testterm -class testterm -fullscreen >&2 &")
machine.sleep(2) machine.sleep(2)
machine.send_chars("echo $XTERM_VERSION >> /tmp/xterm_version\n") machine.send_chars("echo $XTERM_VERSION >> /tmp/xterm_version\n")
machine.wait_for_file("/tmp/xterm_version") machine.wait_for_file("/tmp/xterm_version")