gopkg.in/hugelgupf/u-root.v4@v4.0.0-20180831060141-1d761fb73d50/integration/uinit_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 package integration 6 7 import ( 8 "testing" 9 ) 10 11 // TestHelloWorld runs an init which prints the string "HELLO WORLD" and exits. 12 func TestHelloWorld(t *testing.T) { 13 // Create the CPIO and start QEMU. 14 tmpDir, q := testWithQEMU(t, "helloworld", []string{}) 15 defer cleanup(t, tmpDir, q) 16 17 if err := q.Expect("HELLO WORLD"); err != nil { 18 t.Fatal(`expected "HELLO WORLD", got error: `, err) 19 } 20 } 21 22 // TestHelloWorldNegative runs an init which does not print the string "HELLO WORLD". 23 func TestHelloWorldNegative(t *testing.T) { 24 // Create the CPIO and start QEMU. 25 tmpDir, q := testWithQEMU(t, "helloworld", []string{}) 26 defer cleanup(t, tmpDir, q) 27 28 if err := q.Expect("GOODBYE WORLD"); err == nil { 29 t.Fatal(`expected error, but matched "GOODBYE WORLD"`) 30 } 31 }