@@ -3458,20 +3458,32 @@ func TestRunWriteToProcAsound(t *testing.T) {
3458
3458
logDone ("run - ro write to /proc/asound" )
3459
3459
}
3460
3460
3461
- func TestRunWriteToProcTimer (t * testing.T ) {
3461
+ func TestRunReadProcTimer (t * testing.T ) {
3462
3462
defer deleteAllContainers ()
3463
- code , err := runCommand (exec .Command (dockerBinary , "run" , "busybox" , "sh " , "-c" , "echo 1 >> /proc/timer_stats" ))
3464
- if err == nil || code = = 0 {
3465
- t .Fatal ("standard container should not be able to write to /proc/timer_stats" )
3463
+ out , code , err := runCommandWithOutput (exec .Command (dockerBinary , "run" , "busybox" , "cat " , "/proc/timer_stats" ))
3464
+ if err != nil || code ! = 0 {
3465
+ t .Fatal (err )
3466
3466
}
3467
- logDone ("run - ro write to /proc/timer_stats" )
3467
+ if strings .Trim (out , "\n " ) != "" {
3468
+ t .Fatalf ("expected to receive no output from /proc/timer_stats but received %q" , out )
3469
+ }
3470
+ logDone ("run - read /proc/timer_stats" )
3468
3471
}
3469
3472
3470
- func TestRunWriteToProcLatency (t * testing.T ) {
3473
+ func TestRunReadProcLatency (t * testing.T ) {
3474
+ // some kernels don't have this configured so skip the test if this file is not found
3475
+ // on the host running the tests.
3476
+ if _ , err := os .Stat ("/proc/latency_stats" ); err != nil {
3477
+ t .Skip ()
3478
+ return
3479
+ }
3471
3480
defer deleteAllContainers ()
3472
- code , err := runCommand (exec .Command (dockerBinary , "run" , "busybox" , "sh" , "-c" , "echo 1 >> /proc/latency_stats" ))
3473
- if err == nil || code == 0 {
3474
- t .Fatal ("standard container should not be able to write to /proc/latency_stats" )
3481
+ out , code , err := runCommandWithOutput (exec .Command (dockerBinary , "run" , "busybox" , "cat" , "/proc/latency_stats" ))
3482
+ if err != nil || code != 0 {
3483
+ t .Fatal (err )
3484
+ }
3485
+ if strings .Trim (out , "\n " ) != "" {
3486
+ t .Fatalf ("expected to receive no output from /proc/latency_stats but received %q" , out )
3475
3487
}
3476
- logDone ("run - ro write to /proc/latency_stats" )
3488
+ logDone ("run - read /proc/latency_stats" )
3477
3489
}
0 commit comments