Skip to content

[pull] main from u-root:main #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 120 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
598c62a
pkg/securelaunch: use bytes.Equals instead bytes.Compare
binjip978 Apr 10, 2025
9640da5
cmds/exp/netbootxyz: fix staticcheck gosimple issues
binjip978 Apr 12, 2025
5b7ddb7
pkg/boot/universalpayload: omit comparison with boolean constant
binjip978 Apr 12, 2025
5b03078
pkg/boot/menu: omit redundant nil check
binjip978 Apr 12, 2025
c2c4fe8
cmds/exp/tcpdump: use String() instead of fmt.Sprintf
binjip978 Apr 12, 2025
1e6b090
cmds/core/netcat: eliminate dead condition
lersek Apr 11, 2025
54895c5
pkg/netcat: move SSLOptions.GenerateTLSConfiguration() to temporary s…
lersek Apr 11, 2025
b7e857a
netcat: clean up SSL option processing
lersek Apr 11, 2025
e3be209
integration/generic-tests/netcat_test: make netcatVM() variadic
lersek Apr 14, 2025
b5d4025
integration/generic-tests: add netcat SSL tests
lersek Apr 14, 2025
eb2382b
cmds/core/netcat: clean-up usage message
jensdrenhaus Apr 10, 2025
ee241b0
build(deps): bump golang.org/x/net from 0.37.0 to 0.38.0
dependabot[bot] Apr 16, 2025
b5e3690
pkg/watchdogd: remove cleanup loop
binjip978 Apr 13, 2025
98badbe
pkg/boot/bls: remove redundant brake
binjip978 Apr 17, 2025
665a02a
golangci: add gosimple (part of staticcheck) linter
binjip978 Apr 17, 2025
4606a94
cmds/core/echo: use ReplaceAll
binjip978 Apr 19, 2025
41e46d4
pkg/smbios: Provide a new method to get SMBIOS3 header size
AjanZhong Apr 3, 2025
443bcfe
pkg/boot/universalpayload: Provide SMBIO3 info in device tree
AjanZhong Apr 3, 2025
90ae175
pkg/boot/universalpayload: Separate Load method to Load and Exec
AjanZhong Apr 10, 2025
3331571
pkg/boot/universalpayload: Suppress warning message printing
AjanZhong Apr 10, 2025
85effb4
pkg/boot/universalpayload: Add test case to cover SMBIOS3 node
AjanZhong Apr 15, 2025
510c604
golangci: migrate to v2
binjip978 Apr 21, 2025
ac885c3
cmds/core/ip: add missing newline to print
quite Apr 22, 2025
f0e05c3
.circleci/images: enable the tc-u32 filter type in kernel configs
lersek Apr 22, 2025
783d474
.vmtest.yaml: advance to kernels with the tc-u32 filter type enabled
lersek Apr 25, 2025
3538648
pkg/tc: fix qdisc parent parsing
lersek Apr 16, 2025
6c598ca
pkg/tc: simplify ShowQdisc
lersek Apr 24, 2025
c5e2ab2
pkg/tc: print qdisc handle and parent in ShowQdisc
lersek Apr 24, 2025
54874cd
pkg/tc: print r2q, default, and direct_qlen for HTB qdisc
lersek Apr 24, 2025
769d565
pkg/tc: fix getTickInUsec and CalcXMitTime, for parsing HTB class args
lersek Apr 24, 2025
6629be8
pkg/tc: remove debug output from ParseHTBClassArgs
lersek Apr 24, 2025
dd14b99
pkg/tc: print class handle and parent in ShowClass
lersek Apr 24, 2025
3c4d7c2
pkg/tc: print prio, rate, ceil, burst, and cburst for HTB class
lersek Apr 24, 2025
530ebee
pkg/tc: slightly extend filter priority parsing
lersek Apr 16, 2025
1a3c738
pkg/tc: fix priority and EtherType management for filters
lersek Apr 22, 2025
58c921f
pkg/tc: remove debug output from AddFilter
lersek Apr 24, 2025
ab89420
pkg/tc: tweak ShowFilter output
lersek Apr 24, 2025
de2f62b
pkg/tc: add minimal tc-u32 filter parser and formatter
lersek Apr 17, 2025
73ac2c0
integration/generic-tests: add "tc" integration test
lersek Apr 16, 2025
881d56d
pkg/tftp: fix TransferMode
jensdrenhaus Apr 24, 2025
78890dc
pkg/tftp: fix upload multiple files
jensdrenhaus Apr 28, 2025
35c2a2f
cmds/exp/tftp: fix parsing port number
jensdrenhaus Apr 28, 2025
382310d
cmds/exp/tftp: clean up help text
jensdrenhaus Apr 28, 2025
b4be65d
cmds/exp/tftpd: Add a simple TFTP server
jensdrenhaus Apr 24, 2025
6408c2d
integration/generic-tests: Add tftp test
jensdrenhaus Apr 24, 2025
ba931e6
cmds/exp/tftp: remove markdown docu
jensdrenhaus Apr 29, 2025
ec860cf
cmds/core/echo: remove non-existant \e backslash escape
quite May 2, 2025
6714235
pkg/boot/universalpayload: Add PCI Root Bridge Device Tree nodes
AjanZhong Apr 17, 2025
13f07fe
pkg/boot/universalpayload: Add test case for PCI Root Bridge info
AjanZhong Apr 19, 2025
18bc2d9
cmds/core/pidof: add pidof command
binjip978 Apr 26, 2025
07416f5
cmds/core/pidof: add platform dependent collect
binjip978 Apr 27, 2025
c3921fc
cmds/exp/tc: adapt help messages
jensdrenhaus Apr 30, 2025
89d8dab
ci: increase VM test timeout to 20 min
jensdrenhaus May 7, 2025
204dcbb
cmds/core/ip: remove unused code
jensdrenhaus Apr 9, 2025
35f4166
cmds/core/ip: remove more unused code
jensdrenhaus Apr 9, 2025
c3f7afd
cmds/core/ip: refactor add|append|replace|delete
jensdrenhaus Apr 10, 2025
d500c1b
cmds/core/ip: restructure code for ip route
jensdrenhaus Apr 11, 2025
a38d984
cmds/core/ip: write new 'ip route' parser
jensdrenhaus Apr 14, 2025
1e56209
integration/generic-test: rename helper function in brctl test
jensdrenhaus Apr 9, 2025
b6b92bc
integration/generic-tests: add ip test
jensdrenhaus Apr 9, 2025
3bdb469
ci: add kernel config options for ip tunneling
leongross May 15, 2025
a5aed3a
pkg/cpio: fix Debug output
binjip978 May 18, 2025
115330b
ci: missing virtual tunneling kernel config
leongross May 20, 2025
aefe477
cmds/core/ip: remove unused flag in tunnel subcommand help text
RiSKeD May 13, 2025
486f973
cmds/core/ip: add key option for tunnel subcommand
RiSKeD May 13, 2025
8d8fc53
cmds/core/ip: fix tunnel mode prints
RiSKeD May 13, 2025
6d43859
cmds/core/ip: fix validation boolean default on tunnel deletion
RiSKeD May 13, 2025
12a2350
cmds/core/ip: enhance ip tunnel show output
RiSKeD May 13, 2025
0cd1306
cmds/core/ip: support for 'dev' in tunnel show cmd
RiSKeD May 14, 2025
0485dc4
integration/generic-tests: add ip tunnel {add | del | show } cmds
RiSKeD May 14, 2025
348ae7c
integration/generic-tests: pin kernel images with tunneling support
RiSKeD May 16, 2025
ddc74d6
integration/generic-tests: add ipip, vti, gre tunnel modes
RiSKeD May 15, 2025
ca8a3e1
cmds/core/ip: fix ip neigh add cmd by correct NUD default
RiSKeD May 12, 2025
40609fe
integration/generic-tests: add ip neigh cmds to ip test
RiSKeD May 12, 2025
ecce2f8
cmds/core/ip: improve ip neigh show prints
RiSKeD May 12, 2025
58e6d56
cmds/core/ip: fix NUD state parsing in neigh subcommand
RiSKeD May 12, 2025
d4ac5d7
cmds/core/ip: add parsing function for both addr and CIDR
RiSKeD May 13, 2025
dd29375
cmds/core/ip: neigh show is filterable by IP or CIDR
RiSKeD May 13, 2025
3beeb45
cmds/core/ip: fix & extend ip neigh flush capabilities
RiSKeD May 13, 2025
d0550a2
integration/generic-tests: add ip neigh show cmd to ip test
RiSKeD May 13, 2025
0386538
cmds/core/ip: neigh subcommand accepts delete as del
RiSKeD May 13, 2025
2da3934
integration/generic-tests: add ip neigh replace cmd to ip test
RiSKeD May 13, 2025
ed52566
cmds/core/ip: add additional testcase for parseAddressOrCIDR
RiSKeD May 15, 2025
b723bfe
integration/generic-tests: remove additional prints from ip test
RiSKeD May 15, 2025
0563620
cmds/core/ip: add additional testcases for neigh funcs
RiSKeD May 22, 2025
a34e77a
integration/generic-tests: test ip flush functionality
RiSKeD May 22, 2025
53fe1d4
cmd/exp: traceroute: add functionality for -p/-port
leongross May 21, 2025
eab425a
cmd/exp: traceroute: error on invalid protocol
leongross May 22, 2025
62b6118
test: pin image hash for ghcr.io/hugelgupf/vmtest/qemu
leongross May 25, 2025
9935e1b
Change the version in go.mod so go download works
rminnich May 25, 2025
ac8f2b2
cmds/core/lsfd: add a minimal lsfd command
binjip978 Apr 28, 2025
8d9547b
cmds/core/lsfd: add some smoke tests
binjip978 May 1, 2025
794e324
tools: update status quo with lsfd
binjip978 May 11, 2025
d24f600
integration/generic: add traceroute
leongross May 13, 2025
ac5216c
cmds/exp: traceroute: add udpv6 fallback option for local networks
leongross May 29, 2025
3f165c1
cmds/exp/traceroute: fix checksum to be non-zero
leongross May 30, 2025
66331f0
cmds/exp: traceroute: linter nits
leongross May 30, 2025
84d4df7
integration/generic: traceroute: improve sync
leongross May 30, 2025
9747061
Delete pkg/ip directory
jensdrenhaus May 30, 2025
54a842e
cmds/core/pidof: add single -s flag
binjip978 Jun 1, 2025
3f27db3
cmds/core/pidof: use correct args with flags
binjip978 Jun 5, 2025
70f1377
cmds/core/sshd: just use the default shell
Jun 5, 2025
b5ec1a2
cmds/core/sshd: implement sftp (scp)
Jun 9, 2025
146e482
cmds/core/pidof: add quite flag
binjip978 Jun 7, 2025
ddbe793
build(deps): bump brace-expansion in /docs
dependabot[bot] Jun 11, 2025
0029d75
build(deps): bump github.com/cloudflare/circl from 1.3.7 to 1.6.1
dependabot[bot] Jun 10, 2025
0dfc947
tools/tinygo: sshd no longer works
binjip978 Jun 13, 2025
499618c
cmds/core/base64: add encode/decode tests
binjip978 Jun 24, 2025
ecb3cb8
cmds/core/base64: fix bug with Encoder writer
binjip978 Jun 24, 2025
8926c7b
cmds/core/grep: fully remove can't open file test
binjip978 Jun 22, 2025
7af71d1
cmds/core/backoff: fix 30s default timeout
binjip978 Jun 24, 2025
ac6d77c
account for https://github.com/torvalds/linux/commit/9c54baab4401db24…
abarisani Jun 17, 2025
bd0856c
remove CRC32 test
abarisani Jun 17, 2025
39f572a
remove crc32 field from testImage struct
abarisani Jun 17, 2025
74aa3d1
make gofmt happy
abarisani Jun 18, 2025
0c1018d
cmds/core/cmp: replace goto with else
binjip978 Jun 28, 2025
096794b
cmds/core/date: fix +%j calculation
binjip978 Jun 30, 2025
2f029ef
update vendor to use latest uimage
rminnich Jul 1, 2025
956ffaa
Add termios support for Plan 9
rminnich Jun 25, 2025
5721ed3
remove blind deref of route.Dst in routeAdd
rminnich Jun 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .circleci/images/kernel-amd64/config_linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,24 @@ CONFIG_NET_SCH_CODEL=y
CONFIG_NET_SCH_FQ_CODEL=y
CONFIG_NET_CLS=y
CONFIG_NET_CLS_BASIC=y
CONFIG_NET_CLS_U32=y
CONFIG_NET_CLS_ACT=y
CONFIG_NET_ACT_GACT=y

