github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/libnetwork/osl/kernel/knobs_linux_test.go (about) 1 package kernel 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/containerd/log" 8 "gotest.tools/v3/assert" 9 is "gotest.tools/v3/assert/cmp" 10 ) 11 12 func TestReadWriteKnobs(t *testing.T) { 13 for _, k := range []string{ 14 "net.ipv4.neigh.default.gc_thresh1", 15 "net.ipv4.neigh.default.gc_thresh2", 16 "net.ipv4.neigh.default.gc_thresh3", 17 } { 18 // Check if the test is able to read the value 19 v, err := readSystemProperty(k) 20 if err != nil { 21 log.G(context.TODO()).WithError(err).Warnf("Path %v not readable", k) 22 // the path is not there, skip this key 23 continue 24 } 25 // Test the write 26 assert.Check(t, writeSystemProperty(k, "10000")) 27 newV, err := readSystemProperty(k) 28 assert.NilError(t, err) 29 assert.Check(t, is.Equal(newV, "10000")) 30 // Restore value 31 assert.Check(t, writeSystemProperty(k, v)) 32 } 33 }