summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2016-11-29 23:58:21 -0500
committerGraham Christensen <graham@grahamc.com>2016-11-30 00:17:18 -0500
commitcb74fd75d700228b441b87a6dc46fba663821a97 (patch)
tree316a6017e5a07ebe0604476bdab940b138dcdcf9 /nixos/lib
parentb09435ea51caaae1865e667aaa32f7cba4cc4ff2 (diff)
downloadnixlib-cb74fd75d700228b441b87a6dc46fba663821a97.tar
nixlib-cb74fd75d700228b441b87a6dc46fba663821a97.tar.gz
nixlib-cb74fd75d700228b441b87a6dc46fba663821a97.tar.bz2
nixlib-cb74fd75d700228b441b87a6dc46fba663821a97.tar.lz
nixlib-cb74fd75d700228b441b87a6dc46fba663821a97.tar.xz
nixlib-cb74fd75d700228b441b87a6dc46fba663821a97.tar.zst
nixlib-cb74fd75d700228b441b87a6dc46fba663821a97.zip
login test: Create and use direct reads of the TTY contents.
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/test-driver/Machine.pm25
1 files changed, 25 insertions, 0 deletions
diff --git a/nixos/lib/test-driver/Machine.pm b/nixos/lib/test-driver/Machine.pm
index 1a243918c22f..274b16164db3 100644
--- a/nixos/lib/test-driver/Machine.pm
+++ b/nixos/lib/test-driver/Machine.pm
@@ -504,6 +504,31 @@ sub screenshot {
     }, { image => $name } );
 }
 
+# Get the text of TTY<n>
+sub getTTYText {
+    my ($self, $tty) = @_;
+
+    my ($status, $out) = $self->execute("fold -w 80 /dev/vcs${tty}");
+    return $out;
+}
+
+# Wait until TTY<n>'s text matches a particular regular expression
+sub waitUntilTTYMatches {
+    my ($self, $tty, $regexp) = @_;
+
+    $self->nest("waiting for $regexp to appear on tty $tty", sub {
+        retry sub {
+            return 1 if $self->getTTYText($tty) =~ /$regexp/;
+        }
+    });
+}
+
+# Debugging: Dump the contents of the TTY<n>
+sub dumpTTYContents {
+    my ($self, $tty) = @_;
+
+    $self->execute("fold -w 80 /dev/vcs${tty} | systemd-cat");
+}
 
 # Take a screenshot and return the result as text using optical character
 # recognition.