github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/integration/generic-tests/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 //go:build !race 6 // +build !race 7 8 package integration 9 10 import ( 11 "testing" 12 13 "github.com/mvdan/u-root-coreutils/pkg/vmtest" 14 ) 15 16 // TestHelloWorld runs an init which prints the string "HELLO WORLD" and exits. 17 func TestHelloWorld(t *testing.T) { 18 q, cleanup := vmtest.QEMUTest(t, &vmtest.Options{ 19 Uinit: "github.com/mvdan/u-root-coreutils/integration/testcmd/helloworld/uinit", 20 }) 21 defer cleanup() 22 23 if err := q.Expect("HELLO WORLD"); err != nil { 24 t.Fatal(`expected "HELLO WORLD", got error: `, err) 25 } 26 } 27 28 // TestHelloWorldNegative runs an init which does not print the string "HELLO WORLD". 29 func TestHelloWorldNegative(t *testing.T) { 30 q, cleanup := vmtest.QEMUTest(t, &vmtest.Options{ 31 Uinit: "github.com/mvdan/u-root-coreutils/integration/testcmd/helloworld/uinit", 32 }) 33 defer cleanup() 34 35 if err := q.Expect("GOODBYE WORLD"); err == nil { 36 t.Fatal(`expected error, but matched "GOODBYE WORLD"`) 37 } 38 }