github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/tools/syz-tty/syz-tty.go (about)

     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  //
     6  //	$ syz-tty /dev/ttyUSBx
     7  //
     8  // This should dump device console output.
     9  package main
    10  
    11  import (
    12  	"fmt"
    13  	"io"
    14  	"os"
    15  
    16  	"github.com/google/syzkaller/vm/vmimpl"
    17  )
    18  
    19  func main() {
    20  	if len(os.Args) != 2 {
    21  		fmt.Fprintf(os.Stderr, "usage: %v /dev/ttyUSBx\n", os.Args[0])
    22  		os.Exit(1)
    23  	}
    24  	con, err := vmimpl.OpenConsole(os.Args[1])
    25  	if err != nil {
    26  		fmt.Fprintf(os.Stderr, "failed to open console: %v\n", err)
    27  		os.Exit(1)
    28  	}
    29  	defer con.Close()
    30  	io.Copy(os.Stdout, con)
    31  }