Home | History | Annotate | Download | only in syz-tty
      1 // Copyright 2017 syzkaller project authors. All rights reserved.
      2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
      3 
      4 // syz-tty is utility for testing of usb console reading code. Usage:
      5 //   $ syz-tty /dev/ttyUSBx
      6 // This should dump device console output.
      7 package main
      8 
      9 import (
     10 	"fmt"
     11 	"io"
     12 	"os"
     13 
     14 	"github.com/google/syzkaller/vm/vmimpl"
     15 )
     16 
     17 func main() {
     18 	if len(os.Args) != 2 {
     19 		fmt.Fprintf(os.Stderr, "usage: %v /dev/ttyUSBx\n", os.Args[0])
     20 		os.Exit(1)
     21 	}
     22 	con, err := vmimpl.OpenConsole(os.Args[1])
     23 	if err != nil {
     24 		fmt.Fprintf(os.Stderr, "failed to open console: %v\n", err)
     25 		os.Exit(1)
     26 	}
     27 	defer con.Close()
     28 	io.Copy(os.Stdout, con)
     29 }
     30