mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-05 21:15:20 +00:00
- Added a couple more tests to our details test
- Added a gitattributes file to force line endings to be correct.
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
* text=auto
|
||||||
|
|
||||||
|
# These files are text and should be normalized (convert crlf to lf)
|
||||||
|
*.rb text
|
||||||
|
*.test text
|
||||||
|
*.c text
|
||||||
|
*.cpp text
|
||||||
|
*.h text
|
||||||
|
*.txt text
|
||||||
|
*.yml text
|
||||||
|
*.s79 text
|
||||||
|
*.bat text
|
||||||
|
*.xcl text
|
||||||
|
*.inc text
|
||||||
|
*.info text
|
||||||
|
*.md text
|
||||||
|
makefile text
|
||||||
|
rakefile text
|
||||||
|
|
||||||
|
|
||||||
|
#These files are binary and should not be normalized
|
||||||
|
*.doc binary
|
||||||
|
*.odt binary
|
||||||
|
*.pdf binary
|
||||||
|
*.ewd binary
|
||||||
|
*.eww binary
|
||||||
|
*.dni binary
|
||||||
|
*.wsdt binary
|
||||||
|
*.dbgdt binary
|
||||||
|
*.mac binary
|
||||||
@@ -4,7 +4,7 @@ class CMockGeneratorPluginReturnThruPtr
|
|||||||
|
|
||||||
def initialize(config, utils)
|
def initialize(config, utils)
|
||||||
@utils = utils
|
@utils = utils
|
||||||
@priority = 1
|
@priority = 1 #TODO: it's 1 to come before ignore_arg returns... but should be after expects otherwise (like 9)
|
||||||
end
|
end
|
||||||
|
|
||||||
def instance_typedefs(function)
|
def instance_typedefs(function)
|
||||||
|
|||||||
+381
-381
@@ -1,381 +1,381 @@
|
|||||||
# ==========================================
|
# ==========================================
|
||||||
# CMock Project - Automatic Mock Generation for C
|
# CMock Project - Automatic Mock Generation for C
|
||||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require './vendor/unity/auto/generate_test_runner'
|
require './vendor/unity/auto/generate_test_runner'
|
||||||
require './vendor/unity/auto/unity_test_summary'
|
require './vendor/unity/auto/unity_test_summary'
|
||||||
require './test/system/systest_generator'
|
require './test/system/systest_generator'
|
||||||
require './vendor/unity/auto/colour_reporter.rb'
|
require './vendor/unity/auto/colour_reporter.rb'
|
||||||
|
|
||||||
module RakefileHelpers
|
module RakefileHelpers
|
||||||
|
|
||||||
SYSTEST_GENERATED_FILES_PATH = 'test/system/generated/'
|
SYSTEST_GENERATED_FILES_PATH = 'test/system/generated/'
|
||||||
SYSTEST_BUILD_FILES_PATH = 'test/system/build/'
|
SYSTEST_BUILD_FILES_PATH = 'test/system/build/'
|
||||||
SYSTEST_COMPILE_MOCKABLES_PATH = 'test/system/test_compilation/'
|
SYSTEST_COMPILE_MOCKABLES_PATH = 'test/system/test_compilation/'
|
||||||
C_EXTENSION = '.c'
|
C_EXTENSION = '.c'
|
||||||
RESULT_EXTENSION = '.result'
|
RESULT_EXTENSION = '.result'
|
||||||
|
|
||||||
def load_configuration(config_file)
|
def load_configuration(config_file)
|
||||||
$cfg_file = config_file
|
$cfg_file = config_file
|
||||||
$cfg = YAML.load(File.read('./targets/' + $cfg_file))
|
$cfg = YAML.load(File.read('./targets/' + $cfg_file))
|
||||||
$colour_output = false unless $cfg['colour']
|
$colour_output = false unless $cfg['colour']
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_clean
|
def configure_clean
|
||||||
CLEAN.include(SYSTEST_GENERATED_FILES_PATH + '*.*')
|
CLEAN.include(SYSTEST_GENERATED_FILES_PATH + '*.*')
|
||||||
CLEAN.include(SYSTEST_BUILD_FILES_PATH + '*.*')
|
CLEAN.include(SYSTEST_BUILD_FILES_PATH + '*.*')
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_toolchain(config_file)
|
def configure_toolchain(config_file)
|
||||||
load_configuration(config_file)
|
load_configuration(config_file)
|
||||||
configure_clean
|
configure_clean
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_local_include_dirs
|
def get_local_include_dirs
|
||||||
include_dirs = $cfg['compiler']['includes']['items'].dup
|
include_dirs = $cfg['compiler']['includes']['items'].dup
|
||||||
include_dirs.delete_if {|dir| dir.is_a?(Array)}
|
include_dirs.delete_if {|dir| dir.is_a?(Array)}
|
||||||
return include_dirs
|
return include_dirs
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_headers(filename)
|
def extract_headers(filename)
|
||||||
includes = []
|
includes = []
|
||||||
lines = File.readlines(filename)
|
lines = File.readlines(filename)
|
||||||
lines.each do |line|
|
lines.each do |line|
|
||||||
m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/)
|
m = line.match(/^\s*#include\s+\"\s*(.+\.[hH])\s*\"/)
|
||||||
if not m.nil?
|
if not m.nil?
|
||||||
includes << m[1]
|
includes << m[1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return includes
|
return includes
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_source_file(header, paths)
|
def find_source_file(header, paths)
|
||||||
paths.each do |dir|
|
paths.each do |dir|
|
||||||
src_file = dir + header.ext(C_EXTENSION)
|
src_file = dir + header.ext(C_EXTENSION)
|
||||||
if (File.exists?(src_file))
|
if (File.exists?(src_file))
|
||||||
return src_file
|
return src_file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def squash(prefix, items)
|
def squash(prefix, items)
|
||||||
result = ''
|
result = ''
|
||||||
items.each { |item| result += " #{prefix}#{tackit(item)}" }
|
items.each { |item| result += " #{prefix}#{tackit(item)}" }
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_compiler_fields
|
def build_compiler_fields
|
||||||
command = tackit($cfg['compiler']['path'])
|
command = tackit($cfg['compiler']['path'])
|
||||||
if $cfg['compiler']['defines']['items'].nil?
|
if $cfg['compiler']['defines']['items'].nil?
|
||||||
defines = ''
|
defines = ''
|
||||||
else
|
else
|
||||||
defines = squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'])
|
defines = squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'])
|
||||||
end
|
end
|
||||||
options = squash('', $cfg['compiler']['options'])
|
options = squash('', $cfg['compiler']['options'])
|
||||||
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
|
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
|
||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
return {:command => command, :defines => defines, :options => options, :includes => includes}
|
return {:command => command, :defines => defines, :options => options, :includes => includes}
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile(file, defines=[])
|
def compile(file, defines=[])
|
||||||
compiler = build_compiler_fields
|
compiler = build_compiler_fields
|
||||||
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{defines.inject(''){|all, a| ' -D'+a+all }}#{compiler[:options]}#{compiler[:includes]} #{file} " +
|
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{defines.inject(''){|all, a| ' -D'+a+all }}#{compiler[:options]}#{compiler[:includes]} #{file} " +
|
||||||
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
|
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
|
||||||
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
||||||
execute(cmd_str + obj_file)
|
execute(cmd_str + obj_file)
|
||||||
return obj_file
|
return obj_file
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_linker_fields
|
def build_linker_fields
|
||||||
command = tackit($cfg['linker']['path'])
|
command = tackit($cfg['linker']['path'])
|
||||||
if $cfg['linker']['options'].nil?
|
if $cfg['linker']['options'].nil?
|
||||||
options = ''
|
options = ''
|
||||||
else
|
else
|
||||||
options = squash('', $cfg['linker']['options'])
|
options = squash('', $cfg['linker']['options'])
|
||||||
end
|
end
|
||||||
if ($cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?)
|
if ($cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?)
|
||||||
includes = ''
|
includes = ''
|
||||||
else
|
else
|
||||||
includes = squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
includes = squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
||||||
end
|
end
|
||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
||||||
return {:command => command, :options => options, :includes => includes}
|
return {:command => command, :options => options, :includes => includes}
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_it(exe_name, obj_list)
|
def link_it(exe_name, obj_list)
|
||||||
linker = build_linker_fields
|
linker = build_linker_fields
|
||||||
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
|
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
|
||||||
(obj_list.map{|obj|"#{$cfg['linker']['object_files']['path']}#{obj} "}).uniq.join +
|
(obj_list.map{|obj|"#{$cfg['linker']['object_files']['path']}#{obj} "}).uniq.join +
|
||||||
$cfg['linker']['bin_files']['prefix'] + ' ' +
|
$cfg['linker']['bin_files']['prefix'] + ' ' +
|
||||||
$cfg['linker']['bin_files']['destination'] +
|
$cfg['linker']['bin_files']['destination'] +
|
||||||
exe_name + $cfg['linker']['bin_files']['extension']
|
exe_name + $cfg['linker']['bin_files']['extension']
|
||||||
execute(cmd_str)
|
execute(cmd_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_simulator_fields
|
def build_simulator_fields
|
||||||
return nil if $cfg['simulator'].nil?
|
return nil if $cfg['simulator'].nil?
|
||||||
if $cfg['simulator']['path'].nil?
|
if $cfg['simulator']['path'].nil?
|
||||||
command = ''
|
command = ''
|
||||||
else
|
else
|
||||||
command = (tackit($cfg['simulator']['path']) + ' ')
|
command = (tackit($cfg['simulator']['path']) + ' ')
|
||||||
end
|
end
|
||||||
if $cfg['simulator']['pre_support'].nil?
|
if $cfg['simulator']['pre_support'].nil?
|
||||||
pre_support = ''
|
pre_support = ''
|
||||||
else
|
else
|
||||||
pre_support = squash('', $cfg['simulator']['pre_support'])
|
pre_support = squash('', $cfg['simulator']['pre_support'])
|
||||||
end
|
end
|
||||||
if $cfg['simulator']['post_support'].nil?
|
if $cfg['simulator']['post_support'].nil?
|
||||||
post_support = ''
|
post_support = ''
|
||||||
else
|
else
|
||||||
post_support = squash('', $cfg['simulator']['post_support'])
|
post_support = squash('', $cfg['simulator']['post_support'])
|
||||||
end
|
end
|
||||||
return {:command => command, :pre_support => pre_support, :post_support => post_support}
|
return {:command => command, :pre_support => pre_support, :post_support => post_support}
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute(command_string, verbose=true, raise_on_failure=true)
|
def execute(command_string, verbose=true, raise_on_failure=true)
|
||||||
#report command_string
|
#report command_string
|
||||||
output = `#{command_string}`.chomp
|
output = `#{command_string}`.chomp
|
||||||
report(output) if (verbose && !output.nil? && (output.length > 0))
|
report(output) if (verbose && !output.nil? && (output.length > 0))
|
||||||
if ($?.exitstatus != 0) and (raise_on_failure)
|
if ($?.exitstatus != 0) and (raise_on_failure)
|
||||||
raise "#{command_string} failed. (Returned #{$?.exitstatus})"
|
raise "#{command_string} failed. (Returned #{$?.exitstatus})"
|
||||||
end
|
end
|
||||||
return output
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
def tackit(strings)
|
def tackit(strings)
|
||||||
case(strings)
|
case(strings)
|
||||||
when Array
|
when Array
|
||||||
"\"#{strings.join}\""
|
"\"#{strings.join}\""
|
||||||
when /^-/
|
when /^-/
|
||||||
strings
|
strings
|
||||||
when /\s/
|
when /\s/
|
||||||
"\"#{strings}\""
|
"\"#{strings}\""
|
||||||
else
|
else
|
||||||
strings
|
strings
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.set_root_path(File.expand_path(File.dirname(__FILE__)) + '/')
|
summary.set_root_path(File.expand_path(File.dirname(__FILE__)) + '/')
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||||
results_glob.gsub!(/\\/, '/')
|
results_glob.gsub!(/\\/, '/')
|
||||||
results = Dir[results_glob]
|
results = Dir[results_glob]
|
||||||
summary.set_targets(results)
|
summary.set_targets(results)
|
||||||
summary.run
|
summary.run
|
||||||
fail_out "FAIL: There were failures" if (summary.failures > 0)
|
fail_out "FAIL: There were failures" if (summary.failures > 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_system_test_interactions(test_case_files)
|
def run_system_test_interactions(test_case_files)
|
||||||
load './lib/cmock.rb'
|
load './lib/cmock.rb'
|
||||||
|
|
||||||
SystemTestGenerator.new.generate_files(test_case_files)
|
SystemTestGenerator.new.generate_files(test_case_files)
|
||||||
test_files = FileList.new(SYSTEST_GENERATED_FILES_PATH + 'test*.c')
|
test_files = FileList.new(SYSTEST_GENERATED_FILES_PATH + 'test*.c')
|
||||||
|
|
||||||
load_configuration($cfg_file)
|
load_configuration($cfg_file)
|
||||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||||
|
|
||||||
include_dirs = get_local_include_dirs
|
include_dirs = get_local_include_dirs
|
||||||
|
|
||||||
# Build and execute each unit test
|
# Build and execute each unit test
|
||||||
test_files.each do |test|
|
test_files.each do |test|
|
||||||
|
|
||||||
obj_list = []
|
obj_list = []
|
||||||
|
|
||||||
test_base = File.basename(test, C_EXTENSION)
|
test_base = File.basename(test, C_EXTENSION)
|
||||||
cmock_config = test_base.gsub(/test_/, '') + '_cmock.yml'
|
cmock_config = test_base.gsub(/test_/, '') + '_cmock.yml'
|
||||||
|
|
||||||
report "Executing system tests in #{File.basename(test)}..."
|
report "Executing system tests in #{File.basename(test)}..."
|
||||||
|
|
||||||
# Detect dependencies and build required required modules
|
# Detect dependencies and build required required modules
|
||||||
extract_headers(test).each do |header|
|
extract_headers(test).each do |header|
|
||||||
|
|
||||||
# Generate any needed mocks
|
# Generate any needed mocks
|
||||||
if header =~ /^mock_(.*)\.h/i
|
if header =~ /^mock_(.*)\.h/i
|
||||||
module_name = $1
|
module_name = $1
|
||||||
cmock = CMock.new(SYSTEST_GENERATED_FILES_PATH + cmock_config)
|
cmock = CMock.new(SYSTEST_GENERATED_FILES_PATH + cmock_config)
|
||||||
cmock.setup_mocks("#{$cfg['compiler']['source_path']}#{module_name}.h")
|
cmock.setup_mocks("#{$cfg['compiler']['source_path']}#{module_name}.h")
|
||||||
end
|
end
|
||||||
# Compile corresponding source file if it exists
|
# Compile corresponding source file if it exists
|
||||||
src_file = find_source_file(header, include_dirs)
|
src_file = find_source_file(header, include_dirs)
|
||||||
if !src_file.nil?
|
if !src_file.nil?
|
||||||
obj_list << compile(src_file)
|
obj_list << compile(src_file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generate and build the test suite runner
|
# Generate and build the test suite runner
|
||||||
runner_name = test_base + '_runner.c'
|
runner_name = test_base + '_runner.c'
|
||||||
runner_path = $cfg['compiler']['source_path'] + runner_name
|
runner_path = $cfg['compiler']['source_path'] + runner_name
|
||||||
UnityTestRunnerGenerator.new(SYSTEST_GENERATED_FILES_PATH + cmock_config).run(test, runner_path)
|
UnityTestRunnerGenerator.new(SYSTEST_GENERATED_FILES_PATH + cmock_config).run(test, runner_path)
|
||||||
obj_list << compile(runner_path)
|
obj_list << compile(runner_path)
|
||||||
|
|
||||||
# Build the test module
|
# Build the test module
|
||||||
obj_list << compile(test)
|
obj_list << compile(test)
|
||||||
|
|
||||||
# Link the test executable
|
# Link the test executable
|
||||||
link_it(test_base, obj_list)
|
link_it(test_base, obj_list)
|
||||||
|
|
||||||
# Execute unit test and generate results file
|
# Execute unit test and generate results file
|
||||||
simulator = build_simulator_fields
|
simulator = build_simulator_fields
|
||||||
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
||||||
if simulator.nil?
|
if simulator.nil?
|
||||||
cmd_str = executable
|
cmd_str = executable
|
||||||
else
|
else
|
||||||
cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
||||||
end
|
end
|
||||||
output = execute(cmd_str, false, false)
|
output = execute(cmd_str, false, false)
|
||||||
test_results = $cfg['compiler']['build_path'] + test_base + RESULT_EXTENSION
|
test_results = $cfg['compiler']['build_path'] + test_base + RESULT_EXTENSION
|
||||||
File.open(test_results, 'w') { |f| f.print output }
|
File.open(test_results, 'w') { |f| f.print output }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parse and report test results
|
# Parse and report test results
|
||||||
total_tests = 0
|
total_tests = 0
|
||||||
total_failures = 0
|
total_failures = 0
|
||||||
failure_messages = []
|
failure_messages = []
|
||||||
|
|
||||||
test_case_files.each do |test_case|
|
test_case_files.each do |test_case|
|
||||||
tests = (YAML.load_file(test_case))[:systest][:tests][:units]
|
tests = (YAML.load_file(test_case))[:systest][:tests][:units]
|
||||||
total_tests += tests.size
|
total_tests += tests.size
|
||||||
|
|
||||||
test_file = 'test_' + File.basename(test_case).ext(C_EXTENSION)
|
test_file = 'test_' + File.basename(test_case).ext(C_EXTENSION)
|
||||||
result_file = test_file.ext(RESULT_EXTENSION)
|
result_file = test_file.ext(RESULT_EXTENSION)
|
||||||
test_results = File.readlines(SYSTEST_BUILD_FILES_PATH + result_file).reject {|line| line.size < 10 } # we're rejecting lines that are too short to be realistic, which handles line ending problems
|
test_results = File.readlines(SYSTEST_BUILD_FILES_PATH + result_file).reject {|line| line.size < 10 } # we're rejecting lines that are too short to be realistic, which handles line ending problems
|
||||||
tests.each_with_index do |test, index|
|
tests.each_with_index do |test, index|
|
||||||
# compare test's intended pass/fail state with pass/fail state in actual results;
|
# compare test's intended pass/fail state with pass/fail state in actual results;
|
||||||
# if they don't match, the system test has failed
|
# if they don't match, the system test has failed
|
||||||
this_failed = case(test[:pass])
|
this_failed = case(test[:pass])
|
||||||
when :ignore
|
when :ignore
|
||||||
(test_results[index] =~ /:IGNORE/).nil?
|
(test_results[index] =~ /:IGNORE/).nil?
|
||||||
when true
|
when true
|
||||||
(test_results[index] =~ /:PASS/).nil?
|
(test_results[index] =~ /:PASS/).nil?
|
||||||
when false
|
when false
|
||||||
(test_results[index] =~ /:FAIL/).nil?
|
(test_results[index] =~ /:FAIL/).nil?
|
||||||
end
|
end
|
||||||
if (this_failed)
|
if (this_failed)
|
||||||
total_failures += 1
|
total_failures += 1
|
||||||
test_results[index] =~ /test#{index+1}:(.+)/
|
test_results[index] =~ /test#{index+1}:(.+)/
|
||||||
failure_messages << "#{test_file}:test#{index+1}:should #{test[:should]}:#{$1}"
|
failure_messages << "#{test_file}:test#{index+1}:should #{test[:should]}:#{$1}"
|
||||||
end
|
end
|
||||||
# some tests have additional requirements to check for (checking the actual output message)
|
# some tests have additional requirements to check for (checking the actual output message)
|
||||||
if (test[:verify_error]) and not (test_results[index] =~ /test#{index+1}:.*#{test[:verify_error]}/)
|
if (test[:verify_error]) and not (test_results[index] =~ /test#{index+1}:.*#{test[:verify_error]}/)
|
||||||
total_failures += 1
|
total_failures += 1
|
||||||
failure_messages << "#{test_file}:test#{index+1}:should #{test[:should]}:should have output matching '#{test[:verify_error]}'"
|
failure_messages << "#{test_file}:test#{index+1}:should #{test[:should]}:should have output matching '#{test[:verify_error]}' but was '#{test_results[index]}'"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
report "\n"
|
report "\n"
|
||||||
report "------------------------------------\n"
|
report "------------------------------------\n"
|
||||||
report "SYSTEM TEST MOCK INTERACTION SUMMARY\n"
|
report "SYSTEM TEST MOCK INTERACTION SUMMARY\n"
|
||||||
report "------------------------------------\n"
|
report "------------------------------------\n"
|
||||||
report "#{total_tests} Tests #{total_failures} Failures 0 Ignored\n"
|
report "#{total_tests} Tests #{total_failures} Failures 0 Ignored\n"
|
||||||
report "\n"
|
report "\n"
|
||||||
|
|
||||||
if (failure_messages.size > 0)
|
if (failure_messages.size > 0)
|
||||||
report 'System test failures:'
|
report 'System test failures:'
|
||||||
failure_messages.each do |failure|
|
failure_messages.each do |failure|
|
||||||
report failure
|
report failure
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
report ''
|
report ''
|
||||||
|
|
||||||
return total_failures
|
return total_failures
|
||||||
end
|
end
|
||||||
|
|
||||||
def profile_this(filename)
|
def profile_this(filename)
|
||||||
profile = true
|
profile = true
|
||||||
begin
|
begin
|
||||||
require 'ruby-prof'
|
require 'ruby-prof'
|
||||||
RubyProf.start
|
RubyProf.start
|
||||||
rescue
|
rescue
|
||||||
profile = false
|
profile = false
|
||||||
end
|
end
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
if (profile)
|
if (profile)
|
||||||
profile_result = RubyProf.stop
|
profile_result = RubyProf.stop
|
||||||
File.open("Profile_#{filename}.html", 'w') do |f|
|
File.open("Profile_#{filename}.html", 'w') do |f|
|
||||||
RubyProf::GraphHtmlPrinter.new(profile_result).print(f)
|
RubyProf::GraphHtmlPrinter.new(profile_result).print(f)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_system_test_compilations(mockables)
|
def run_system_test_compilations(mockables)
|
||||||
load './lib/cmock.rb'
|
load './lib/cmock.rb'
|
||||||
|
|
||||||
load_configuration($cfg_file)
|
load_configuration($cfg_file)
|
||||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||||
|
|
||||||
report "\n"
|
report "\n"
|
||||||
report "------------------------------------\n"
|
report "------------------------------------\n"
|
||||||
report "SYSTEM TEST MOCK COMPILATION SUMMARY\n"
|
report "SYSTEM TEST MOCK COMPILATION SUMMARY\n"
|
||||||
report "------------------------------------\n"
|
report "------------------------------------\n"
|
||||||
mockables.each do |header|
|
mockables.each do |header|
|
||||||
mock_filename = 'mock_' + File.basename(header).ext('.c')
|
mock_filename = 'mock_' + File.basename(header).ext('.c')
|
||||||
CMock.new(SYSTEST_COMPILE_MOCKABLES_PATH + 'config.yml').setup_mocks(header)
|
CMock.new(SYSTEST_COMPILE_MOCKABLES_PATH + 'config.yml').setup_mocks(header)
|
||||||
report "Compiling #{mock_filename}..."
|
report "Compiling #{mock_filename}..."
|
||||||
compile(SYSTEST_GENERATED_FILES_PATH + mock_filename)
|
compile(SYSTEST_GENERATED_FILES_PATH + mock_filename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_system_test_profiles(mockables)
|
def run_system_test_profiles(mockables)
|
||||||
load './lib/cmock.rb'
|
load './lib/cmock.rb'
|
||||||
|
|
||||||
load_configuration($cfg_file)
|
load_configuration($cfg_file)
|
||||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||||
|
|
||||||
report "\n"
|
report "\n"
|
||||||
report "--------------------------\n"
|
report "--------------------------\n"
|
||||||
report "SYSTEM TEST MOCK PROFILING\n"
|
report "SYSTEM TEST MOCK PROFILING\n"
|
||||||
report "--------------------------\n"
|
report "--------------------------\n"
|
||||||
mockables.each do |header|
|
mockables.each do |header|
|
||||||
mock_filename = 'mock_' + File.basename(header).ext('.c')
|
mock_filename = 'mock_' + File.basename(header).ext('.c')
|
||||||
profile_this(mock_filename.gsub('.c','')) do
|
profile_this(mock_filename.gsub('.c','')) do
|
||||||
10.times do
|
10.times do
|
||||||
CMock.new(SYSTEST_COMPILE_MOCKABLES_PATH + 'config.yml').setup_mocks(header)
|
CMock.new(SYSTEST_COMPILE_MOCKABLES_PATH + 'config.yml').setup_mocks(header)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
report "Compiling #{mock_filename}..."
|
report "Compiling #{mock_filename}..."
|
||||||
compile(SYSTEST_GENERATED_FILES_PATH + mock_filename)
|
compile(SYSTEST_GENERATED_FILES_PATH + mock_filename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_and_test_c_files
|
def build_and_test_c_files
|
||||||
report "\n"
|
report "\n"
|
||||||
report "----------------\n"
|
report "----------------\n"
|
||||||
report "UNIT TEST C CODE\n"
|
report "UNIT TEST C CODE\n"
|
||||||
report "----------------\n"
|
report "----------------\n"
|
||||||
errors = false
|
errors = false
|
||||||
FileList.new("test/c/*.yml").each do |yaml_file|
|
FileList.new("test/c/*.yml").each do |yaml_file|
|
||||||
test = YAML.load(File.read(yaml_file))
|
test = YAML.load(File.read(yaml_file))
|
||||||
report "\nTesting #{yaml_file.sub('.yml','')}"
|
report "\nTesting #{yaml_file.sub('.yml','')}"
|
||||||
report "(#{test[:options].join(', ')})"
|
report "(#{test[:options].join(', ')})"
|
||||||
test[:files].each { |f| compile(f, test[:options]) }
|
test[:files].each { |f| compile(f, test[:options]) }
|
||||||
obj_files = test[:files].map { |f| f.gsub!(/.*\//,'').gsub!(C_EXTENSION, $cfg['compiler']['object_files']['extension']) }
|
obj_files = test[:files].map { |f| f.gsub!(/.*\//,'').gsub!(C_EXTENSION, $cfg['compiler']['object_files']['extension']) }
|
||||||
link_it('TestCMockC', obj_files)
|
link_it('TestCMockC', obj_files)
|
||||||
if $cfg['simulator'].nil?
|
if $cfg['simulator'].nil?
|
||||||
execute($cfg['linker']['bin_files']['destination'] + 'TestCMockC' + $cfg['linker']['bin_files']['extension'])
|
execute($cfg['linker']['bin_files']['destination'] + 'TestCMockC' + $cfg['linker']['bin_files']['extension'])
|
||||||
else
|
else
|
||||||
execute(tackit($cfg['simulator']['path'].join) + ' ' +
|
execute(tackit($cfg['simulator']['path'].join) + ' ' +
|
||||||
$cfg['simulator']['pre_support'].map{|o| tackit(o)}.join(' ') + ' ' +
|
$cfg['simulator']['pre_support'].map{|o| tackit(o)}.join(' ') + ' ' +
|
||||||
$cfg['linker']['bin_files']['destination'] +
|
$cfg['linker']['bin_files']['destination'] +
|
||||||
'TestCMockC' +
|
'TestCMockC' +
|
||||||
$cfg['linker']['bin_files']['extension'] + ' ' +
|
$cfg['linker']['bin_files']['extension'] + ' ' +
|
||||||
$cfg['simulator']['post_support'].map{|o| tackit(o)}.join(' ') )
|
$cfg['simulator']['post_support'].map{|o| tackit(o)}.join(' ') )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fail_out(msg)
|
def fail_out(msg)
|
||||||
puts msg
|
puts msg
|
||||||
exit(-1)
|
exit(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,272 +1,308 @@
|
|||||||
---
|
---
|
||||||
:cmock:
|
:cmock:
|
||||||
:enforce_strict_ordering: 1
|
:enforce_strict_ordering: 1
|
||||||
:plugins:
|
:plugins:
|
||||||
- :array
|
- :array
|
||||||
- :cexception
|
- :cexception
|
||||||
- :ignore
|
- :ignore
|
||||||
- :callback
|
- :callback
|
||||||
- :return_thru_ptr
|
- :return_thru_ptr
|
||||||
- :ignore_arg
|
- :ignore_arg
|
||||||
- :expect_any_args
|
- :expect_any_args
|
||||||
:callback_after_arg_check: false
|
:callback_after_arg_check: false
|
||||||
:callback_include_count: false
|
:callback_include_count: false
|
||||||
:treat_externs: :include
|
:treat_externs: :include
|
||||||
|
|
||||||
:systest:
|
:systest:
|
||||||
:types: |
|
:types: |
|
||||||
typedef struct _POINT_T {
|
typedef struct _POINT_T {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
} POINT_T;
|
} POINT_T;
|
||||||
|
|
||||||
:mockable: |
|
:mockable: |
|
||||||
#include "CException.h"
|
#include "CException.h"
|
||||||
extern void foo(POINT_T* a);
|
extern void foo(POINT_T* a);
|
||||||
POINT_T* bar(void);
|
POINT_T* bar(void);
|
||||||
void no_args(void);
|
void no_args(void);
|
||||||
|
|
||||||
:source:
|
:source:
|
||||||
:header: |
|
:header: |
|
||||||
#include "CException.h"
|
#include "CException.h"
|
||||||
void function_a(void);
|
void function_a(void);
|
||||||
void function_b(void);
|
int function_b(void);
|
||||||
void function_c(void);
|
|
||||||
int function_d(void);
|
:code: |
|
||||||
void function_e(void);
|
void function_a(void)
|
||||||
|
{
|
||||||
:code: |
|
foo(bar());
|
||||||
void function_a(void)
|
no_args();
|
||||||
{
|
}
|
||||||
foo(bar());
|
|
||||||
no_args();
|
int function_b(void)
|
||||||
}
|
{
|
||||||
|
POINT_T pt = { 1, 2 };
|
||||||
:tests:
|
foo(&pt);
|
||||||
:common: |
|
return (pt.x + pt.y);
|
||||||
#include "CException.h"
|
}
|
||||||
void setUp(void) {}
|
|
||||||
void tearDown(void) {}
|
:tests:
|
||||||
void my_foo_callback(POINT_T* a) { TEST_ASSERT_EQUAL_INT(2, a->x); }
|
:common: |
|
||||||
|
#include "CException.h"
|
||||||
:units:
|
void setUp(void) {}
|
||||||
- :pass: TRUE
|
void tearDown(void) {}
|
||||||
:should: 'just pass if we do not insert anything ugly into it'
|
void my_foo_callback(POINT_T* a) { TEST_ASSERT_EQUAL_INT(2, a->x); }
|
||||||
:code: |
|
|
||||||
test()
|
:units:
|
||||||
{
|
- :pass: TRUE
|
||||||
bar_ExpectAndReturn(NULL);
|
:should: 'just pass if we do not insert anything ugly into it'
|
||||||
foo_Expect(NULL);
|
:code: |
|
||||||
no_args_Expect();
|
test()
|
||||||
|
{
|
||||||
function_a();
|
bar_ExpectAndReturn(NULL);
|
||||||
}
|
foo_Expect(NULL);
|
||||||
|
no_args_Expect();
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after an expect and return'
|
function_a();
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after an expect and return'
|
||||||
bar_ExpectAndReturn(NULL);
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
:code: |
|
||||||
foo_Expect(NULL);
|
test()
|
||||||
no_args_Expect();
|
{
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
function_a();
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
}
|
foo_Expect(NULL);
|
||||||
|
no_args_Expect();
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after an expect'
|
function_a();
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after an expect'
|
||||||
bar_ExpectAndReturn(NULL);
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
foo_Expect(NULL);
|
:code: |
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
test()
|
||||||
no_args_Expect();
|
{
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
function_a();
|
foo_Expect(NULL);
|
||||||
}
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
no_args_Expect();
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after throw expectation'
|
function_a();
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after throw expectation'
|
||||||
CEXCEPTION_T e;
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
bar_ExpectAndReturn(NULL);
|
test()
|
||||||
foo_Expect(NULL);
|
{
|
||||||
no_args_ExpectAndThrow(5);
|
CEXCEPTION_T e;
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
|
||||||
|
bar_ExpectAndReturn(NULL);
|
||||||
Try { function_a(); } Catch(e) {}
|
foo_Expect(NULL);
|
||||||
}
|
no_args_ExpectAndThrow(5);
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after a mock call'
|
Try { function_a(); } Catch(e) {}
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after a mock call'
|
||||||
bar_ExpectAndReturn(NULL);
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
foo_Expect(NULL);
|
:code: |
|
||||||
no_args_Expect();
|
test()
|
||||||
|
{
|
||||||
function_a();
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
no_args_Expect();
|
||||||
}
|
|
||||||
|
function_a();
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after throw'
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after throw'
|
||||||
CEXCEPTION_T e;
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
bar_ExpectAndReturn(NULL);
|
test()
|
||||||
foo_Expect(NULL);
|
{
|
||||||
no_args_ExpectAndThrow(5);
|
CEXCEPTION_T e;
|
||||||
|
|
||||||
Try { function_a(); } Catch(e) {}
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
no_args_ExpectAndThrow(5);
|
||||||
}
|
|
||||||
|
Try { function_a(); } Catch(e) {}
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after ignore'
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after ignore'
|
||||||
bar_ExpectAndReturn(NULL);
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
foo_Expect(NULL);
|
:code: |
|
||||||
no_args_Ignore();
|
test()
|
||||||
|
{
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
function_a();
|
no_args_Ignore();
|
||||||
}
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after ignored mock'
|
function_a();
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after ignored mock'
|
||||||
bar_ExpectAndReturn(NULL);
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
foo_Expect(NULL);
|
:code: |
|
||||||
no_args_Ignore();
|
test()
|
||||||
|
{
|
||||||
function_a();
|
bar_ExpectAndReturn(NULL);
|
||||||
|
foo_Expect(NULL);
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
no_args_Ignore();
|
||||||
}
|
|
||||||
|
function_a();
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after callback setup'
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after callback setup'
|
||||||
POINT_T pt = { 2, 2 };
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
bar_ExpectAndReturn(&pt);
|
:code: |
|
||||||
foo_StubWithCallback(my_foo_callback);
|
test()
|
||||||
|
{
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
POINT_T pt = { 2, 2 };
|
||||||
|
bar_ExpectAndReturn(&pt);
|
||||||
no_args_Expect();
|
foo_StubWithCallback(my_foo_callback);
|
||||||
|
|
||||||
function_a();
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
}
|
|
||||||
|
no_args_Expect();
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after mock with callback'
|
function_a();
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after mock with callback'
|
||||||
POINT_T pt = { 2, 2 };
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
bar_ExpectAndReturn(&pt);
|
:code: |
|
||||||
foo_StubWithCallback(my_foo_callback);
|
test()
|
||||||
no_args_Expect();
|
{
|
||||||
|
POINT_T pt = { 2, 2 };
|
||||||
function_a();
|
bar_ExpectAndReturn(&pt);
|
||||||
|
foo_StubWithCallback(my_foo_callback);
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
no_args_Expect();
|
||||||
}
|
|
||||||
|
function_a();
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after expect any args'
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after expect any args'
|
||||||
POINT_T pt = { 2, 2 };
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
bar_ExpectAndReturn(&pt);
|
:code: |
|
||||||
foo_ExpectAnyArgs();
|
test()
|
||||||
|
{
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
POINT_T pt = { 2, 2 };
|
||||||
|
bar_ExpectAndReturn(&pt);
|
||||||
no_args_Expect();
|
foo_ExpectAnyArgs();
|
||||||
|
|
||||||
function_a();
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
}
|
|
||||||
|
no_args_Expect();
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after mock which expected any args'
|
function_a();
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after mock which expected any args'
|
||||||
POINT_T pt = { 2, 2 };
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
bar_ExpectAndReturn(&pt);
|
:code: |
|
||||||
foo_ExpectAnyArgs();
|
test()
|
||||||
no_args_Expect();
|
{
|
||||||
|
POINT_T pt = { 2, 2 };
|
||||||
function_a();
|
bar_ExpectAndReturn(&pt);
|
||||||
|
foo_ExpectAnyArgs();
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
no_args_Expect();
|
||||||
}
|
|
||||||
|
function_a();
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after ignored arg'
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after ignored arg'
|
||||||
POINT_T pt = { 2, 2 };
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
bar_ExpectAndReturn(&pt);
|
:code: |
|
||||||
foo_Expect(NULL);
|
test()
|
||||||
foo_IgnoreArg_a();
|
{
|
||||||
|
POINT_T pt = { 2, 2 };
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
bar_ExpectAndReturn(&pt);
|
||||||
|
foo_Expect(NULL);
|
||||||
no_args_Expect();
|
foo_IgnoreArg_a();
|
||||||
|
|
||||||
function_a();
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
}
|
|
||||||
|
no_args_Expect();
|
||||||
- :pass: FALSE
|
|
||||||
:should: 'not contain mock details in failed assertion after mock which ignored an arg'
|
function_a();
|
||||||
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
}
|
||||||
:code: |
|
|
||||||
test()
|
- :pass: FALSE
|
||||||
{
|
:should: 'not contain mock details in failed assertion after mock which ignored an arg'
|
||||||
POINT_T pt = { 2, 2 };
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
bar_ExpectAndReturn(&pt);
|
:code: |
|
||||||
foo_Expect(NULL);
|
test()
|
||||||
foo_IgnoreArg_a();
|
{
|
||||||
no_args_Expect();
|
POINT_T pt = { 2, 2 };
|
||||||
|
bar_ExpectAndReturn(&pt);
|
||||||
function_a();
|
foo_Expect(NULL);
|
||||||
|
foo_IgnoreArg_a();
|
||||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
no_args_Expect();
|
||||||
}
|
|
||||||
|
function_a();
|
||||||
...
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after mock which threw a CException'
|
||||||
|
:verify_error: 'FAIL: Expected 1 Was 2. CustomFail'
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
CEXCEPTION_T e;
|
||||||
|
bar_ExpectAndThrow(0x12);
|
||||||
|
|
||||||
|
Try {
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
|
Catch(e) {}
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT_MESSAGE(1,2,"CustomFail");
|
||||||
|
}
|
||||||
|
|
||||||
|
- :pass: FALSE
|
||||||
|
:should: 'not contain mock details in failed assertion after mock which used a return thru ptr'
|
||||||
|
#:verify_error: 'FAIL: Expected 3 Was 7. CustomFail' #TODO: put back in once ReturnThruPtr fixed
|
||||||
|
:code: |
|
||||||
|
test()
|
||||||
|
{
|
||||||
|
POINT_T pt1 = { 1, 2 };
|
||||||
|
POINT_T pt2 = { 3, 4 };
|
||||||
|
|
||||||
|
foo_Expect(&pt1);
|
||||||
|
foo_ReturnThruPtr_a(&pt2);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT(3, function_b());
|
||||||
|
}
|
||||||
|
|
||||||
|
...
|
||||||
|
|||||||
Reference in New Issue
Block a user