@@ -316,6 +316,13 @@ func TestRunWithJsonFileLogDriverAndLogPathOpt(t *testing.T) {
316316}
317317
318318func TestRunWithJournaldLogDriver (t * testing.T ) {
319+ testutil .RequireExecutable (t , "journalctl" )
320+ journalctl , _ := exec .LookPath ("journalctl" )
321+ res := icmd .RunCmd (icmd .Command (journalctl , "-xe" ))
322+ if res .ExitCode != 0 {
323+ t .Skipf ("current user is not allowed to access journal logs: %s" , res .Combined ())
324+ }
325+
319326 if runtime .GOOS == "windows" {
320327 t .Skip ("journald log driver is not yet implemented on Windows" )
321328 }
@@ -327,8 +334,6 @@ func TestRunWithJournaldLogDriver(t *testing.T) {
327334 "sh" , "-euxc" , "echo foo; echo bar" ).AssertOK ()
328335
329336 time .Sleep (3 * time .Second )
330- journalctl , err := exec .LookPath ("journalctl" )
331- assert .NilError (t , err )
332337
333338 inspectedContainer := base .InspectContainer (containerName )
334339
@@ -370,6 +375,13 @@ func TestRunWithJournaldLogDriver(t *testing.T) {
370375}
371376
372377func TestRunWithJournaldLogDriverAndLogOpt (t * testing.T ) {
378+ testutil .RequireExecutable (t , "journalctl" )
379+ journalctl , _ := exec .LookPath ("journalctl" )
380+ res := icmd .RunCmd (icmd .Command (journalctl , "-xe" ))
381+ if res .ExitCode != 0 {
382+ t .Skipf ("current user is not allowed to access journal logs: %s" , res .Combined ())
383+ }
384+
373385 if runtime .GOOS == "windows" {
374386 t .Skip ("journald log driver is not yet implemented on Windows" )
375387 }
@@ -381,8 +393,6 @@ func TestRunWithJournaldLogDriverAndLogOpt(t *testing.T) {
381393 "sh" , "-euxc" , "echo foo; echo bar" ).AssertOK ()
382394
383395 time .Sleep (3 * time .Second )
384- journalctl , err := exec .LookPath ("journalctl" )
385- assert .NilError (t , err )
386396 inspectedContainer := base .InspectContainer (containerName )
387397 found := 0
388398 check := func (log poll.LogT ) poll.Result {
0 commit comments