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