# Network tunneling
CONFIG_INET6_ESP=y
CONFIG_INET6_ESPINTCP=y
CONFIG_INET6_ESP_OFFLOAD=y
CONFIG_INET6_IPCOMP=y
CONFIG_INET_IPCOMP=y
CONFIG_IPV6_SIT_6RD=y
CONFIG_IPV6_VTI=y
CONFIG_NET_FOU_IP_TUNNELS=y
CONFIG_NET_IPGRE=y
CONFIG_NET_IPGRE_DEMUX=y
CONFIG_NET_IPIP=y
CONFIG_NET_IPVTI=y

# 9P net filesystem
CONFIG_NET_9P=y
CONFIG_NET_9P_VIRTIO=y
Expand Down Expand Up @@ -167,4 +182,4 @@ CONFIG_GCOV_PROFILE_ALL=y
CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_CORE=y
CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED=y
CONFIG_WATCHDOG_OPEN_TIMEOUT=0
CONFIG_WATCHDOG_OPEN_TIMEOUT=0
14 changes: 14 additions & 0 deletions .circleci/images/kernel-arm/config_linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,23 @@ CONFIG_NET_SCH_CODEL=y
CONFIG_NET_SCH_FQ_CODEL=y
CONFIG_NET_CLS=y
CONFIG_NET_CLS_BASIC=y
CONFIG_NET_CLS_U32=y
CONFIG_NET_CLS_ACT=y
CONFIG_NET_ACT_GACT=y

