提交 8fb02040 编写于 作者: M mvandervoord

Examples and main tests can be run on GCC or IAR now

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@5 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
上级 d1550d84
......@@ -6,15 +6,23 @@ require 'fileutils'
require 'set'
require '../auto/unity_test_summary'
require '../auto/generate_test_runner'
require 'rakefile_helper'
#USE THIS ONE IF YOU WANT TO TRY THIS WITH GCC
#require 'rakefile_helper_GCC'
#USE THIS ONE IF YOU WANT TO TRY THIS WITH IAR
require 'rakefile_helper_IAR'
include RakefileHelpers
#This tells us where to clean our temporary files
CLEAN.include('build/*')
desc "Build and run all tests, then output results (you can just type \"rake\" to get this."
#This is what is run when you type rake with no params
desc "Build and run all tests, then output results (you can just type \"rake\" to get this)."
task :default => [:clobber, :all, :summary]
#This runs our test summary
task :summary do
flush_output
summary = UnityTestSummary.new
......@@ -23,6 +31,7 @@ task :summary do
summary.run
end
#This builds and runs all the unit tests
task :all do
puts "Starting Test Suite"
runner_generator = UnityTestRunnerGenerator.new
......
#This rakefile sets you up to use GCC as your compiler for tests
module RakefileConstants
C_EXTENSION = '.c'
OBJ_EXTENSION = '.obj'
BIN_EXTENSION = '.exe'
UNIT_TEST_PATH = 'test'
UNITY_PATH = '../src'
SOURCE_PATH = 'src'
BUILD_PATH = 'build'
UNITY_SRC = UNITY_PATH + '\unity.c'
UNITY_HDR = UNITY_PATH + '\unity.h'
COMPILER = 'gcc.exe'
LINKER = 'gcc.exe'
end
module RakefileHelpers
include RakefileConstants
def flush_output
$stderr.flush
$stdout.flush
end
def report message
puts message
flush_output
end
def compile src, obj
execute "#{COMPILER} -c -I#{SOURCE_PATH} -I#{UNITY_PATH} -DTEST #{src} -o#{obj}"
end
def link prerequisites, executable
execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o#{executable}"
end
def run_test executable
execute "\"#{executable}\""
end
def write_result_file filename, results
if (results.include?("OK\n"))
output_file = filename.gsub(BIN_EXTENSION, '.testpass')
else
output_file = filename.gsub(BIN_EXTENSION, '.testfail')
end
File.open(output_file, 'w') do |f|
f.print results
end
end
private #####################
def execute command_string
report command_string
output = `#{command_string}`
report output
output
end
end
HERE = File.expand_path( File.dirname( __FILE__ ) ).gsub(/\//, '\\')
#This rakefile sets you up to use IAR System's C Compiler and Simulator for your tests.
module RakefileConstants
PROGRAM_FILES_PATH = ENV['ProgramFiles']
begin
begin #If You installed the real thing
Dir.new PROGRAM_FILES_PATH + '\IAR Systems\Embedded Workbench 4.0\arm'
IAR_ROOT = PROGRAM_FILES_PATH + '\IAR Systems\Embedded Workbench 4.0'
rescue
rescue #Or If you installed the kick-start version
Dir.new PROGRAM_FILES_PATH + '\IAR Systems\Embedded Workbench 4.0 Kickstart\arm'
IAR_ROOT = PROGRAM_FILES_PATH + '\IAR Systems\Embedded Workbench 4.0 Kickstart'
end
......@@ -21,7 +20,6 @@ module RakefileConstants
BUILD_PATH = 'build'
IAR_PATH = IAR_ROOT + '\common'
IAR_BIN = IAR_PATH + '\bin'
IAR_INCLUDE = IAR_PATH + '\inc'
IAR_CORE_PATH = IAR_ROOT + '\arm'
IAR_CORE_BIN = IAR_CORE_PATH + '\bin'
IAR_CORE_CONFIG = IAR_CORE_PATH + '\config'
......@@ -30,7 +28,6 @@ module RakefileConstants
IAR_CORE_LIB = IAR_CORE_PATH + '\lib'
IAR_CORE_DLIB = IAR_CORE_LIB + '\dl5tpannl8n.r79'
IAR_CORE_DLIB_CONFIG = IAR_CORE_LIB + '\dl5tpannl8n.h'
IAR_PROCESSOR_SPECIFIC_PATH = HERE + '\proc'
SIMULATOR_PROCESSOR = IAR_CORE_BIN + '\armproc.dll'
SIMULATOR_DRIVER = IAR_CORE_BIN + '\armsim.dll'
SIMULATOR_PLUGIN = IAR_CORE_BIN + '\armbat.dll'
......@@ -40,11 +37,6 @@ module RakefileConstants
UNITY_SRC = UNITY_PATH + '\unity.c'
UNITY_HDR = UNITY_PATH + '\unity.h'
UNITY_OBJ = BUILD_PATH + '\unity' + OBJ_EXTENSION
UNITY_TEST_OBJ = BUILD_PATH + '\testunity' + OBJ_EXTENSION
UNITY_TEST_RUNNER_OBJ = BUILD_PATH + '\testunity_Runner' + OBJ_EXTENSION
UNITY_TEST_EXEC = UNITY_TEST_OBJ.ext BIN_EXTENSION
TEST_RESULTS = UNITY_TEST_OBJ.ext '.testpass'
COMPILER = IAR_CORE_BIN + '\iccarm.exe'
LINKER = IAR_BIN + '\xlink.exe'
......
......@@ -5,7 +5,12 @@ require 'rake/loaders/makefile'
require 'fileutils'
require 'set'
require 'auto/unity_test_summary'
require 'rakefile_helper'
#USE THIS ONE IF YOU WANT TO TRY THIS WITH GCC
require 'rakefile_helper_GCC'
#USE THIS ONE IF YOU WANT TO TRY THIS WITH IAR
#require 'rakefile_helper_IAR'
include RakefileHelpers
......
#This rakefile sets you up to use GCC as your compiler for tests
module RakefileConstants
C_EXTENSION = '.c'
OBJ_EXTENSION = '.obj'
BIN_EXTENSION = '.exe'
UNIT_TEST_PATH = 'test'
UNITY_PATH = 'src'
SOURCE_PATH = 'src'
BUILD_PATH = 'build'
UNITY_SRC = UNITY_PATH + '\unity.c'
UNITY_HDR = UNITY_PATH + '\unity.h'
BIN_PATH = 'build'
UNITY_TEST_SRC = UNIT_TEST_PATH + '\testunity.c'
UNITY_TEST_RUNNER_SRC = UNIT_TEST_PATH + '\testunity_Runner.c'
UNITY_OBJ = BIN_PATH + '\unity' + OBJ_EXTENSION
UNITY_TEST_OBJ = BIN_PATH + '\testunity' + OBJ_EXTENSION
UNITY_TEST_RUNNER_OBJ = BIN_PATH + '\testunity_Runner' + OBJ_EXTENSION
UNITY_TEST_EXEC = UNITY_TEST_OBJ.ext BIN_EXTENSION
TEST_RESULTS = UNITY_TEST_OBJ.ext '.testpass'
COMPILER = 'gcc.exe'
LINKER = 'gcc.exe'
end
module RakefileHelpers
include RakefileConstants
def flush_output
$stderr.flush
$stdout.flush
end
def report message
puts message
flush_output
end
def compile src, obj
execute "#{COMPILER} -c -I#{SOURCE_PATH} -I#{UNITY_PATH} -DTEST #{src} -o#{obj}"
end
def link prerequisites, executable
execute "#{LINKER} -DTEST #{prerequisites.join(' ')} -o#{executable}"
end
def run_test executable
execute "\"#{executable}\""
end
def write_result_file filename, results
if (results.include?("OK\n"))
output_file = filename.gsub(BIN_EXTENSION, '.testpass')
else
output_file = filename.gsub(BIN_EXTENSION, '.testfail')
end
File.open(output_file, 'w') do |f|
f.print results
end
end
private #####################
def execute command_string
report command_string
output = `#{command_string}`
report output
output
end
end
HERE = File.expand_path( File.dirname( __FILE__ ) ).gsub(/\//, '\\')
#This rakefile sets you up to use IAR System's C Compiler and Simulator for your tests.
module RakefileConstants
PROGRAM_FILES_PATH = ENV['ProgramFiles']
begin
begin #If You installed the real thing
Dir.new PROGRAM_FILES_PATH + '\IAR Systems\Embedded Workbench 4.0\arm'
IAR_ROOT = PROGRAM_FILES_PATH + '\IAR Systems\Embedded Workbench 4.0'
rescue
rescue #Or If you installed the kick-start version
Dir.new PROGRAM_FILES_PATH + '\IAR Systems\Embedded Workbench 4.0 Kickstart\arm'
IAR_ROOT = PROGRAM_FILES_PATH + '\IAR Systems\Embedded Workbench 4.0 Kickstart'
end
......@@ -16,11 +15,12 @@ module RakefileConstants
BIN_EXTENSION = '.d79'
UNIT_TEST_PATH = 'test'
UNITY_PATH = 'src'
SOURCE_PATH = 'src'
BUILD_PATH = 'build'
BIN_PATH = 'build'
IAR_PATH = IAR_ROOT + '\common'
IAR_BIN = IAR_PATH + '\bin'
IAR_INCLUDE = IAR_PATH + '\inc'
IAR_CORE_PATH = IAR_ROOT + '\arm'
IAR_CORE_BIN = IAR_CORE_PATH + '\bin'
IAR_CORE_CONFIG = IAR_CORE_PATH + '\config'
......@@ -29,7 +29,6 @@ module RakefileConstants
IAR_CORE_LIB = IAR_CORE_PATH + '\lib'
IAR_CORE_DLIB = IAR_CORE_LIB + '\dl5tpannl8n.r79'
IAR_CORE_DLIB_CONFIG = IAR_CORE_LIB + '\dl5tpannl8n.h'
IAR_PROCESSOR_SPECIFIC_PATH = HERE + '\proc'
SIMULATOR_PROCESSOR = IAR_CORE_BIN + '\armproc.dll'
SIMULATOR_DRIVER = IAR_CORE_BIN + '\armsim.dll'
SIMULATOR_PLUGIN = IAR_CORE_BIN + '\armbat.dll'
......@@ -37,8 +36,8 @@ module RakefileConstants
PROCESSOR_TYPE = "ARM926EJ-S"
LINKER_CONFIG = IAR_CORE_CONFIG + '\lnkarm.xcl'
UNITY_SRC = SOURCE_PATH + '\unity.c'
UNITY_HDR = SOURCE_PATH + '\unity.h'
UNITY_SRC = UNITY_PATH + '\unity.c'
UNITY_HDR = UNITY_PATH + '\unity.h'
UNITY_TEST_SRC = UNIT_TEST_PATH + '\testunity.c'
UNITY_TEST_RUNNER_SRC = UNIT_TEST_PATH + '\testunity_Runner.c'
UNITY_OBJ = BIN_PATH + '\unity' + OBJ_EXTENSION
......@@ -67,7 +66,7 @@ module RakefileHelpers
end
def compile src, obj
execute "#{COMPILER} --dlib_config \"#{IAR_CORE_DLIB_CONFIG}\" -z3 --no_cse --no_unroll --no_inline --no_code_motion --no_tbaa --no_clustering --no_scheduling --debug --cpu_mode arm --endian little --cpu #{PROCESSOR_TYPE} --stack_align 4 -e --fpu None --diag_suppress Pa050 --diag_suppress Pe111 -I\"#{IAR_CORE_INCLUDE}\" -Isrc -Itest #{src} -o#{obj}"
execute "#{COMPILER} --dlib_config \"#{IAR_CORE_DLIB_CONFIG}\" -z3 --no_cse --no_unroll --no_inline --no_code_motion --no_tbaa --no_clustering --no_scheduling --debug --cpu_mode arm --endian little --cpu #{PROCESSOR_TYPE} --stack_align 4 -e --fpu None --diag_suppress Pa050 --diag_suppress Pe111 -I\"#{IAR_CORE_INCLUDE}\" -I\"#{UNITY_PATH}\" -Isrc -Itest #{src} -o#{obj}"
end
def link prerequisites, executable
......@@ -78,7 +77,18 @@ module RakefileHelpers
execute "\"#{SIMULATOR}\" --silent \"#{SIMULATOR_PROCESSOR}\" \"#{SIMULATOR_DRIVER}\" #{executable} --plugin \"#{SIMULATOR_PLUGIN}\" --backend -B --cpu #{PROCESSOR_TYPE} -p \"#{SIMULATOR_BACKEND_DDF}\" -d sim"
end
private
def write_result_file filename, results
if (results.include?("OK\n"))
output_file = filename.gsub(BIN_EXTENSION, '.testpass')
else
output_file = filename.gsub(BIN_EXTENSION, '.testfail')
end
File.open(output_file, 'w') do |f|
f.print results
end
end
private #####################
def execute command_string
report command_string
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册