Method: GeneratorHelper#test_crash?

Defined in:
lib/ceedling/generator_helper.rb

#test_crash?(test_filename, executable, shell_result) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ceedling/generator_helper.rb', line 16

def test_crash?(test_filename, executable, shell_result)
  runner = File.basename(executable)

  crash = false

  # Unix Signal 11 ==> SIGSEGV
  # Applies to Unix-like systems including MSYS on Windows
  if (shell_result[:status].termsig == 11)
    @loginator.log( "#{runner} process terminated with SIGSEGV (Unix Signal 11)", Verbosity::DEBUG, LogLabels::CRASH )
    crash = true
  end

  # No test results found in test executable output
  if (shell_result[:output] =~ TEST_STDOUT_STATISTICS_PATTERN).nil?
    # No debug logging here because we log this condition in the error log handling below
    crash = true
  end

  # Negative lookahead regex that checks all lines in test STDERR output.
  # (?m) enables multiline mode.
  # Matches only a line with a 'segfault' variant that does not begin with the test code filename.
  # Processing STDERR and ignoring lines that look like test case results helps limit false positives.
  segfault_pattern = 'Seg.*fault'
  regex = /\A(?!(?m).*^#{Regexp.escape(test_filename)}.*$).*(?:#{segfault_pattern})/mi

  if shell_result[:stderr].match?(regex)
    @loginator.log( "#{runner} STDERR reports segmentation fault", Verbosity::DEBUG, LogLabels::CRASH )
    crash = true
  end

  return crash
end