|
@@ -3078,20 +3078,32 @@ func TestRunWriteToProcAsound(t *testing.T) {
|
|
logDone("run - ro write to /proc/asound")
|
|
logDone("run - ro write to /proc/asound")
|
|
}
|
|
}
|
|
|
|
|
|
-func TestRunWriteToProcTimer(t *testing.T) {
|
|
|
|
|
|
+func TestRunReadProcTimer(t *testing.T) {
|
|
defer deleteAllContainers()
|
|
defer deleteAllContainers()
|
|
- code, err := runCommand(exec.Command(dockerBinary, "run", "busybox", "sh", "-c", "echo 1 >> /proc/timer_stats"))
|
|
|
|
- if err == nil || code == 0 {
|
|
|
|
- t.Fatal("standard container should not be able to write to /proc/timer_stats")
|
|
|
|
|
|
+ out, code, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "busybox", "cat", "/proc/timer_stats"))
|
|
|
|
+ if err != nil || code != 0 {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+ if strings.Trim(out, "\n ") != "" {
|
|
|
|
+ t.Fatalf("expected to receive no output from /proc/timer_stats but received %q", out)
|
|
}
|
|
}
|
|
- logDone("run - ro write to /proc/timer_stats")
|
|
|
|
|
|
+ logDone("run - read /proc/timer_stats")
|
|
}
|
|
}
|
|
|
|
|
|
-func TestRunWriteToProcLatency(t *testing.T) {
|
|
|
|
|
|
+func TestRunReadProcLatency(t *testing.T) {
|
|
|
|
+ // some kernels don't have this configured so skip the test if this file is not found
|
|
|
|
+ // on the host running the tests.
|
|
|
|
+ if _, err := os.Stat("/proc/latency_stats"); err != nil {
|
|
|
|
+ t.Skip()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
defer deleteAllContainers()
|
|
defer deleteAllContainers()
|
|
- code, err := runCommand(exec.Command(dockerBinary, "run", "busybox", "sh", "-c", "echo 1 >> /proc/latency_stats"))
|
|
|
|
- if err == nil || code == 0 {
|
|
|
|
- t.Fatal("standard container should not be able to write to /proc/latency_stats")
|
|
|
|
|
|
+ out, code, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "busybox", "cat", "/proc/latency_stats"))
|
|
|
|
+ if err != nil || code != 0 {
|
|
|
|
+ t.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+ if strings.Trim(out, "\n ") != "" {
|
|
|
|
+ t.Fatalf("expected to receive no output from /proc/latency_stats but received %q", out)
|
|
}
|
|
}
|
|
- logDone("run - ro write to /proc/latency_stats")
|
|
|
|
|
|
+ logDone("run - read /proc/latency_stats")
|
|
}
|
|
}
|