# Network tunneling
CONFIG_INET6_ESP=y
CONFIG_INET6_IPCOMP=y
CONFIG_INET_IPCOMP=y
CONFIG_IPV6_GRE=y
CONFIG_IPV6_IOAM6_LWTUNNEL=y
CONFIG_IPV6_VTI=y
CONFIG_NET_FOU=y
CONFIG_NET_IPGRE=y
CONFIG_NET_IPGRE_DEMUX=y
CONFIG_NET_IPIP=y
CONFIG_NET_IPVTI=y

# GPIO test - mock GPIO libraries
CONFIG_GPIOLIB=y
CONFIG_GPIO_MOCKUP=y
Expand Down
15 changes: 14 additions & 1 deletion .circleci/images/kernel-arm64/config_linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,22 @@ CONFIG_NET_SCH_CODEL=y
CONFIG_NET_SCH_FQ_CODEL=y
CONFIG_NET_CLS=y
CONFIG_NET_CLS_BASIC=y
CONFIG_NET_CLS_U32=y
CONFIG_NET_CLS_ACT=y
CONFIG_NET_ACT_GACT=y

# Network tunneling
CONFIG_INET6_IPCOMP=y
CONFIG_INET_IPCOMP=y
CONFIG_IPV6_GRE=y
CONFIG_IPV6_IOAM6_LWTUNNEL=y
CONFIG_IPV6_VTI=y
CONFIG_NET_FOU_IP_TUNNELS=y
CONFIG_NET_IPGRE=y
CONFIG_NET_IPGRE_DEMUX=y
CONFIG_NET_IPIP=y
CONFIG_NET_IPVTI=y

