aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-06-26 16:22:29 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-06-26 16:22:29 +0200
commitf6267bfc3686037be7bd0c2b394dcdd0dc150258 (patch)
tree414637a08958ab1dc0b3930daac19c22c208704b /tools
parent43f0f8f079de145a601472e0c630d4f7de3cf434 (diff)
tools/syz-tty: add utility for testing of usb console reading code
Diffstat (limited to 'tools')
-rw-r--r--tools/syz-tty/syz-tty.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/syz-tty/syz-tty.go b/tools/syz-tty/syz-tty.go
new file mode 100644
index 000000000..a03e7ee39
--- /dev/null
+++ b/tools/syz-tty/syz-tty.go
@@ -0,0 +1,29 @@
+// 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[0])
+ 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)
+}