mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-09-14 14:19:58 +00:00
Tidy handling of system tests to depend more on the defines involved then separate tracking.
Remove yml files that are no longer needed.
This commit is contained in:
+1
-1
@@ -39,7 +39,7 @@ CMOCK_MEM_INDEX_TYPE CMock_Guts_MemEndOfChain(CMOCK_MEM_INDEX_TYPE root_index)
|
|||||||
|
|
||||||
void* CMock_Guts_GetAddressFor(CMOCK_MEM_INDEX_TYPE index) CMOCK_FUNCTION_ATTR(pure);
|
void* CMock_Guts_GetAddressFor(CMOCK_MEM_INDEX_TYPE index) CMOCK_FUNCTION_ATTR(pure);
|
||||||
|
|
||||||
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesCapacity(void) CMOCK_FUNCTION_ATTR(const);
|
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesCapacity(void) CMOCK_FUNCTION_ATTR(const);
|
||||||
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesFree(void) CMOCK_FUNCTION_ATTR(pure);
|
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesFree(void) CMOCK_FUNCTION_ATTR(pure);
|
||||||
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesUsed(void) CMOCK_FUNCTION_ATTR(pure);
|
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesUsed(void) CMOCK_FUNCTION_ATTR(pure);
|
||||||
void CMock_Guts_MemFreeAll(void);
|
void CMock_Guts_MemFreeAll(void);
|
||||||
|
|||||||
+29
-42
@@ -50,18 +50,21 @@ task :test => ['test:all']
|
|||||||
|
|
||||||
namespace :test do
|
namespace :test do
|
||||||
desc "Run all unit, c, and system tests"
|
desc "Run all unit, c, and system tests"
|
||||||
task :all => [:config_toolchains, :clobber, :prep_system_tests, 'test:units', 'test:c', 'test:system']
|
task :all => [:config_toolchains, :clobber, :prep_system_tests, 'test:unit', 'test:c', 'test:system']
|
||||||
|
|
||||||
desc "Run Unit Tests"
|
desc "Run Unit Tests"
|
||||||
task :units => [:config_toolchains, :prep_system_tests] do
|
task :unit => [:config_toolchains, :prep_system_tests] do
|
||||||
run_ruby_unit_tests
|
run_ruby_unit_tests
|
||||||
end
|
end
|
||||||
|
|
||||||
#individual unit tests
|
#individual unit tests
|
||||||
FileList['unit/*_test.rb'].each do |test|
|
namespace :unit do
|
||||||
Rake::TestTask.new(File.basename(test,'.*').sub('_test','') => [:config_toolchains]) do |t|
|
FileList['unit/*_test.rb'].each do |test|
|
||||||
t.pattern = test
|
desc "Run unit test #{File.basename(test,'.*')}"
|
||||||
t.verbose = true
|
Rake::TestTask.new(File.basename(test,'.*').sub('_test','') => [:config_toolchains]) do |t|
|
||||||
|
t.pattern = test
|
||||||
|
t.verbose = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -74,36 +77,29 @@ namespace :test do
|
|||||||
|
|
||||||
desc "Run System Tests"
|
desc "Run System Tests"
|
||||||
task :system => [:config_toolchains, :clobber, :prep_system_tests] do
|
task :system => [:config_toolchains, :clobber, :prep_system_tests] do
|
||||||
# Get a list of all system tests, removing unsupported tests for this toolchain
|
|
||||||
# including those explicitly not included, plus those implicitly based on needs
|
|
||||||
unsupported = unsupported_tests()
|
|
||||||
criteria = {
|
|
||||||
'out_of_memory' => { :defines => ['CMOCK_MEM_STATIC', 'CMOCK_MEM_SIZE=1024']}
|
|
||||||
}
|
|
||||||
criteria.each_pair do |k,v|
|
|
||||||
crit_defs = v[:defines] || []
|
|
||||||
test_defs = $unity_cfg.dig(:defines,:test)
|
|
||||||
conf_defs = (test_defs.is_a?(Hash) ? test_defs['*'] : nil) || test_defs || []
|
|
||||||
if (crit_defs & conf_defs).empty?
|
|
||||||
unsupported |= [k]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
sys_unsupported = unsupported.map {|a| 'system/test_interactions/'+a+'.yml'}
|
|
||||||
|
|
||||||
# Determine which system tests remain after those are removed
|
|
||||||
sys_tests_to_run = FileList['system/test_interactions/*.yml'] - sys_unsupported
|
|
||||||
compile_unsupported = unsupported.map {|a| SYSTEST_COMPILE_MOCKABLES_PATH+a+'.h'}
|
|
||||||
compile_tests_to_run = FileList[SYSTEST_COMPILE_MOCKABLES_PATH + '*.h'] - compile_unsupported
|
|
||||||
unless (sys_unsupported.empty? and compile_unsupported.empty?)
|
|
||||||
report "\nIgnoring these system tests..."
|
|
||||||
sys_unsupported.each {|a| report a}
|
|
||||||
compile_unsupported.each {|a| report a}
|
|
||||||
end
|
|
||||||
report "\nRunning system tests..."
|
report "\nRunning system tests..."
|
||||||
tests_failed = run_system_test_interactions(sys_tests_to_run)
|
tests_failed = run_system_test_interactions(FileList['system/test_interactions/*.yml'])
|
||||||
raise "System tests failed." if (tests_failed > 0)
|
raise "System tests failed." if (tests_failed > 0)
|
||||||
|
|
||||||
run_system_test_compilations(compile_tests_to_run)
|
run_system_test_compilations(FileList[SYSTEST_COMPILE_MOCKABLES_PATH + '*.h'])
|
||||||
|
end
|
||||||
|
|
||||||
|
#individual system tests
|
||||||
|
namespace :system do
|
||||||
|
FileList['system/test_interactions/*.yml'].each do |test|
|
||||||
|
basename = File.basename(test,'.*')
|
||||||
|
desc "Run system test #{basename}"
|
||||||
|
task basename => [:config_toolchains, :prep_system_tests] do
|
||||||
|
run_system_test_interactions([test])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
FileList[SYSTEST_COMPILE_MOCKABLES_PATH + '*.h'].each do |test|
|
||||||
|
basename = File.basename(test,'.*')
|
||||||
|
desc "Run system test #{basename}"
|
||||||
|
task basename => [:config_toolchains, :prep_system_tests] do
|
||||||
|
run_system_test_compilations([test])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Test cmock examples"
|
desc "Test cmock examples"
|
||||||
@@ -111,15 +107,6 @@ namespace :test do
|
|||||||
run_examples()
|
run_examples()
|
||||||
end
|
end
|
||||||
|
|
||||||
#individual system tests
|
|
||||||
FileList['system/test_interactions/*.yml'].each do |test|
|
|
||||||
basename = File.basename(test,'.*')
|
|
||||||
#desc "Run system test #{basename}"
|
|
||||||
task basename => [:config_toolchains] do
|
|
||||||
run_system_test_interactions([test])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Profile Mock Generation"
|
desc "Profile Mock Generation"
|
||||||
task :profile => [:config_toolchains, :clobber, :prep_system_tests] do
|
task :profile => [:config_toolchains, :clobber, :prep_system_tests] do
|
||||||
run_system_test_profiles(FileList[SYSTEST_COMPILE_MOCKABLES_PATH + '*.h'])
|
run_system_test_profiles(FileList[SYSTEST_COMPILE_MOCKABLES_PATH + '*.h'])
|
||||||
|
|||||||
+39
-8
@@ -144,10 +144,22 @@ module RakefileHelpers
|
|||||||
(($unity_cfg[:paths] || {})[:test] || []).select { |p| p.is_a?(Array) }
|
(($unity_cfg[:paths] || {})[:test] || []).select { |p| p.is_a?(Array) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the unsupported test list, regardless of whether it came from
|
# Returns the full unsupported test list for the current toolchain, combining:
|
||||||
# a CMock overlay or a CMock-only target file.
|
# - explicit :unsupported lists from the CMock overlay and Unity target files
|
||||||
|
# - implicit criteria (tests that require defines not present in the toolchain)
|
||||||
|
UNSUPPORTED_CRITERIA = {
|
||||||
|
'out_of_memory' => { :defines => ['CMOCK_MEM_STATIC'] },
|
||||||
|
'unity_64bit_support' => { :defines => ['UNITY_SUPPORT_64'] }
|
||||||
|
}.freeze
|
||||||
|
|
||||||
def unsupported_tests
|
def unsupported_tests
|
||||||
($cmock_cfg[:unsupported] || []) | ($unity_cfg[:unsupported] || [])
|
result = ($cmock_cfg[:unsupported] || []) | ($unity_cfg[:unsupported] || [])
|
||||||
|
test_defs = $unity_cfg.dig(:defines, :test)
|
||||||
|
conf_defs = (test_defs.is_a?(Hash) ? test_defs['*'] : nil) || test_defs || []
|
||||||
|
UNSUPPORTED_CRITERIA.each_pair do |name, crit|
|
||||||
|
result |= [name] if (crit[:defines] & conf_defs).empty?
|
||||||
|
end
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
# Resolve argument template tokens and produce a flat argument string.
|
# Resolve argument template tokens and produce a flat argument string.
|
||||||
@@ -228,7 +240,7 @@ module RakefileHelpers
|
|||||||
{ command: "#{executable} ", pre_support: pre, post_support: post }
|
{ command: "#{executable} ", pre_support: pre, post_support: post }
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute(command_string, verbose=true, raise_on_failure=true)
|
def execute(command_string, verbose=false, raise_on_failure=true)
|
||||||
report(command_string) if verbose
|
report(command_string) if verbose
|
||||||
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))
|
||||||
@@ -320,20 +332,30 @@ module RakefileHelpers
|
|||||||
def run_system_test_interactions(test_case_files)
|
def run_system_test_interactions(test_case_files)
|
||||||
load '../lib/cmock.rb'
|
load '../lib/cmock.rb'
|
||||||
|
|
||||||
|
unsupported = unsupported_tests
|
||||||
|
test_case_files = test_case_files.reject do |f|
|
||||||
|
name = File.basename(f, YAML_EXTENSION)
|
||||||
|
if unsupported.include?(name)
|
||||||
|
report "Ignoring system test: #{name}"
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
SystemTestGenerator.new.generate_files(test_case_files)
|
SystemTestGenerator.new.generate_files(test_case_files)
|
||||||
test_files = FileList.new(SYSTEST_GENERATED_FILES_PATH + 'test*.c')
|
|
||||||
|
|
||||||
load_configuration($cfg_file)
|
load_configuration($cfg_file)
|
||||||
|
|
||||||
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_case_files.each do |yaml|
|
||||||
|
|
||||||
obj_list = []
|
obj_list = []
|
||||||
|
|
||||||
test_base = File.basename(test, C_EXTENSION)
|
name = File.basename(yaml, YAML_EXTENSION)
|
||||||
cmock_config = test_base.gsub(/test_/, '') + '_cmock.yml'
|
test_base = 'test_' + name
|
||||||
|
test = SYSTEST_GENERATED_FILES_PATH + test_base + C_EXTENSION
|
||||||
|
cmock_config = name + '_cmock.yml'
|
||||||
|
|
||||||
report "Executing system tests in #{File.basename(test)}..."
|
report "Executing system tests in #{File.basename(test)}..."
|
||||||
|
|
||||||
@@ -461,6 +483,15 @@ module RakefileHelpers
|
|||||||
load '../lib/cmock.rb'
|
load '../lib/cmock.rb'
|
||||||
load_configuration($cfg_file)
|
load_configuration($cfg_file)
|
||||||
|
|
||||||
|
unsupported = unsupported_tests
|
||||||
|
mockables = mockables.reject do |f|
|
||||||
|
name = File.basename(f, '.h')
|
||||||
|
if unsupported.include?(name)
|
||||||
|
report "Ignoring system test compilation: #{name}"
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
report "\n"
|
report "\n"
|
||||||
report "------------------------------------\n"
|
report "------------------------------------\n"
|
||||||
report "SYSTEM TEST MOCK COMPILATION SUMMARY\n"
|
report "SYSTEM TEST MOCK COMPILATION SUMMARY\n"
|
||||||
|
|||||||
@@ -24,15 +24,15 @@ void const_variants2(
|
|||||||
|
|
||||||
const int * const_retval1(void); /* nicety version for pointer to constant int */
|
const int * const_retval1(void); /* nicety version for pointer to constant int */
|
||||||
int const * const_retval2(void); /* formal version for pointer to constant int */
|
int const * const_retval2(void); /* formal version for pointer to constant int */
|
||||||
//int * const const_retval3(void); /* formal version for constant pointer to int */
|
int * const const_retval3(void); /* formal version for constant pointer to int */
|
||||||
//int const * const const_retval4(void); /* formal version for constant pointer to constant int */
|
int const * const const_retval4(void); /* formal version for constant pointer to constant int */
|
||||||
|
|
||||||
const int* const_retval5(void); /* sticky-left nicety version for pointer to constant int */
|
const int* const_retval5(void); /* sticky-left nicety version for pointer to constant int */
|
||||||
int const* const_retval6(void); /* sticky-left formal version for pointer to constant int */
|
int const* const_retval6(void); /* sticky-left formal version for pointer to constant int */
|
||||||
//int* const const_retval7(void); /* sticky-left formal version for constant pointer to int */
|
int* const const_retval7(void); /* sticky-left formal version for constant pointer to int */
|
||||||
//int const* const const_retval8(void); /* sticky-left formal version for constant pointer to constant int */
|
int const* const const_retval8(void); /* sticky-left formal version for constant pointer to constant int */
|
||||||
|
|
||||||
const int *const_retval9(void); /* sticky-right nicety version for pointer to constant int */
|
const int *const_retval9(void); /* sticky-right nicety version for pointer to constant int */
|
||||||
int const *const_retvalA(void); /* sticky-right formal version for pointer to constant int */
|
int const *const_retvalA(void); /* sticky-right formal version for pointer to constant int */
|
||||||
//int *const const_retvalB(void); /* sticky-right formal version for constant pointer to int */
|
int *const const_retvalB(void); /* sticky-right formal version for constant pointer to int */
|
||||||
//int const *const const_retvalC(void); /* sticky-right formal version for constant pointer to constant int */
|
int const *const const_retvalC(void); /* sticky-right formal version for constant pointer to constant int */
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
const char const * bars(void);
|
const char const * bars(void);
|
||||||
|
|
||||||
:source:
|
:source:
|
||||||
:header: |
|
:header: |
|
||||||
#include "CException.h"
|
#include "CException.h"
|
||||||
void function_a(void);
|
void function_a(void);
|
||||||
void function_b(void);
|
void function_b(void);
|
||||||
|
|||||||
@@ -13,9 +13,10 @@
|
|||||||
|
|
||||||
:systest:
|
:systest:
|
||||||
:types: |
|
:types: |
|
||||||
|
#define BIG_FAT_STRUCT_SIZE (512)
|
||||||
typedef struct _BIG_FAT_STRUCT_T
|
typedef struct _BIG_FAT_STRUCT_T
|
||||||
{
|
{
|
||||||
char bytes[512];
|
char bytes[BIG_FAT_STRUCT_SIZE];
|
||||||
} BIG_FAT_STRUCT_T;
|
} BIG_FAT_STRUCT_T;
|
||||||
|
|
||||||
:mockable: |
|
:mockable: |
|
||||||
@@ -52,9 +53,17 @@
|
|||||||
:code: |
|
:code: |
|
||||||
test()
|
test()
|
||||||
{
|
{
|
||||||
|
int i=0;
|
||||||
BIG_FAT_STRUCT_T expected = { { 8, 0 } };
|
BIG_FAT_STRUCT_T expected = { { 8, 0 } };
|
||||||
foo_Expect(expected);
|
// Fill expectations until there is not enough room for more.
|
||||||
function_a();
|
// We know we can ask one more when there is only enough room for 2 blocks, ignoring overhead.
|
||||||
|
while (CMock_Guts_MemBytesFree() > (CMOCK_MEM_SIZE*2)) {
|
||||||
|
i++;
|
||||||
|
foo_Expect(expected);
|
||||||
|
}
|
||||||
|
for (; i>0; i--) {
|
||||||
|
function_a();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- :pass: FALSE
|
- :pass: FALSE
|
||||||
@@ -62,11 +71,19 @@
|
|||||||
:code: |
|
:code: |
|
||||||
test()
|
test()
|
||||||
{
|
{
|
||||||
|
int i=0;
|
||||||
BIG_FAT_STRUCT_T expected1 = { { 9, 1, 0 } };
|
BIG_FAT_STRUCT_T expected1 = { { 9, 1, 0 } };
|
||||||
BIG_FAT_STRUCT_T expected2 = { { 9, 2, 0 } };
|
BIG_FAT_STRUCT_T expected2 = { { 9, 2, 0 } };
|
||||||
foo_Expect(expected1);
|
// Ask for more room than we have
|
||||||
foo_Expect(expected2);
|
while (CMock_Guts_MemBytesFree() > 0) {
|
||||||
function_b();
|
foo_Expect(expected1);
|
||||||
|
foo_Expect(expected2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// It should not actually get here
|
||||||
|
for (i=0; i < (CMOCK_MEM_SIZE/BIG_FAT_STRUCT_SIZE - 1); i++) {
|
||||||
|
function_b();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
# =========================================================================
|
|
||||||
# CMock - Automatic Mock Generation for C
|
|
||||||
# ThrowTheSwitch.org
|
|
||||||
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
# =========================================================================
|
|
||||||
|
|
||||||
# CMock overlay for vendor/unity/test/targets/clang_strict.yml
|
|
||||||
# Only contains additions not present in the Unity base target.
|
|
||||||
:unsupported:
|
|
||||||
- out_of_memory
|
|
||||||
- callingconv
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# =========================================================================
|
|
||||||
# CMock - Automatic Mock Generation for C
|
|
||||||
# ThrowTheSwitch.org
|
|
||||||
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
# =========================================================================
|
|
||||||
|
|
||||||
# CMock overlay for vendor/unity/test/targets/gcc_32.yml
|
|
||||||
# Only contains additions not present in the Unity base target.
|
|
||||||
---
|
|
||||||
:unsupported:
|
|
||||||
- out_of_memory
|
|
||||||
- unity_64bit_support
|
|
||||||
- callingconv
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
# =========================================================================
|
|
||||||
# CMock - Automatic Mock Generation for C
|
|
||||||
# ThrowTheSwitch.org
|
|
||||||
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
# =========================================================================
|
|
||||||
|
|
||||||
# CMock overlay for vendor/unity/test/targets/gcc_64.yml
|
|
||||||
# Only contains additions not present in the Unity base target.
|
|
||||||
:unsupported:
|
|
||||||
- out_of_memory
|
|
||||||
- callingconv
|
|
||||||
@@ -9,8 +9,6 @@
|
|||||||
# Only contains additions not present in the Unity base target.
|
# Only contains additions not present in the Unity base target.
|
||||||
|
|
||||||
:unsupported:
|
:unsupported:
|
||||||
- out_of_memory
|
|
||||||
- nonstandard_parsed_stuff_1
|
- nonstandard_parsed_stuff_1
|
||||||
- const
|
- const
|
||||||
- callingconv
|
- callingconv
|
||||||
- unity_64bit_support
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
- struct_union_enum_expect_and_return
|
- struct_union_enum_expect_and_return
|
||||||
- struct_union_enum_expect_and_return_with_plugins
|
- struct_union_enum_expect_and_return_with_plugins
|
||||||
- stubs_with_callbacks
|
- stubs_with_callbacks
|
||||||
- unity_64bit_support
|
|
||||||
- unity_ignores
|
- unity_ignores
|
||||||
- callingconv
|
- callingconv
|
||||||
- C
|
- C
|
||||||
|
|||||||
Reference in New Issue
Block a user