MCPcopy
hub / github.com/cilium/ebpf / TestMapPin

Function TestMapPin

map_test.go:447–481  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

445}
446
447func TestMapPin(t *testing.T) {
448 m := createMap(t, Array, 2)
449
450 if err := m.Put(uint32(0), uint32(42)); err != nil {
451 t.Fatal("Can't put:", err)
452 }
453
454 tmp := testutils.TempBPFFS(t)
455 path := filepath.Join(tmp, "map")
456
457 if err := m.Pin(path); err != nil {
458 testutils.SkipIfNotSupported(t, err)
459 t.Fatal(err)
460 }
461
462 pinned := m.IsPinned()
463 qt.Assert(t, qt.IsTrue(pinned))
464
465 m.Close()
466
467 m, err := LoadPinnedMap(path, nil)
468 testutils.SkipIfNotSupported(t, err)
469 if err != nil {
470 t.Fatal(err)
471 }
472 defer m.Close()
473
474 var v uint32
475 if err := m.Lookup(uint32(0), &v); err != nil {
476 t.Fatal("Can't lookup 0:", err)
477 }
478 if v != 42 {
479 t.Error("Want value 42, got", v)
480 }
481}
482
483func TestNestedMapPin(t *testing.T) {
484 m := createMapInMap(t, ArrayOfMaps, Array)

Callers

nothing calls this directly

Calls 10

TempBPFFSFunction · 0.92
SkipIfNotSupportedFunction · 0.92
LoadPinnedMapFunction · 0.85
PutMethod · 0.80
createMapFunction · 0.70
PinMethod · 0.65
CloseMethod · 0.65
IsPinnedMethod · 0.45
LookupMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…