Fix and enhance systemtap tests

Previous tests did not work correctly with RHEL-6
This commit is contained in:
Pavel Valena 2016-07-19 14:59:06 +02:00
parent 9fd772dd06
commit 88c977056b
2 changed files with 22 additions and 18 deletions

View File

@ -964,6 +964,9 @@ TZ=UTC make check TESTS="-v $DISABLE_TESTS"
%{ruby_libdir}/tkextlib
%changelog
* Tue Jul 19 2016 Pavel Valena <pvalena@redhat.com> - 2.3.0-60
- Fix and enhance systemtap tests
* Wed Apr 13 2016 Pavel Valena <pvalena@redhat.com> - 2.3.0-60
- Fix ruby lib path in macros.ruby.rh-ruby23
- Resolves: rhbz#1255753

View File

@ -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