(t *testing.T)
| 210 | } |
| 211 | |
| 212 | func TestUprobeMultiProgramCall(t *testing.T) { |
| 213 | testutils.SkipIfNotSupported(t, features.HaveBPFLinkUprobeMulti()) |
| 214 | |
| 215 | // We execute 'bash --help' |
| 216 | args := []string{"--help"} |
| 217 | elf := "/bin/bash" |
| 218 | |
| 219 | test := func(retprobe bool, expected uint32) { |
| 220 | m, p := newUpdaterMapProg(t, ebpf.Kprobe, ebpf.AttachTraceUprobeMulti) |
| 221 | |
| 222 | var err error |
| 223 | |
| 224 | // Load the executable. |
| 225 | ex, err := OpenExecutable(elf) |
| 226 | if err != nil { |
| 227 | t.Fatal(err) |
| 228 | } |
| 229 | |
| 230 | var um Link |
| 231 | |
| 232 | // Open UprobeMulti on the executable for the given symbol |
| 233 | // and attach it to the ebpf program created above. |
| 234 | if retprobe { |
| 235 | um, err = ex.UretprobeMulti(bashSyms, p, nil) |
| 236 | } else { |
| 237 | um, err = ex.UprobeMulti(bashSyms, p, nil) |
| 238 | } |
| 239 | if errors.Is(err, ErrNoSymbol) { |
| 240 | // Assume bash_Syms symbols always exist and skip the test |
| 241 | // if the symbol can't be found as certain OS (eg. Debian) |
| 242 | // strip binaries. |
| 243 | t.Skipf("executable %s appear to be stripped, skipping", elf) |
| 244 | } |
| 245 | if err != nil { |
| 246 | t.Fatal(err) |
| 247 | } |
| 248 | |
| 249 | // Trigger ebpf program call. |
| 250 | trigger := func(t *testing.T) { |
| 251 | if err := exec.Command(elf, args...).Run(); err != nil { |
| 252 | t.Fatal(err) |
| 253 | } |
| 254 | } |
| 255 | trigger(t) |
| 256 | |
| 257 | // Detach link. |
| 258 | if err := um.Close(); err != nil { |
| 259 | t.Fatal(err) |
| 260 | } |
| 261 | |
| 262 | assertMapValueGE(t, m, 0, expected) |
| 263 | |
| 264 | // Reset map value to 0 at index 0. |
| 265 | if err := m.Update(uint32(0), uint32(0), ebpf.UpdateExist); err != nil { |
| 266 | t.Fatal(err) |
| 267 | } |
| 268 | |
| 269 | // Retrigger the ebpf program call. |
nothing calls this directly
no test coverage detected
searching dependent graphs…