(t *testing.T)
| 24 | } |
| 25 | |
| 26 | func TestCollectionSpecNotModified(t *testing.T) { |
| 27 | spec := &CollectionSpec{ |
| 28 | Maps: map[string]*MapSpec{ |
| 29 | "my-map": { |
| 30 | Type: Array, |
| 31 | KeySize: 4, |
| 32 | ValueSize: 4, |
| 33 | MaxEntries: 1, |
| 34 | }, |
| 35 | ".rodata": { |
| 36 | Type: Array, |
| 37 | KeySize: 4, |
| 38 | ValueSize: 4, |
| 39 | MaxEntries: 1, |
| 40 | Flags: 0, // Loader sets BPF_F_MMAPABLE. |
| 41 | Contents: []MapKV{{uint32(0), uint32(1)}}, |
| 42 | }, |
| 43 | }, |
| 44 | Programs: map[string]*ProgramSpec{ |
| 45 | "test": { |
| 46 | Type: SocketFilter, |
| 47 | Instructions: asm.Instructions{ |
| 48 | asm.LoadImm(asm.R1, 0, asm.DWord).WithReference(".rodata"), |
| 49 | asm.LoadImm(asm.R1, 0, asm.DWord).WithReference("my-map"), |
| 50 | asm.LoadImm(asm.R0, 0, asm.DWord), |
| 51 | asm.Return(), |
| 52 | }, |
| 53 | License: "MIT", |
| 54 | }, |
| 55 | }, |
| 56 | } |
| 57 | |
| 58 | orig := spec.Copy() |
| 59 | coll := mustNewCollection(t, spec, nil) |
| 60 | qt.Assert(t, qt.CmpEquals(orig, spec, csCmpOpts)) |
| 61 | |
| 62 | for name := range spec.Maps { |
| 63 | qt.Assert(t, qt.IsNotNil(coll.Maps[name])) |
| 64 | } |
| 65 | |
| 66 | for name := range spec.Programs { |
| 67 | qt.Assert(t, qt.IsNotNil(coll.Programs[name])) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | func TestCollectionSpecCopy(t *testing.T) { |
| 72 | ms := &MapSpec{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…