github.com/xyproto/u-root@v6.0.1-0.20200302025726-5528e0c77a3c+incompatible/integration/generic-tests/io_test.go (about) 1 // Copyright 2018 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 // +build amd64,!race 6 7 package integration 8 9 import ( 10 "fmt" 11 "testing" 12 13 "github.com/u-root/u-root/pkg/vmtest" 14 ) 15 16 // TestIO tests the string "UART TEST" is written to the serial port on 0x3f8. 17 func TestIO(t *testing.T) { 18 // TODO: support arm 19 if vmtest.TestArch() != "amd64" { 20 t.Skipf("test not supported on %s", vmtest.TestArch()) 21 } 22 23 testCmds := []string{} 24 for _, b := range []byte("UART TEST\r\n") { 25 testCmds = append(testCmds, fmt.Sprintf("io outb 0x3f8 %d", b)) 26 } 27 28 // Create the CPIO and start QEMU. 29 q, cleanup := vmtest.QEMUTest(t, &vmtest.Options{ 30 TestCmds: testCmds, 31 }) 32 defer cleanup() 33 34 if err := q.Expect("UART TEST"); err != nil { 35 t.Fatal(`expected "UART TEST", got error: `, err) 36 } 37 }