@@ -206,17 +206,14 @@ func TestEnter(t *testing.T) {
206
206
if testing .Short () {
207
207
return
208
208
}
209
- root , err := newTestRoot ()
210
- ok (t , err )
211
- defer os .RemoveAll (root )
212
209
213
210
rootfs , err := newRootfs ()
214
211
ok (t , err )
215
212
defer remove (rootfs )
216
213
217
214
config := newTemplateConfig (rootfs )
218
215
219
- container , err := factory . Create ("test" , config )
216
+ container , err := newContainerWithName ("test" , config )
220
217
ok (t , err )
221
218
defer container .Destroy ()
222
219
@@ -296,17 +293,14 @@ func TestProcessEnv(t *testing.T) {
296
293
if testing .Short () {
297
294
return
298
295
}
299
- root , err := newTestRoot ()
300
- ok (t , err )
301
- defer os .RemoveAll (root )
302
296
303
297
rootfs , err := newRootfs ()
304
298
ok (t , err )
305
299
defer remove (rootfs )
306
300
307
301
config := newTemplateConfig (rootfs )
308
302
309
- container , err := factory . Create ("test" , config )
303
+ container , err := newContainerWithName ("test" , config )
310
304
ok (t , err )
311
305
defer container .Destroy ()
312
306
@@ -347,9 +341,6 @@ func TestProcessEmptyCaps(t *testing.T) {
347
341
if testing .Short () {
348
342
return
349
343
}
350
- root , err := newTestRoot ()
351
- ok (t , err )
352
- defer os .RemoveAll (root )
353
344
354
345
rootfs , err := newRootfs ()
355
346
ok (t , err )
@@ -358,7 +349,7 @@ func TestProcessEmptyCaps(t *testing.T) {
358
349
config := newTemplateConfig (rootfs )
359
350
config .Capabilities = nil
360
351
361
- container , err := factory . Create ("test" , config )
352
+ container , err := newContainerWithName ("test" , config )
362
353
ok (t , err )
363
354
defer container .Destroy ()
364
355
@@ -399,17 +390,14 @@ func TestProcessCaps(t *testing.T) {
399
390
if testing .Short () {
400
391
return
401
392
}
402
- root , err := newTestRoot ()
403
- ok (t , err )
404
- defer os .RemoveAll (root )
405
393
406
394
rootfs , err := newRootfs ()
407
395
ok (t , err )
408
396
defer remove (rootfs )
409
397
410
398
config := newTemplateConfig (rootfs )
411
399
412
- container , err := factory . Create ("test" , config )
400
+ container , err := newContainerWithName ("test" , config )
413
401
ok (t , err )
414
402
defer container .Destroy ()
415
403
@@ -471,20 +459,13 @@ func TestAdditionalGroups(t *testing.T) {
471
459
if testing .Short () {
472
460
return
473
461
}
474
- root , err := newTestRoot ()
475
- ok (t , err )
476
- defer os .RemoveAll (root )
477
-
478
462
rootfs , err := newRootfs ()
479
463
ok (t , err )
480
464
defer remove (rootfs )
481
465
482
466
config := newTemplateConfig (rootfs )
483
467
484
- factory , err := libcontainer .New (root , libcontainer .Cgroupfs )
485
- ok (t , err )
486
-
487
- container , err := factory .Create ("test" , config )
468
+ container , err := newContainerWithName ("test" , config )
488
469
ok (t , err )
489
470
defer container .Destroy ()
490
471
@@ -531,21 +512,13 @@ func testFreeze(t *testing.T, systemd bool) {
531
512
if testing .Short () {
532
513
return
533
514
}
534
- root , err := newTestRoot ()
535
- ok (t , err )
536
- defer os .RemoveAll (root )
537
515
538
516
rootfs , err := newRootfs ()
539
517
ok (t , err )
540
518
defer remove (rootfs )
541
519
542
520
config := newTemplateConfig (rootfs )
543
- f := factory
544
- if systemd {
545
- f = systemdFactory
546
- }
547
-
548
- container , err := f .Create ("test" , config )
521
+ container , err := newContainerWithName ("test" , config )
549
522
ok (t , err )
550
523
defer container .Destroy ()
551
524
@@ -727,11 +700,6 @@ func TestContainerState(t *testing.T) {
727
700
if testing .Short () {
728
701
return
729
702
}
730
- root , err := newTestRoot ()
731
- if err != nil {
732
- t .Fatal (err )
733
- }
734
- defer os .RemoveAll (root )
735
703
736
704
rootfs , err := newRootfs ()
737
705
if err != nil {
@@ -754,7 +722,7 @@ func TestContainerState(t *testing.T) {
754
722
{Type : configs .NEWNET },
755
723
})
756
724
757
- container , err := factory . Create ("test" , config )
725
+ container , err := newContainerWithName ("test" , config )
758
726
if err != nil {
759
727
t .Fatal (err )
760
728
}
@@ -807,7 +775,7 @@ func TestPassExtraFiles(t *testing.T) {
807
775
808
776
config := newTemplateConfig (rootfs )
809
777
810
- container , err := factory . Create ("test" , config )
778
+ container , err := newContainerWithName ("test" , config )
811
779
if err != nil {
812
780
t .Fatal (err )
813
781
}
@@ -867,11 +835,6 @@ func TestMountCmds(t *testing.T) {
867
835
if testing .Short () {
868
836
return
869
837
}
870
- root , err := newTestRoot ()
871
- if err != nil {
872
- t .Fatal (err )
873
- }
874
- defer os .RemoveAll (root )
875
838
876
839
rootfs , err := newRootfs ()
877
840
if err != nil {
@@ -901,7 +864,7 @@ func TestMountCmds(t *testing.T) {
901
864
},
902
865
})
903
866
904
- container , err := factory . Create ("test" , config )
867
+ container , err := newContainerWithName ("test" , config )
905
868
if err != nil {
906
869
t .Fatal (err )
907
870
}
@@ -937,9 +900,6 @@ func TestSysctl(t *testing.T) {
937
900
if testing .Short () {
938
901
return
939
902
}
940
- root , err := newTestRoot ()
941
- ok (t , err )
942
- defer os .RemoveAll (root )
943
903
944
904
rootfs , err := newRootfs ()
945
905
ok (t , err )
@@ -950,7 +910,7 @@ func TestSysctl(t *testing.T) {
950
910
"kernel.shmmni" : "8192" ,
951
911
}
952
912
953
- container , err := factory . Create ("test" , config )
913
+ container , err := newContainerWithName ("test" , config )
954
914
ok (t , err )
955
915
defer container .Destroy ()
956
916
@@ -1077,9 +1037,6 @@ func TestOomScoreAdj(t *testing.T) {
1077
1037
if testing .Short () {
1078
1038
return
1079
1039
}
1080
- root , err := newTestRoot ()
1081
- ok (t , err )
1082
- defer os .RemoveAll (root )
1083
1040
1084
1041
rootfs , err := newRootfs ()
1085
1042
ok (t , err )
@@ -1088,10 +1045,7 @@ func TestOomScoreAdj(t *testing.T) {
1088
1045
config := newTemplateConfig (rootfs )
1089
1046
config .OomScoreAdj = ptrInt (200 )
1090
1047
1091
- factory , err := libcontainer .New (root , libcontainer .Cgroupfs )
1092
- ok (t , err )
1093
-
1094
- container , err := factory .Create ("test" , config )
1048
+ container , err := newContainerWithName ("test" , config )
1095
1049
ok (t , err )
1096
1050
defer container .Destroy ()
1097
1051
@@ -1198,7 +1152,7 @@ func TestHook(t *testing.T) {
1198
1152
ok (t , err )
1199
1153
ok (t , json .NewEncoder (f ).Encode (config ))
1200
1154
1201
- container , err := factory . Create ("test" , config )
1155
+ container , err := newContainerWithName ("test" , config )
1202
1156
ok (t , err )
1203
1157
1204
1158
var stdout bytes.Buffer
@@ -1307,10 +1261,7 @@ func TestRootfsPropagationSlaveMount(t *testing.T) {
1307
1261
Device : "bind" ,
1308
1262
Flags : unix .MS_BIND | unix .MS_REC })
1309
1263
1310
- // TODO: systemd specific processing
1311
- f := factory
1312
-
1313
- container , err := f .Create ("testSlaveMount" , config )
1264
+ container , err := newContainerWithName ("testSlaveMount" , config )
1314
1265
ok (t , err )
1315
1266
defer container .Destroy ()
1316
1267
@@ -1425,10 +1376,7 @@ func TestRootfsPropagationSharedMount(t *testing.T) {
1425
1376
Device : "bind" ,
1426
1377
Flags : unix .MS_BIND | unix .MS_REC })
1427
1378
1428
- // TODO: systemd specific processing
1429
- f := factory
1430
-
1431
- container , err := f .Create ("testSharedMount" , config )
1379
+ container , err := newContainerWithName ("testSharedMount" , config )
1432
1380
ok (t , err )
1433
1381
defer container .Destroy ()
1434
1382
@@ -1729,9 +1677,6 @@ func TestTmpfsCopyUp(t *testing.T) {
1729
1677
if testing .Short () {
1730
1678
return
1731
1679
}
1732
- root , err := newTestRoot ()
1733
- ok (t , err )
1734
- defer os .RemoveAll (root )
1735
1680
1736
1681
rootfs , err := newRootfs ()
1737
1682
ok (t , err )
@@ -1746,10 +1691,7 @@ func TestTmpfsCopyUp(t *testing.T) {
1746
1691
Extensions : configs .EXT_COPYUP ,
1747
1692
})
1748
1693
1749
- factory , err := libcontainer .New (root , libcontainer .Cgroupfs )
1750
- ok (t , err )
1751
-
1752
- container , err := factory .Create ("test" , config )
1694
+ container , err := newContainerWithName ("test" , config )
1753
1695
ok (t , err )
1754
1696
defer container .Destroy ()
1755
1697
0 commit comments