libcontainer: unconvert

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2020-09-29 12:14:02 +02:00
parent b3a8b0742c
commit 28b452bf65
4 changed files with 18 additions and 17 deletions

View File

@@ -33,8 +33,8 @@ func TestParseCgroupFromReader(t *testing.T) {
for s, expected := range cases {
g, err := parseCgroupFromReader(strings.NewReader(s))
if expected != "" {
if string(g) != expected {
t.Errorf("expected %q, got %q", expected, string(g))
if g != expected {
t.Errorf("expected %q, got %q", expected, g)
}
if err != nil {
t.Error(err)

View File

@@ -1629,7 +1629,7 @@ func TestRootfsPropagationSharedMount(t *testing.T) {
t.Logf("findmnt error %q: %q", err, outtrim)
}
if string(outtrim) != dir2host {
if outtrim != dir2host {
t.Fatalf("Mount in container on %s did not propagate to host on %s. finmnt output=%s", dir2cont, dir2host, outtrim)
}
}

View File

@@ -4,6 +4,7 @@ package intelrdt
import (
"bufio"
"bytes"
"fmt"
"io"
"io/ioutil"
@@ -375,7 +376,7 @@ func getIntelRdtParamUint(path, file string) (uint64, error) {
return 0, err
}
res, err := parseUint(strings.TrimSpace(string(contents)), 10, 64)
res, err := parseUint(string(bytes.TrimSpace(contents)), 10, 64)
if err != nil {
return res, fmt.Errorf("unable to parse %q as a uint from file %q", string(contents), fileName)
}
@@ -389,7 +390,7 @@ func getIntelRdtParamString(path, file string) (string, error) {
return "", err
}
return strings.TrimSpace(string(contents)), nil
return string(bytes.TrimSpace(contents)), nil
}
func writeFile(dir, file, data string) error {

View File

@@ -19,8 +19,8 @@ func TestLoggingToFile(t *testing.T) {
logToLogWriter(t, logW, `{"level": "info","msg":"kitten"}`)
logFileContent := waitForLogContent(t, logFile)
if !strings.Contains(string(logFileContent), "kitten") {
t.Fatalf("%s does not contain kitten", string(logFileContent))
if !strings.Contains(logFileContent, "kitten") {
t.Fatalf("%s does not contain kitten", logFileContent)
}
}
@@ -32,8 +32,8 @@ func TestLogForwardingDoesNotStopOnJsonDecodeErr(t *testing.T) {
logToLogWriter(t, logW, "invalid-json-with-kitten")
logFileContent := waitForLogContent(t, logFile)
if !strings.Contains(string(logFileContent), "failed to decode") {
t.Fatalf("%q does not contain decoding error", string(logFileContent))
if !strings.Contains(logFileContent, "failed to decode") {
t.Fatalf("%q does not contain decoding error", logFileContent)
}
truncateLogFile(t, logFile)
@@ -41,8 +41,8 @@ func TestLogForwardingDoesNotStopOnJsonDecodeErr(t *testing.T) {
logToLogWriter(t, logW, `{"level": "info","msg":"puppy"}`)
logFileContent = waitForLogContent(t, logFile)
if !strings.Contains(string(logFileContent), "puppy") {
t.Fatalf("%s does not contain puppy", string(logFileContent))
if !strings.Contains(logFileContent, "puppy") {
t.Fatalf("%s does not contain puppy", logFileContent)
}
}
@@ -54,8 +54,8 @@ func TestLogForwardingDoesNotStopOnLogLevelParsingErr(t *testing.T) {
logToLogWriter(t, logW, `{"level": "alert","msg":"puppy"}`)
logFileContent := waitForLogContent(t, logFile)
if !strings.Contains(string(logFileContent), "failed to parse log level") {
t.Fatalf("%q does not contain log level parsing error", string(logFileContent))
if !strings.Contains(logFileContent, "failed to parse log level") {
t.Fatalf("%q does not contain log level parsing error", logFileContent)
}
truncateLogFile(t, logFile)
@@ -63,8 +63,8 @@ func TestLogForwardingDoesNotStopOnLogLevelParsingErr(t *testing.T) {
logToLogWriter(t, logW, `{"level": "info","msg":"puppy"}`)
logFileContent = waitForLogContent(t, logFile)
if !strings.Contains(string(logFileContent), "puppy") {
t.Fatalf("%s does not contain puppy", string(logFileContent))
if !strings.Contains(logFileContent, "puppy") {
t.Fatalf("%s does not contain puppy", logFileContent)
}
}
@@ -75,8 +75,8 @@ func TestLogForwardingStopsAfterClosingTheWriter(t *testing.T) {
logToLogWriter(t, logW, `{"level": "info","msg":"sync"}`)
logFileContent := waitForLogContent(t, logFile)
if !strings.Contains(string(logFileContent), "sync") {
t.Fatalf("%q does not contain sync message", string(logFileContent))
if !strings.Contains(logFileContent, "sync") {
t.Fatalf("%q does not contain sync message", logFileContent)
}
logW.Close()