@@ -80,11 +80,31 @@ func TestIntegrationSingleShot(t *testing.T) {
8080 t .Skip ("This test requires root privileges" )
8181 }
8282
83+ // Enable info logging to see uprobe attachment
84+ log .SetLevel (log .InfoLevel )
85+
8386 // Enable debug logging for CI debugging
8487 if os .Getenv ("DEBUG_TEST" ) != "" {
8588 log .SetLevel (log .DebugLevel )
8689 }
8790
91+ t .Logf ("Test process PID: %d" , os .Getpid ())
92+
93+ // Check which libraries are available and contain dlopen
94+ t .Logf ("Checking for dlopen-containing libraries..." )
95+ possibleLibs := []string {
96+ "/lib/x86_64-linux-gnu/libc.so.6" ,
97+ "/lib64/libc.so.6" ,
98+ "/usr/lib/x86_64-linux-gnu/libc.so.6" ,
99+ "/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2" ,
100+ "/lib64/ld-linux-x86-64.so.2" ,
101+ }
102+ for _ , lib := range possibleLibs {
103+ if _ , err := os .Stat (lib ); err == nil {
104+ t .Logf ("Found library: %s" , lib )
105+ }
106+ }
107+
88108 // Override HasMultiUprobeSupport to force single-shot mode
89109 multiUProbeOverride := false
90110 util .SetTestOnlyMultiUprobeSupport (& multiUProbeOverride )
@@ -95,10 +115,12 @@ func TestIntegrationSingleShot(t *testing.T) {
95115 defer cancel ()
96116
97117 // Start the tracer with all tracers enabled
118+ t .Logf ("Starting tracer..." )
98119 traceCh , trc := testutils .StartTracer (ctx , t ,
99120 tracertypes .AllTracers (),
100121 false )
101122 defer trc .Close ()
123+ t .Logf ("Tracer started successfully" )
102124
103125 // Consume traces to prevent blocking
104126 go func () {
@@ -117,23 +139,32 @@ func TestIntegrationSingleShot(t *testing.T) {
117139 require .Eventually (t , func () bool {
118140 // Get the initial metric value
119141 initialCount := getEBPFMetricValue (trc , metrics .IDDlopenUprobeHits )
120- // t.Logf("Initial dlopen uprobe metric count: %d", initialCount)
142+ t .Logf ("Initial dlopen uprobe metric count: %d" , initialCount )
121143
122144 // Use dlopen to load a shared library
123145 // libm is a standard math library that's always present
124146 lib , err := dlopen .GetHandle ([]string {
125147 "/lib/x86_64-linux-gnu/libm.so.6" ,
126148 "libm.so.6" ,
127149 })
128- require .NoError (t , err , "Failed to open libm.so.6" )
150+ if err != nil {
151+ t .Logf ("Failed to open libm.so.6: %v" , err )
152+ require .NoError (t , err , "Failed to open libm.so.6" )
153+ }
154+ t .Logf ("Successfully opened libm.so.6" )
129155 defer lib .Close ()
130156
131157 // Get the metrics after dlopen
132158 finalCount := getEBPFMetricValue (trc , metrics .IDDlopenUprobeHits )
133- // t.Logf("Final dlopen uprobe metric count: %d", finalCount)
159+ t .Logf ("Final dlopen uprobe metric count: %d (delta: %d) " , finalCount , finalCount - initialCount )
134160
135161 // Check that the metric was incremented
136- return finalCount > initialCount
162+ if finalCount > initialCount {
163+ t .Logf ("SUCCESS: Metric incremented from %d to %d" , initialCount , finalCount )
164+ return true
165+ }
166+ t .Logf ("Metric not incremented yet, retrying..." )
167+ return false
137168 }, 10 * time .Second , 50 * time .Millisecond )
138169}
139170
@@ -142,21 +173,29 @@ func getEBPFMetricValue(trc *tracer.Tracer, metricID metrics.MetricID) uint64 {
142173 ebpfMaps := trc .GetEbpfMaps ()
143174 metricsMap , ok := ebpfMaps ["metrics" ]
144175 if ! ok {
176+ log .Debugf ("Metrics map not found in eBPF maps" )
145177 return 0
146178 }
147179
148180 // Find the eBPF metric ID that corresponds to our metrics.MetricID
149181 var ebpfMetricID uint32
182+ found := false
150183 for ebpfID , id := range support .MetricsTranslation {
151184 if id == metricID {
152185 ebpfMetricID = uint32 (ebpfID )
186+ found = true
153187 break
154188 }
155189 }
190+ if ! found {
191+ log .Debugf ("Metric ID %v not found in MetricsTranslation" , metricID )
192+ return 0
193+ }
156194
157195 // Read the per-CPU values
158196 var perCPUValues []uint64
159197 if err := metricsMap .Lookup (unsafe .Pointer (& ebpfMetricID ), & perCPUValues ); err != nil {
198+ log .Debugf ("Failed to lookup metric %v (eBPF ID %d): %v" , metricID , ebpfMetricID , err )
160199 return 0
161200 }
162201
@@ -165,5 +204,6 @@ func getEBPFMetricValue(trc *tracer.Tracer, metricID metrics.MetricID) uint64 {
165204 for _ , val := range perCPUValues {
166205 total += val
167206 }
207+ log .Debugf ("Metric %v (eBPF ID %d): total=%d from %d CPUs" , metricID , ebpfMetricID , total , len (perCPUValues ))
168208 return total
169209}
0 commit comments