# GPIO test - mock GPIO libraries
CONFIG_GPIOLIB=y
CONFIG_GPIO_MOCKUP=y
Expand Down Expand Up @@ -168,4 +181,4 @@ CONFIG_EFI_BOOTLOADER_CONTROL=y

# Watchdog
CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_CORE=y
CONFIG_WATCHDOG_CORE=y
8 changes: 4 additions & 4 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: '1.24'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
version: v1.64.5
args: --out-format=line-number --timeout=5m
version: v2.1.2
args: --timeout=5m
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
mkdir gocov
VMTEST_GOCOVERDIR=$(pwd)/gocov \
VMTEST_GO_PROFILE=vmcoverage.txt runvmtest -- \
go test -v -timeout=15m \
go test -v -timeout=20m \
-covermode=atomic ${{ matrix.extra-arg }} \
-coverprofile=coverage.txt ./${{ matrix.pattern }}

Expand Down
75 changes: 42 additions & 33 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
version: "2"
linters:
disable-all: true
default: none
enable:
- revive
- errorlint
- ineffassign
- revive
- staticcheck
- stylecheck
- errorlint

linters-settings:
staticcheck:
checks: ["all", "-SA1019"]
stylecheck:
checks: ["all", "-ST1003"]
errorlint:
errorf: true
asserts: false
comparison: false

