github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/integration/testcmd/helloworld/uinit/helloworld.go (about) 1 // Copyright 2021 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 main 6 7 import ( 8 "fmt" 9 "log" 10 11 "github.com/mvdan/u-root-coreutils/integration/testcmd/common" 12 "golang.org/x/sys/unix" 13 ) 14 15 func runTest() error { 16 cleanup, err := common.MountSharedDir() 17 if err != nil { 18 return err 19 } 20 defer cleanup() 21 defer common.CollectKernelCoverage() 22 23 fmt.Println("HELLO WORLD") 24 return nil 25 } 26 27 // The most trivial init script. 28 func main() { 29 if err := runTest(); err != nil { 30 log.Printf("Tests failed: %v", err) 31 } else { 32 log.Print("Tests passed") 33 } 34 35 if err := unix.Reboot(unix.LINUX_REBOOT_CMD_POWER_OFF); err != nil { 36 log.Fatalf("Failed to reboot: %v", err) 37 } 38 }