@@ -19,39 +19,41 @@ package container
1919import (
2020 "testing"
2121
22+ "github.com/containerd/nerdctl/mod/tigron/expect"
23+ "github.com/containerd/nerdctl/mod/tigron/test"
24+
2225 "github.com/containerd/nerdctl/v2/pkg/testutil"
26+ "github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
2327)
2428
2529func TestRunSysctl (t * testing.T ) {
26- t .Parallel ()
27- base := testutil .NewBase (t )
28- base .Cmd ("run" , "--rm" , "--sysctl" , "net.ipv4.ip_forward=1" , testutil .AlpineImage , "cat" , "/proc/sys/net/ipv4/ip_forward" ).AssertOutExactly ("1\n " )
30+ testCase := nerdtest .Setup ()
31+
32+ testCase .Command = test .Command ("run" , "--rm" , "--sysctl" , "net.ipv4.ip_forward=1" , testutil .AlpineImage , "cat" , "/proc/sys/net/ipv4/ip_forward" )
33+ testCase .Expected = test .Expects (0 , nil , expect .Equals ("1\n " ))
34+
35+ testCase .Run (t )
2936}
3037
3138func TestRunSysctl_DefaultUnprivilegedPortStart (t * testing.T ) {
32- t .Parallel ()
33- base := testutil .NewBase (t )
39+ testCase := nerdtest .Setup ()
3440
3541 // No --sysctl flags, default network mode (non-host).
3642 // We expect net.ipv4.ip_unprivileged_port_start=0 inside the container,
3743 // because withDefaultUnprivilegedPortSysctl should apply the default.
38- base .Cmd (
39- "run" , "--rm" ,
40- testutil .AlpineImage ,
41- "cat" , "/proc/sys/net/ipv4/ip_unprivileged_port_start" ,
42- ).AssertOutExactly ("0\n " )
44+ testCase .Command = test .Command ("run" , "--rm" , testutil .AlpineImage , "cat" , "/proc/sys/net/ipv4/ip_unprivileged_port_start" )
45+ testCase .Expected = test .Expects (0 , nil , expect .Equals ("0\n " ))
46+
47+ testCase .Run (t )
4348}
4449
4550func TestRunSysctl_UnprivilegedPortStartOverride (t * testing.T ) {
46- t .Parallel ()
47- base := testutil .NewBase (t )
51+ testCase := nerdtest .Setup ()
4852
4953 // User explicitly sets net.ipv4.ip_unprivileged_port_start=1000.
5054 // We must NOT override this; the container should see "1000".
51- base .Cmd (
52- "run" , "--rm" ,
53- "--sysctl" , "net.ipv4.ip_unprivileged_port_start=1000" ,
54- testutil .AlpineImage ,
55- "cat" , "/proc/sys/net/ipv4/ip_unprivileged_port_start" ,
56- ).AssertOutExactly ("1000\n " )
55+ testCase .Command = test .Command ("run" , "--rm" , "--sysctl" , "net.ipv4.ip_unprivileged_port_start=1000" , testutil .AlpineImage , "cat" , "/proc/sys/net/ipv4/ip_unprivileged_port_start" )
56+ testCase .Expected = test .Expects (0 , nil , expect .Equals ("1000\n " ))
57+
58+ testCase .Run (t )
5759}
0 commit comments