issues:
exclude-dirs:
- pkg/uroot/test
exclude-rules:
- linters: [revive]
text: "don't use underscores"
- linters: [revive]
text: "don't use ALL_CAPS"
- linters: [revive]
text: "stutter"
- linters: [revive]
text: "unexported-return"
- linters: [revive]
text: "unused-parameter"
- linters: [revive]
text: "superfluous-else"
- linters: [revive]
text: "empty-block"
settings:
errorlint:
errorf: true
asserts: false
comparison: false
staticcheck:
checks:
- all
- -SA1019
- -ST1003
- -QF*
exclusions:
presets:
- comments
rules:
- linters:
- revive
text: don't use underscores
- linters:
- revive
text: don't use ALL_CAPS
- linters:
- revive
text: stutter
- linters:
- revive
text: unexported-return
- linters:
- revive
text: unused-parameter
- linters:
- revive
text: superfluous-else
- linters:
- revive
text: empty-block
paths:
- pkg/uroot/test
12 changes: 6 additions & 6 deletions .vmtest.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
amd64:
VMTEST_QEMU:
container: "ghcr.io/hugelgupf/vmtest/qemu:main"
container: "ghcr.io/hugelgupf/vmtest/qemu:main@sha256:d5b3d31f39edb6394d20bdd76027512f956d78af9c6e49ecf2ab9ab59944638a"
template: "{{.qemu}}/bin/qemu-system-x86_64 -L {{.qemu}}/pc-bios -m 1G"
directories:
qemu: "/zqemu"

VMTEST_KERNEL:
container: "ghcr.io/u-root/u-root/test-kernel-amd64@sha256:0b4f399fd61f2f5e060c86216150ec12439851101921337add61402c185e8007"
container: "ghcr.io/u-root/u-root/test-kernel-amd64@sha256:8b6e8c08724ef0aa2809685c7adb98e1b9b000f79fa790ec254c3176ecc5ec93"
template: "{{.bzImage}}"
files:
bzImage: "/bzImage"
Expand All @@ -25,26 +25,26 @@ amd64:

arm:
VMTEST_QEMU:
container: "ghcr.io/hugelgupf/vmtest/qemu:main"
container: "ghcr.io/hugelgupf/vmtest/qemu:main@sha256:d5b3d31f39edb6394d20bdd76027512f956d78af9c6e49ecf2ab9ab59944638a"
template: "{{.qemu}}/bin/qemu-system-arm -M virt,highmem=off -L {{.qemu}}/pc-bios"
directories:
qemu: "/zqemu"

VMTEST_KERNEL:
container: "ghcr.io/u-root/u-root/test-kernel-arm@sha256:0429fa0ab8dbc4d1913f1c2b8ccc45fa8000897c801ed90b90c14a15e1f32020"
container: "ghcr.io/u-root/u-root/test-kernel-arm@sha256:a3df0094d89dda04a3eb08d3c8df538b3d2cb3019962cbd8f8886ac624cc8838"
template: "{{.zImage}}"
files:
zImage: "/zImage"

arm64:
VMTEST_QEMU:
container: "ghcr.io/hugelgupf/vmtest/qemu:main"
container: "ghcr.io/hugelgupf/vmtest/qemu:main@sha256:d5b3d31f39edb6394d20bdd76027512f956d78af9c6e49ecf2ab9ab59944638a"
template: "{{.qemu}}/bin/qemu-system-aarch64 -machine virt -cpu max -m 1G -L {{.qemu}}/pc-bios"
directories:
qemu: "/zqemu"

VMTEST_KERNEL:
container: "ghcr.io/u-root/u-root/test-kernel-arm64@sha256:e48f32266071edaec44445da98375fe512b1532640e256f9f7138633e0000866"
container: "ghcr.io/u-root/u-root/test-kernel-arm64@sha256:d0b65ec5584fef929828324b0f998ad7e853c95bcc2288a163ebdf64401fe5a0"
template: "{{.Image}}"
files:
Image: "/Image"
38 changes: 31 additions & 7 deletions cmds/core/backoff/main.go → cmds/core/backoff/backoff.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012-2021 the u-root Authors. All rights reserved
// Copyright 2012-2025 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

