mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-19 22:04:44 +08:00
libcontainer: unconvert
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -33,8 +33,8 @@ func TestParseCgroupFromReader(t *testing.T) {
|
|||||||
for s, expected := range cases {
|
for s, expected := range cases {
|
||||||
g, err := parseCgroupFromReader(strings.NewReader(s))
|
g, err := parseCgroupFromReader(strings.NewReader(s))
|
||||||
if expected != "" {
|
if expected != "" {
|
||||||
if string(g) != expected {
|
if g != expected {
|
||||||
t.Errorf("expected %q, got %q", expected, string(g))
|
t.Errorf("expected %q, got %q", expected, g)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
@@ -1629,7 +1629,7 @@ func TestRootfsPropagationSharedMount(t *testing.T) {
|
|||||||
t.Logf("findmnt error %q: %q", err, outtrim)
|
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)
|
t.Fatalf("Mount in container on %s did not propagate to host on %s. finmnt output=%s", dir2cont, dir2host, outtrim)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ package intelrdt
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -375,7 +376,7 @@ func getIntelRdtParamUint(path, file string) (uint64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := parseUint(strings.TrimSpace(string(contents)), 10, 64)
|
res, err := parseUint(string(bytes.TrimSpace(contents)), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, fmt.Errorf("unable to parse %q as a uint from file %q", string(contents), fileName)
|
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 "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.TrimSpace(string(contents)), nil
|
return string(bytes.TrimSpace(contents)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeFile(dir, file, data string) error {
|
func writeFile(dir, file, data string) error {
|
||||||
|
@@ -19,8 +19,8 @@ func TestLoggingToFile(t *testing.T) {
|
|||||||
logToLogWriter(t, logW, `{"level": "info","msg":"kitten"}`)
|
logToLogWriter(t, logW, `{"level": "info","msg":"kitten"}`)
|
||||||
|
|
||||||
logFileContent := waitForLogContent(t, logFile)
|
logFileContent := waitForLogContent(t, logFile)
|
||||||
if !strings.Contains(string(logFileContent), "kitten") {
|
if !strings.Contains(logFileContent, "kitten") {
|
||||||
t.Fatalf("%s does not contain kitten", string(logFileContent))
|
t.Fatalf("%s does not contain kitten", logFileContent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ func TestLogForwardingDoesNotStopOnJsonDecodeErr(t *testing.T) {
|
|||||||
logToLogWriter(t, logW, "invalid-json-with-kitten")
|
logToLogWriter(t, logW, "invalid-json-with-kitten")
|
||||||
|
|
||||||
logFileContent := waitForLogContent(t, logFile)
|
logFileContent := waitForLogContent(t, logFile)
|
||||||
if !strings.Contains(string(logFileContent), "failed to decode") {
|
if !strings.Contains(logFileContent, "failed to decode") {
|
||||||
t.Fatalf("%q does not contain decoding error", string(logFileContent))
|
t.Fatalf("%q does not contain decoding error", logFileContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
truncateLogFile(t, logFile)
|
truncateLogFile(t, logFile)
|
||||||
@@ -41,8 +41,8 @@ func TestLogForwardingDoesNotStopOnJsonDecodeErr(t *testing.T) {
|
|||||||
logToLogWriter(t, logW, `{"level": "info","msg":"puppy"}`)
|
logToLogWriter(t, logW, `{"level": "info","msg":"puppy"}`)
|
||||||
|
|
||||||
logFileContent = waitForLogContent(t, logFile)
|
logFileContent = waitForLogContent(t, logFile)
|
||||||
if !strings.Contains(string(logFileContent), "puppy") {
|
if !strings.Contains(logFileContent, "puppy") {
|
||||||
t.Fatalf("%s does not contain puppy", string(logFileContent))
|
t.Fatalf("%s does not contain puppy", logFileContent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,8 +54,8 @@ func TestLogForwardingDoesNotStopOnLogLevelParsingErr(t *testing.T) {
|
|||||||
logToLogWriter(t, logW, `{"level": "alert","msg":"puppy"}`)
|
logToLogWriter(t, logW, `{"level": "alert","msg":"puppy"}`)
|
||||||
|
|
||||||
logFileContent := waitForLogContent(t, logFile)
|
logFileContent := waitForLogContent(t, logFile)
|
||||||
if !strings.Contains(string(logFileContent), "failed to parse log level") {
|
if !strings.Contains(logFileContent, "failed to parse log level") {
|
||||||
t.Fatalf("%q does not contain log level parsing error", string(logFileContent))
|
t.Fatalf("%q does not contain log level parsing error", logFileContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
truncateLogFile(t, logFile)
|
truncateLogFile(t, logFile)
|
||||||
@@ -63,8 +63,8 @@ func TestLogForwardingDoesNotStopOnLogLevelParsingErr(t *testing.T) {
|
|||||||
logToLogWriter(t, logW, `{"level": "info","msg":"puppy"}`)
|
logToLogWriter(t, logW, `{"level": "info","msg":"puppy"}`)
|
||||||
|
|
||||||
logFileContent = waitForLogContent(t, logFile)
|
logFileContent = waitForLogContent(t, logFile)
|
||||||
if !strings.Contains(string(logFileContent), "puppy") {
|
if !strings.Contains(logFileContent, "puppy") {
|
||||||
t.Fatalf("%s does not contain puppy", string(logFileContent))
|
t.Fatalf("%s does not contain puppy", logFileContent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,8 +75,8 @@ func TestLogForwardingStopsAfterClosingTheWriter(t *testing.T) {
|
|||||||
logToLogWriter(t, logW, `{"level": "info","msg":"sync"}`)
|
logToLogWriter(t, logW, `{"level": "info","msg":"sync"}`)
|
||||||
|
|
||||||
logFileContent := waitForLogContent(t, logFile)
|
logFileContent := waitForLogContent(t, logFile)
|
||||||
if !strings.Contains(string(logFileContent), "sync") {
|
if !strings.Contains(logFileContent, "sync") {
|
||||||
t.Fatalf("%q does not contain sync message", string(logFileContent))
|
t.Fatalf("%q does not contain sync message", logFileContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
logW.Close()
|
logW.Close()
|
||||||
|
Reference in New Issue
Block a user