Update to latest version of Unity

This commit is contained in:
Mark VanderVoord
2014-03-17 10:46:43 -04:00
parent d0d87d9436
commit 2e3744f748
4 changed files with 42 additions and 42 deletions
+38 -38
View File
@@ -2,7 +2,7 @@
# CMock Project - Automatic Mock Generation for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
# ==========================================
require 'yaml'
require 'fileutils'
@@ -18,23 +18,23 @@ module RakefileHelpers
SYSTEST_COMPILE_MOCKABLES_PATH = 'test/system/test_compilation/'
C_EXTENSION = '.c'
RESULT_EXTENSION = '.result'
def load_configuration(config_file)
$cfg_file = config_file
$cfg = YAML.load(File.read('./targets/' + $cfg_file))
$colour_output = false unless $cfg['colour']
end
def configure_clean
CLEAN.include(SYSTEST_GENERATED_FILES_PATH + '*.*')
CLEAN.include(SYSTEST_BUILD_FILES_PATH + '*.*')
end
def configure_toolchain(config_file)
load_configuration(config_file)
configure_clean
end
def get_local_include_dirs
include_dirs = $cfg['compiler']['includes']['items'].dup
include_dirs.delete_if {|dir| dir.is_a?(Array)}
@@ -90,7 +90,7 @@ module RakefileHelpers
execute(cmd_str + obj_file)
return obj_file
end
def build_linker_fields
command = tackit($cfg['linker']['path'])
if $cfg['linker']['options'].nil?
@@ -106,7 +106,7 @@ module RakefileHelpers
includes = includes.gsub(/\\ /, ' ').gsub(/\\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
return {:command => command, :options => options, :includes => includes}
end
def link_it(exe_name, obj_list)
linker = build_linker_fields
cmd_str = "#{linker[:command]}#{linker[:options]}#{linker[:includes]} " +
@@ -116,7 +116,7 @@ module RakefileHelpers
exe_name + $cfg['linker']['bin_files']['extension']
execute(cmd_str)
end
def build_simulator_fields
return nil if $cfg['simulator'].nil?
if $cfg['simulator']['path'].nil?
@@ -136,7 +136,7 @@ module RakefileHelpers
end
return {:command => command, :pre_support => pre_support, :post_support => post_support}
end
def execute(command_string, verbose=true, raise_on_failure=true)
#report command_string
output = `#{command_string}`.chomp
@@ -146,7 +146,7 @@ module RakefileHelpers
end
return output
end
def tackit(strings)
case(strings)
when Array
@@ -159,7 +159,7 @@ module RakefileHelpers
strings
end
end
def report_summary
summary = UnityTestSummary.new
summary.set_root_path(File.expand_path(File.dirname(__FILE__)) + '/')
@@ -170,28 +170,28 @@ module RakefileHelpers
summary.run
fail_out "FAIL: There were failures" if (summary.failures > 0)
end
def run_system_test_interactions(test_case_files)
load './lib/cmock.rb'
SystemTestGenerator.new.generate_files(test_case_files)
test_files = FileList.new(SYSTEST_GENERATED_FILES_PATH + 'test*.c')
load_configuration($cfg_file)
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
include_dirs = get_local_include_dirs
# Build and execute each unit test
test_files.each do |test|
obj_list = []
test_base = File.basename(test, C_EXTENSION)
cmock_config = test_base.gsub(/test_/, '') + '_cmock.yml'
report "Executing system tests in #{File.basename(test)}..."
# Detect dependencies and build required required modules
extract_headers(test).each do |header|
@@ -213,13 +213,13 @@ module RakefileHelpers
runner_path = $cfg['compiler']['source_path'] + runner_name
UnityTestRunnerGenerator.new(SYSTEST_GENERATED_FILES_PATH + cmock_config).run(test, runner_path)
obj_list << compile(runner_path)
# Build the test module
obj_list << compile(test)
# Link the test executable
link_it(test_base, obj_list)
# Execute unit test and generate results file
simulator = build_simulator_fields
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
@@ -232,19 +232,19 @@ module RakefileHelpers
test_results = $cfg['compiler']['build_path'] + test_base + RESULT_EXTENSION
File.open(test_results, 'w') { |f| f.print output }
end
# Parse and report test results
total_tests = 0
total_failures = 0
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]
total_tests += tests.size
test_file = 'test_' + File.basename(test_case).ext(C_EXTENSION)
result_file = test_file.ext(RESULT_EXTENSION)
test_results = File.readlines(SYSTEST_BUILD_FILES_PATH + result_file)
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|
# compare test's intended pass/fail state with pass/fail state in actual results;
# if they don't match, the system test has failed
@@ -268,26 +268,26 @@ module RakefileHelpers
end
end
end
report "\n"
report "------------------------------------\n"
report "SYSTEM TEST MOCK INTERACTION SUMMARY\n"
report "------------------------------------\n"
report "#{total_tests} Tests #{total_failures} Failures 0 Ignored\n"
report "\n"
if (failure_messages.size > 0)
report 'System test failures:'
failure_messages.each do |failure|
report failure
end
end
report ''
return total_failures
end
def profile_this(filename)
profile = true
begin
@@ -296,9 +296,9 @@ module RakefileHelpers
rescue
profile = false
end
yield
if (profile)
profile_result = RubyProf.stop
File.open("Profile_#{filename}.html", 'w') do |f|
@@ -306,10 +306,10 @@ module RakefileHelpers
end
end
end
def run_system_test_compilations(mockables)
load './lib/cmock.rb'
load_configuration($cfg_file)
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
@@ -324,10 +324,10 @@ module RakefileHelpers
compile(SYSTEST_GENERATED_FILES_PATH + mock_filename)
end
end
def run_system_test_profiles(mockables)
load './lib/cmock.rb'
load_configuration($cfg_file)
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
@@ -337,8 +337,8 @@ module RakefileHelpers
report "--------------------------\n"
mockables.each do |header|
mock_filename = 'mock_' + File.basename(header).ext('.c')
profile_this(mock_filename.gsub('.c','')) do
10.times do
profile_this(mock_filename.gsub('.c','')) do
10.times do
CMock.new(SYSTEST_COMPILE_MOCKABLES_PATH + 'config.yml').setup_mocks(header)
end
end
@@ -346,7 +346,7 @@ module RakefileHelpers
compile(SYSTEST_GENERATED_FILES_PATH + mock_filename)
end
end
def build_and_test_c_files
report "\n"
report "----------------\n"
@@ -372,7 +372,7 @@ module RakefileHelpers
end
end
end
def fail_out(msg)
puts msg
exit(-1)
+2 -2
View File
@@ -20,9 +20,9 @@ extern void test_ThatWeCanAskForAllSortsOfSizes(void);
int main(void)
{
Unity.TestFile = "TestCMockDynamic.c";
UnityBegin();
Unity.TestFile = "TestCMockDynamic.c";
RUN_TEST(test_MemNewWillReturnNullIfGivenIllegalSizes, 26);
RUN_TEST(test_MemNewWillNowSupportSizesGreaterThanTheDefinesCMockSize, 35);
RUN_TEST(test_MemChainWillReturnNullAndDoNothingIfGivenIllegalInformation, 45);
+1 -1
View File
@@ -22,8 +22,8 @@ extern void test_ThatWeCanAskForAllSortsOfSizes(void);
int main(void)
{
Unity.TestFile = "TestCMock.c";
UnityBegin();
Unity.TestFile = "TestCMock.c";
RUN_TEST(test_MemNewWillReturnNullIfGivenIllegalSizes, 21);
RUN_TEST(test_MemChainWillReturnNullAndDoNothingIfGivenIllegalInformation, 32);
+1 -1