# selftest_nano.exp — drives GNU nano over a REAL pty (BRINTOS-283). # # nano has no batch mode. It is a full-screen curses editor, so the only way to # assert it works on this target is to give it a terminal and type at it: cooked # stdin proves nothing about the thing that is actually new here. This payload is # also the first consumer on this image to exercise the terminfo database END TO # END — 07-ncurses-terminfo-base.test can only check that the entry files exist # and carry the right magic, because the runner is piped and less reads terminfo # on a real tty only. Here $TERM=xterm is resolved through /etc/terminfo by # ncurses itself, and the title bar arriving is the proof. # # WHY THE VERDICTS ARE ON DISK, NOT ON THE SCREEN. Reading nano's ongoing screen # repaints back through the pty proved unreliable on this target: the first burst # (setup + title bar) arrives, and matching anything painted after it times out, # even though nano is demonstrably still running and still obeying keystrokes. # That is not currently understood well enough to call a platform defect, and it # does not need to be, because a screen scrape is the WEAKER assertion anyway — a # curses app can repaint a convincing lie. So this payload types blind against # settle delays and lets 58-nano.test assert the BYTES THAT REACHED THE DISK. # The one screen assertion kept (N1start) is the one measured to be reliable. # # Keystrokes are control characters (^O ^X ^K) — single bytes, no timing # ambiguity — EXCEPT the deliberate one: N3arrow sends the Down arrow, ESC [ B. # That is the ticket's stated risk (the runtime's defective timers can distort the # inter-byte gap ncurses uses to tell a lone ESC from the start of a sequence), # and it is measured through the disk: after Down, ^K must cut line 2 (bravo). If # the sequence had not decoded, a different line would go — or "[B" would be typed # into the buffer — and the assertion names which. # # argv: — created and pre-seeded by 58-nano.test, which asserts the # resulting files. # Emits N- OK/FAIL lines, then ALL-NANO-OK iff every case passed. log_user 0 set stty_init "rows 24 columns 80" set env(TERM) "xterm" set timeout 6 set work [lindex $argv 0] set pass 0 set total 0 proc verdict {tag ok} { global pass total incr total if {$ok} { incr pass; puts "N-$tag OK" } else { puts "N-$tag FAIL" } } # --- S1: start on a new file, type two lines, write them out, leave. # Reaching the title bar already proves a lot: get_homedir() runs before the first # repaint and calls getpwuid() here (the target is root), which is the static-glibc # NSS path that used to trap (BRINTOS-77 / linux-in-the-browser#92). A hang or a # signal instead of a title bar is that trap coming back. set ok 0 spawn -noecho nano -I $work/typed.txt expect { "GNU nano 7.2" { set ok 1 } timeout {} eof {} } verdict N1start $ok sleep 1 send "hello from nano\r" send "second line" sleep 1 send "\017" sleep 1 send "\r" sleep 1 send "\030" expect { eof {} timeout {} } lassign [wait] _p _s _oserr rc1 verdict N2exit [expr {$_oserr == 0 && $rc1 == 0}] # --- S2: ^K cuts the line the cursor is on (line 1) — a plain control byte. spawn -noecho nano -I $work/cut.txt sleep 2 send "\013" sleep 1 send "\017" sleep 1 send "\r" sleep 1 send "\030" expect { eof {} timeout {} } lassign [wait] _p _s _oserr rc2 verdict N3cutexit [expr {$_oserr == 0 && $rc2 == 0}] # --- S3: the escape-sequence probe. Down arrow (ESC [ B) then ^K, so WHICH line # disappears is the answer: line 2 (bravo) means the sequence decoded. spawn -noecho nano -I $work/arrow.txt sleep 2 send "\033\[B" sleep 1 send "\013" sleep 1 send "\017" sleep 1 send "\r" sleep 1 send "\030" expect { eof {} timeout {} } lassign [wait] _p _s _oserr rc3 verdict N4arrowexit [expr {$_oserr == 0 && $rc3 == 0}] puts "N-SUMMARY pass=$pass/$total" if {$pass == $total} { puts "ALL-NANO-OK" }