Expand All @@ -11,13 +11,13 @@
// backoff will run the command until it succeeds or a timeout has passed.
// The default timeout is 30s.
// If -v is set, it will show what it is running, each time it is tried.
// If no args are given, it will just return.
// If no args are given, it will print command help.
//
// Example:
// $ backoff echo hi
// hi
// $
// $ backoff -v -t 2s false
// $ backoff -v -t=2s false
// 2022/03/31 14:29:37 Run ["false"]
// 2022/03/31 14:29:37 Set timeout to 2s
// 2022/03/31 14:29:37 "false" []:exit status 1
Expand All @@ -31,16 +31,40 @@ package main

import (
"flag"
"fmt"
"log"
"os"
"os/exec"
"time"

"github.com/cenkalti/backoff/v4"
)

var (
timeout = flag.String("t", "", "Timeout for command")
verbose = flag.Bool("v", true, "Log each attempt to run the command")
v = func(string, ...interface{}) {}
timeout = flag.Duration("t", 30*time.Second, "Timeout for command")
verbose = flag.Bool("v", false, "Log each attempt to run the command")
v = func(string, ...any) {}

errNoCmd = fmt.Errorf("no command passed")
)

func run(timeout time.Duration, c string, a ...string) error {
if c == "" {
return errNoCmd
}
b := backoff.NewExponentialBackOff()
b.MaxElapsedTime = timeout
f := func() error {
cmd := exec.Command(c, a...)
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
err := cmd.Run()
v("%q %q:%v", c, a, err)
return err
}

return backoff.Retry(f, b)
}

func main() {
flag.Parse()
if *verbose {
Expand All @@ -52,7 +76,7 @@ func main() {
os.Exit(1)
}
v("Run %q", a)
if err := runit(*timeout, a[0], a[1:]...); err != nil {
if err := run(*timeout, a[0], a[1:]...); err != nil {
log.Fatalf("Error: %v", err)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 the u-root Authors. All rights reserved
// Copyright 2021-2025 the u-root Authors. All rights reserved
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

Expand All @@ -7,49 +7,42 @@ package main
import (
"bytes"
"errors"
"fmt"
"regexp"
"strings"
"testing"
"time"

"github.com/u-root/u-root/pkg/testutil"
)

func TestRunIt(t *testing.T) {
for _, tt := range []struct {
name string
timeout string
timeout time.Duration
cmd string
args []string
wantErr error
}{
{
name: "_date",
timeout: "3s",
timeout: 3 * time.Second,
cmd: "date",
},
{
name: "noCmd",
timeout: "3s",
timeout: 3 * time.Second,
cmd: "",
wantErr: ErrNoCmd,
wantErr: errNoCmd,
},
{
name: "echo",
timeout: "3s",
timeout: 3 * time.Second,
cmd: "echo",
args: []string{"hi"},
},
{
name: "echo_missing_unit",
timeout: "3",
cmd: "echo",
args: []string{"hi"},
wantErr: fmt.Errorf("time: missing unit in duration \"3\""),
},
} {
t.Run(tt.name, func(t *testing.T) {
if err := runit(tt.timeout, tt.cmd, tt.args...); !errors.Is(err, tt.wantErr) {
if err := run(tt.timeout, tt.cmd, tt.args...); !errors.Is(err, tt.wantErr) {
if err != nil {
if !strings.Contains(err.Error(), tt.wantErr.Error()) {
t.Errorf("runit(%s, %s, %s)= %q, want %q", tt.timeout, tt.cmd, tt.args, err, tt.wantErr)
Expand All @@ -70,9 +63,8 @@ func TestOK(t *testing.T) {
}{
{args: []string{}, stdout: "", exitok: false},
{args: []string{"date"}, stdout: ".*", exitok: true},
{args: []string{"-t", "wh", "date"}, stdout: ".*", stderr: ".*invalid.*duration.*wh", exitok: false},
{args: []string{"echo", "hi"}, stdout: ".*hi", exitok: true},
{args: []string{"-t", "3s", "false"}, exitok: false},
{args: []string{"-t", "1s", "false"}, exitok: false},
}

for _, v := range tests {
Expand Down
Loading