(t *testing.T)
| 486 | } |
| 487 | |
| 488 | func TestCollectionAssignFail(t *testing.T) { |
| 489 | // `map2` does not exist |
| 490 | var objs struct { |
| 491 | Program *Program `ebpf:"prog1"` |
| 492 | Map *Map `ebpf:"map2"` |
| 493 | } |
| 494 | |
| 495 | cs := &CollectionSpec{ |
| 496 | Maps: map[string]*MapSpec{ |
| 497 | "map1": { |
| 498 | Type: Array, |
| 499 | KeySize: 4, |
| 500 | ValueSize: 4, |
| 501 | MaxEntries: 1, |
| 502 | }, |
| 503 | }, |
| 504 | Programs: map[string]*ProgramSpec{ |
| 505 | "prog1": { |
| 506 | Type: SocketFilter, |
| 507 | Instructions: asm.Instructions{ |
| 508 | asm.LoadImm(asm.R0, 0, asm.DWord), |
| 509 | asm.Return(), |
| 510 | }, |
| 511 | License: "MIT", |
| 512 | }, |
| 513 | }, |
| 514 | } |
| 515 | |
| 516 | coll := mustNewCollection(t, cs, nil) |
| 517 | |
| 518 | qt.Assert(t, qt.IsNotNil(coll.Assign(&objs))) |
| 519 | |
| 520 | // Check that the collection has retained ownership |
| 521 | qt.Assert(t, qt.IsNotNil(coll.Programs["prog1"])) |
| 522 | qt.Assert(t, qt.IsNotNil(coll.Maps["map1"])) |
| 523 | } |
| 524 | |
| 525 | func TestIncompleteLoadAndAssign(t *testing.T) { |
| 526 | spec := &CollectionSpec{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…