aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-tty/syz-tty.go
blob: 01788259efa054968762ea990f87193cc4aea301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2017 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

// syz-tty is utility for testing of usb console reading code. Usage:
//
//	$ syz-tty /dev/ttyUSBx
//
// This should dump device console output.
package main

import (
	"fmt"
	"io"
	"os"

	"github.com/google/syzkaller/vm/vmimpl"
)

func main() {
	if len(os.Args) != 2 {
		fmt.Fprintf(os.Stderr, "usage: %v /dev/ttyUSBx\n", os.Args[0])
		os.Exit(1)
	}
	con, err := vmimpl.OpenConsole(os.Args[1])
	if err != nil {
		fmt.Fprintf(os.Stderr, "failed to open console: %v\n", err)
		os.Exit(1)
	}
	defer con.Close()
	io.Copy(os.Stdout, con)
}