From 88c977056b79317b251f922b089c757737dc72e9 Mon Sep 17 00:00:00 2001 From: Pavel Valena Date: Tue, 19 Jul 2016 14:59:06 +0200 Subject: [PATCH] Fix and enhance systemtap tests Previous tests did not work correctly with RHEL-6 --- ruby.spec | 3 +++ test_systemtap.rb | 37 +++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ruby.spec b/ruby.spec index bb1701d..391a4b6 100644 --- a/ruby.spec +++ b/ruby.spec @@ -964,6 +964,9 @@ TZ=UTC make check TESTS="-v $DISABLE_TESTS" %{ruby_libdir}/tkextlib %changelog +* Tue Jul 19 2016 Pavel Valena - 2.3.0-60 +- Fix and enhance systemtap tests + * Wed Apr 13 2016 Pavel Valena - 2.3.0-60 - Fix ruby lib path in macros.ruby.rh-ruby23 - Resolves: rhbz#1255753 diff --git a/test_systemtap.rb b/test_systemtap.rb index eb518df..5784e2d 100644 --- a/test_systemtap.rb +++ b/test_systemtap.rb @@ -3,8 +3,10 @@ require 'set' LIBRUBY_SO = 'libruby.so' PROBES_D = 'probes.d' -### -# Detect SystemTap section headers presence. +# These probes are excluded by VM_COLLECT_USAGE_DETAILS ifdef. +EXCLUDE_PROBES = Set.new %w(insn insn__operand) + +## Detect SystemTap section headers presence stap_headers = [ '\.stapsdt\.base', @@ -22,43 +24,42 @@ unless detected_stap_headers.size == 2 exit false end -### -# Find if every declared probe is propagated to resulting library. +## Find if every declared probe is propagated to resulting library # Colect probes specified in probes.d file. -probes = [] +probes_declared = [] File.open(PROBES_D) do |file| file.each_line do |line| if probe = line[/probe (\S+)\(.*\);/, 1] - probes << probe + probes_declared << probe end end end -probes = Set.new probes +probes_declared = Set.new probes_declared -# These probes are excluded by VM_COLLECT_USAGE_DETAILS ifdef. -EXCLUDE_PROBES = Set.new %w(insn insn__operand) -unless EXCLUDE_PROBES.subset? probes +unless EXCLUDE_PROBES.subset? probes_declared puts 'ERROR: Change in SystemTap (DTrace) probes definition file detected.' exit false end -probes -= EXCLUDE_PROBES +probes_declared -= EXCLUDE_PROBES # Detect probes in resulting library. -probe_regexp = %r{ -^\s*stapsdt\s*0[xX][0-9a-fA-F]+\tNT_STAPSDT \(SystemTap probe descriptors\)$ -^\s*Provider: ruby$ -^\s*Name: (\S+)$ +get_probes_detected = %r{ +^\s*Provider:\s+ruby,\s+Name:\s+(\S+),\s+.*$ } -notes = `readelf -n "#{LIBRUBY_SO}"` -detected_probes = Set.new notes.scan(probe_regexp).flatten +probes_detected = `eu-readelf -n "#{LIBRUBY_SO}"` + +probes_detected = Set.new probes_detected.scan(get_probes_detected).flatten # Both sets must be equal, otherwise something is wrong. -unless probes == detected_probes +unless probes_declared == probes_detected puts 'ERROR: SystemTap (DTrace) probes were not correctly propagated into resulting library.' + puts " Undetected probes: #{(probes_declared - probes_detected).sort.join(', ')}\n", + " Additional detected probes: #{(probes_detected - probes_declared).sort.join(', ')}" + exit false end