mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-28 04:46:44 -04:00
all: remove ioutil usage from tests
This removes the remaining (and trivial) use of deprecated ioutil package from test files. Replacements are easy: ioutil.ReadAll -> io.ReadAll ioutil.ReadDir -> os.ReadDir ioutil.ReadFile -> os.ReadFile ioutil.WriteFile -> os.WriteFile While at it, simplify some error reporting. Change-Id: I60a242fd3c08d8fe571a18f16716439a9acdd59d Reviewed-on: https://go-review.googlesource.com/c/sys/+/526299 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
committed by
Gopher Robot
parent
fc717d344a
commit
fdc7ef4071
@@ -10,7 +10,6 @@ import (
|
||||
"debug/pe"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -667,14 +666,14 @@ func TestWinVerifyTrust(t *testing.T) {
|
||||
// Now that we've verified the legitimate file verifies, let's corrupt it and see if it correctly fails.
|
||||
|
||||
corruptedEvsignedfile := filepath.Join(t.TempDir(), "corrupted-file")
|
||||
evsignedfileBytes, err := ioutil.ReadFile(evsignedfile)
|
||||
evsignedfileBytes, err := os.ReadFile(evsignedfile)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to read %s bytes: %v", evsignedfile, err)
|
||||
}
|
||||
if len(evsignedfileBytes) > 0 {
|
||||
evsignedfileBytes[len(evsignedfileBytes)/2-1]++
|
||||
}
|
||||
err = ioutil.WriteFile(corruptedEvsignedfile, evsignedfileBytes, 0755)
|
||||
err = os.WriteFile(corruptedEvsignedfile, evsignedfileBytes, 0755)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to write corrupted ntoskrnl.exe bytes: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user