@@ -1326,10 +1326,9 @@ func TestTraceEBPFTypes(t *testing.T) {
13261326 dlvbin := protest .GetDlvBinaryEBPF (t )
13271327 fixtures := protest .FindFixturesDir ()
13281328
1329- // Test small integer types (int8, uint16, int32) to verify correct byte sizes
1330- t .Run ("SmallInts" , func (t * testing.T ) {
1331- t .Parallel ()
1332- cmd := exec .Command (dlvbin , "trace" , "--ebpf" , "--output" , filepath .Join (t .TempDir (), "__debug" ), filepath .Join (fixtures , "ebpf_trace_types.go" ), "main.tracedSmallInts" )
1329+ runEBPFTrace := func (t * testing.T , funcName string ) []byte {
1330+ t .Helper ()
1331+ cmd := exec .Command (dlvbin , "trace" , "--ebpf" , "--output" , filepath .Join (t .TempDir (), "__debug" ), filepath .Join (fixtures , "ebpf_trace_types.go" ), funcName )
13331332 rdr , err := cmd .StderrPipe ()
13341333 assertNoError (err , t , "stderr pipe" )
13351334 defer rdr .Close ()
@@ -1338,8 +1337,13 @@ func TestTraceEBPFTypes(t *testing.T) {
13381337 output , err := io .ReadAll (rdr )
13391338 assertNoError (err , t , "ReadAll" )
13401339 cmd .Wait ()
1340+ return output
1341+ }
13411342
1342- // Verify that small int values display correctly
1343+ // Test small integer types (int8, uint16, int32) to verify correct byte sizes
1344+ t .Run ("SmallInts" , func (t * testing.T ) {
1345+ t .Parallel ()
1346+ output := runEBPFTrace (t , "main.tracedSmallInts" )
13431347 if ! bytes .Contains (output , []byte ("7" )) || ! bytes .Contains (output , []byte ("1000" )) || ! bytes .Contains (output , []byte ("-42" )) {
13441348 t .Fatalf ("expected small int values in output, got:\n %s" , string (output ))
13451349 }
@@ -1348,21 +1352,10 @@ func TestTraceEBPFTypes(t *testing.T) {
13481352 // Test pointer types
13491353 t .Run ("Pointers" , func (t * testing.T ) {
13501354 t .Parallel ()
1351- cmd := exec .Command (dlvbin , "trace" , "--ebpf" , "--output" , filepath .Join (t .TempDir (), "__debug" ), filepath .Join (fixtures , "ebpf_trace_types.go" ), "main.tracedPointer" )
1352- rdr , err := cmd .StderrPipe ()
1353- assertNoError (err , t , "stderr pipe" )
1354- defer rdr .Close ()
1355-
1356- assertNoError (cmd .Start (), t , "running trace" )
1357- output , err := io .ReadAll (rdr )
1358- assertNoError (err , t , "ReadAll" )
1359- cmd .Wait ()
1360-
1361- // Verify pointer params don't show "type not supported" errors
1355+ output := runEBPFTrace (t , "main.tracedPointer" )
13621356 if bytes .Contains (output , []byte ("type not supported" )) {
13631357 t .Fatalf ("pointer type should be supported, got:\n %s" , string (output ))
13641358 }
1365- // Should contain a non-zero address value for the pointer
13661359 addrRe := regexp .MustCompile (`main\.tracedPointer\([1-9][0-9]*` )
13671360 if ! addrRe .Match (output ) {
13681361 t .Fatalf ("expected pointer address values in output, got:\n %s" , string (output ))
@@ -1372,21 +1365,10 @@ func TestTraceEBPFTypes(t *testing.T) {
13721365 // Test slice types
13731366 t .Run ("Slices" , func (t * testing.T ) {
13741367 t .Parallel ()
1375- cmd := exec .Command (dlvbin , "trace" , "--ebpf" , "--output" , filepath .Join (t .TempDir (), "__debug" ), filepath .Join (fixtures , "ebpf_trace_types.go" ), "main.tracedSlice" )
1376- rdr , err := cmd .StderrPipe ()
1377- assertNoError (err , t , "stderr pipe" )
1378- defer rdr .Close ()
1379-
1380- assertNoError (cmd .Start (), t , "running trace" )
1381- output , err := io .ReadAll (rdr )
1382- assertNoError (err , t , "ReadAll" )
1383- cmd .Wait ()
1384-
1385- // Verify slice params don't show "type not supported" errors
1368+ output := runEBPFTrace (t , "main.tracedSlice" )
13861369 if bytes .Contains (output , []byte ("type not supported" )) {
13871370 t .Fatalf ("slice type should be supported, got:\n %s" , string (output ))
13881371 }
1389- // Should contain a non-zero address value for the slice data pointer
13901372 sliceRe := regexp .MustCompile (`main\.tracedSlice\([1-9][0-9]*` )
13911373 if ! sliceRe .Match (output ) {
13921374 t .Fatalf ("expected slice address value in output, got:\n %s" , string (output ))
0 commit comments