@@ -316,6 +316,13 @@ func TestRunWithJsonFileLogDriverAndLogPathOpt(t *testing.T) {
316
316
}
317
317
318
318
func 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
+
319
326
if runtime .GOOS == "windows" {
320
327
t .Skip ("journald log driver is not yet implemented on Windows" )
321
328
}
@@ -327,8 +334,6 @@ func TestRunWithJournaldLogDriver(t *testing.T) {
327
334
"sh" , "-euxc" , "echo foo; echo bar" ).AssertOK ()
328
335
329
336
time .Sleep (3 * time .Second )
330
- journalctl , err := exec .LookPath ("journalctl" )
331
- assert .NilError (t , err )
332
337
333
338
inspectedContainer := base .InspectContainer (containerName )
334
339
@@ -370,6 +375,13 @@ func TestRunWithJournaldLogDriver(t *testing.T) {
370
375
}
371
376
372
377
func 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
+
373
385
if runtime .GOOS == "windows" {
374
386
t .Skip ("journald log driver is not yet implemented on Windows" )
375
387
}
@@ -381,8 +393,6 @@ func TestRunWithJournaldLogDriverAndLogOpt(t *testing.T) {
381
393
"sh" , "-euxc" , "echo foo; echo bar" ).AssertOK ()
382
394
383
395
time .Sleep (3 * time .Second )
384
- journalctl , err := exec .LookPath ("journalctl" )
385
- assert .NilError (t , err )
386
396
inspectedContainer := base .InspectContainer (containerName )
387
397
found := 0
388
398
check := func (log poll.LogT ) poll.Result {
0 commit comments