github.com/ratrocket/u-root@v0.0.0-20180201221235-1cf9f48ee2cf/pkg/pty/pty_test.go (about) 1 // Copyright 2015-2017 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package pty 6 7 import ( 8 "reflect" 9 "testing" 10 ) 11 12 func TestNew(t *testing.T) { 13 if _, err := New("/bin/bash", "-c", "/bin/date"); err != nil { 14 t.Errorf("New pty: want nil, got %v", err) 15 } 16 } 17 18 func TestRunRestoreTTYMode(t *testing.T) { 19 p, err := New("echo", "hi") 20 if err != nil { 21 t.Fatalf("TestStart New pty: want nil, got %v", err) 22 } 23 if err := p.Run(); err != nil { 24 t.Fatalf("TestStart Start: want nil, got %v", err) 25 } 26 ti, err := p.TTY.Get() 27 if err != nil { 28 t.Fatalf("TestStart Get: want nil, got %v", err) 29 } 30 if !reflect.DeepEqual(ti, p.Restorer) { 31 t.Errorf("TestStart: want termios from Get %v to be the same as termios from Start (%v) to be the same, they differ", ti, p.Restorer) 32 } 33 }