mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-05 02:37:50 +00:00
Update to latest Unity, raising warning / error level in the process.
Clean up some warnings. Purposefully accept them in tests where we're verifying it still mocks when those issues exist.
This commit is contained in:
@@ -20,7 +20,7 @@ REQUIRED_DIRS.each do |v|
|
||||
end
|
||||
|
||||
# Load default configuration, for now
|
||||
DEFAULT_CONFIG_FILE = 'gcc_64.yml'.freeze
|
||||
DEFAULT_CONFIG_FILE = 'gcc.yml'.freeze
|
||||
configure_toolchain(DEFAULT_CONFIG_FILE)
|
||||
|
||||
task :unit do
|
||||
|
||||
@@ -23,11 +23,13 @@ void AdcModel_ProcessInput(uint16 millivolts)
|
||||
bool AdcModel_DoNothingExceptTestASpecialType(EXAMPLE_STRUCT_T ExampleStruct)
|
||||
{
|
||||
//This doesn't really do anything. it's only here to make sure I can compare a struct.
|
||||
(void)ExampleStruct;
|
||||
return FALSE;
|
||||
}
|
||||
bool AdModel_DoNothingExceptTestPointers(uint32* pExample)
|
||||
{
|
||||
//This doesn't really do anything. it's only here to make sure I can compare a pointer value.
|
||||
(void)pExample;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# =========================================================================
|
||||
|
||||
# gcc_64 with debug symbols enabled for meaningful valgrind output.
|
||||
# gcc with debug symbols enabled for meaningful valgrind output.
|
||||
# Used by the CI valgrind job to check for memory leaks and errors.
|
||||
|
||||
---
|
||||
@@ -15,7 +15,6 @@
|
||||
:executable: gcc
|
||||
:arguments:
|
||||
- "-c"
|
||||
- "-m64"
|
||||
- "-g"
|
||||
- "-Wall"
|
||||
- "-Wno-address"
|
||||
@@ -31,18 +30,12 @@
|
||||
:arguments:
|
||||
- "${1}"
|
||||
- "-lm"
|
||||
- "-m64"
|
||||
- "-o ${2}"
|
||||
:extension:
|
||||
:object: ".o"
|
||||
:executable: ".exe"
|
||||
:defines:
|
||||
:test:
|
||||
- UNITY_EXCLUDE_STDINT_H
|
||||
- UNITY_EXCLUDE_LIMITS_H
|
||||
- UNITY_INCLUDE_DOUBLE
|
||||
- UNITY_SUPPORT_TEST_CASES
|
||||
- UNITY_SUPPORT_64
|
||||
- UNITY_INT_WIDTH=32
|
||||
- UNITY_LONG_WIDTH=64
|
||||
- UNITY_POINTER_WIDTH=64
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ require './rakefile_helper'
|
||||
|
||||
include RakefileHelpers
|
||||
|
||||
DEFAULT_CONFIG_FILE = 'gcc_64.yml'
|
||||
DEFAULT_CONFIG_FILE = 'gcc.yml'
|
||||
CMOCK_TEST_ROOT = File.expand_path(File.dirname(__FILE__))
|
||||
|
||||
SYSTEM_TEST_SUPPORT_DIRS = [
|
||||
|
||||
+26
-5
@@ -194,7 +194,21 @@ module RakefileHelpers
|
||||
result.join(' ')
|
||||
end
|
||||
|
||||
def compile(file, extra_defines = [])
|
||||
def compiler_basename
|
||||
exe = $unity_cfg[:tools][:test_compiler][:executable]
|
||||
File.basename(exe.is_a?(Array) ? exe.join : exe.to_s)
|
||||
end
|
||||
|
||||
def extra_flags_for_compiler(flags_config)
|
||||
return [] unless flags_config
|
||||
|
||||
basename = compiler_basename
|
||||
flags_config.each_with_object([]) do |(compiler_key, flags), result|
|
||||
result.concat(Array(flags)) if basename.include?(compiler_key.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
def compile(file, extra_defines = [], extra_flags = [])
|
||||
tool = $unity_cfg[:tools][:test_compiler]
|
||||
ext = $unity_cfg[:extension][:object] || '.o'
|
||||
build_root = $proj[:project][:build_root] || 'build/'
|
||||
@@ -206,6 +220,7 @@ module RakefileHelpers
|
||||
$proj[:paths][:include],
|
||||
all_defines(extra_defines),
|
||||
file, obj_file)
|
||||
cmd_str += ' ' + extra_flags.join(' ') unless extra_flags.empty?
|
||||
execute(cmd_str)
|
||||
File.basename(obj_file)
|
||||
end
|
||||
@@ -356,6 +371,9 @@ module RakefileHelpers
|
||||
test = SYSTEST_GENERATED_FILES_PATH + test_base + C_EXTENSION
|
||||
cmock_config = name + '_cmock.yml'
|
||||
|
||||
yaml_content = load_yaml(yaml)
|
||||
extra_flags = extra_flags_for_compiler((yaml_content || {})[:flags])
|
||||
|
||||
report "Executing system tests in #{File.basename(test)}..."
|
||||
|
||||
# Detect dependencies and build required modules
|
||||
@@ -369,17 +387,17 @@ module RakefileHelpers
|
||||
end
|
||||
# Compile corresponding source file if it exists
|
||||
src_file = find_source_file(header, include_dirs)
|
||||
obj_list << compile(src_file) unless src_file.nil?
|
||||
obj_list << compile(src_file, [], extra_flags) unless src_file.nil?
|
||||
end
|
||||
|
||||
# Generate and build the test suite runner
|
||||
runner_name = test_base + '_runner.c'
|
||||
runner_path = $proj[:paths][:source].first + runner_name
|
||||
UnityTestRunnerGenerator.new(SYSTEST_GENERATED_FILES_PATH + cmock_config).run(test, runner_path)
|
||||
obj_list << compile(runner_path)
|
||||
obj_list << compile(runner_path, [], extra_flags)
|
||||
|
||||
# Build the test module
|
||||
obj_list << compile(test)
|
||||
obj_list << compile(test, [], extra_flags)
|
||||
|
||||
# Link the test executable
|
||||
link_it(test_base, obj_list)
|
||||
@@ -498,6 +516,9 @@ module RakefileHelpers
|
||||
end
|
||||
end
|
||||
|
||||
compile_config = load_yaml(SYSTEST_COMPILE_MOCKABLES_PATH + 'config.yml')
|
||||
extra_flags = extra_flags_for_compiler((compile_config || {})[:flags])
|
||||
|
||||
report "\n"
|
||||
report "------------------------------------\n"
|
||||
report "SYSTEM TEST MOCK COMPILATION SUMMARY\n"
|
||||
@@ -507,7 +528,7 @@ module RakefileHelpers
|
||||
mock_filename = 'mock_' + File.basename(header).ext('.c')
|
||||
CMock.new(SYSTEST_COMPILE_MOCKABLES_PATH + 'config.yml').setup_mocks(header)
|
||||
report "Compiling #{mock_filename}..."
|
||||
compile(SYSTEST_GENERATED_FILES_PATH + mock_filename)
|
||||
compile(SYSTEST_GENERATED_FILES_PATH + mock_filename, [], extra_flags)
|
||||
pass_count += 1
|
||||
end
|
||||
report "#{pass_count} Tests 0 Failures 0 Ignored\nOK\n"
|
||||
|
||||
@@ -6,6 +6,12 @@
|
||||
# =========================================================================
|
||||
|
||||
---
|
||||
:flags:
|
||||
:gcc:
|
||||
- -Wno-ignored-qualifiers
|
||||
:clang:
|
||||
- -Wno-ignored-qualifiers
|
||||
|
||||
:cmock:
|
||||
:plugins: []
|
||||
:includes: []
|
||||
|
||||
@@ -10,6 +10,15 @@
|
||||
:plugins:
|
||||
- # none
|
||||
|
||||
# We are purposefully trying various (sometimes pointless) configurations
|
||||
# of const, so that we can ensure cmock handles them all, for compilers that
|
||||
# accept that style. Ignore this warning so it can be tested
|
||||
:flags:
|
||||
:gcc:
|
||||
- -Wno-ignored-qualifiers
|
||||
:clang:
|
||||
- -Wno-ignored-qualifiers
|
||||
|
||||
:systest:
|
||||
:types: |
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
test()
|
||||
{
|
||||
unsigned char a[] = { 1, 2, 3, 4, 5, 6 };
|
||||
unsigned char** pa = (unsigned char**)(&a);
|
||||
unsigned char* aa[] = { &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7] };
|
||||
unsigned char** pa = (unsigned char**)(aa);
|
||||
|
||||
bar_ExpectAndReturn(pa);
|
||||
foo_Expect(pa);
|
||||
@@ -54,9 +55,11 @@
|
||||
test()
|
||||
{
|
||||
unsigned char a[] = { 1, 2, 3, 4, 5, 6 };
|
||||
unsigned char* aa[] = { &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7] };
|
||||
unsigned char b[] = { 5, 6, 7, 8, 9, 0 };
|
||||
unsigned char** pa = (unsigned char**)(&a);
|
||||
unsigned char** pb = (unsigned char**)(&b);
|
||||
unsigned char* bb[] = { &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], &b[6], &b[7] };
|
||||
unsigned char** pa = (unsigned char**)(aa);
|
||||
unsigned char** pb = (unsigned char**)(bb);
|
||||
|
||||
bar_ExpectAndReturn(pa);
|
||||
foo_Expect(pb);
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* b = "Hello";
|
||||
char* a = (char*)("Hello");
|
||||
char* b = (char*)("Hello");
|
||||
ret_v_ptr_ExpectAndReturn(a);
|
||||
get_v_ptr_Expect(b);
|
||||
get_v_ptr_typedefed_Expect((VOID_PTR)b);
|
||||
@@ -59,8 +59,8 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* b = "Hello";
|
||||
char* a = (char*)("Hello");
|
||||
char* b = (char*)("Hello");
|
||||
ret_v_ptr_ExpectAndReturn(a);
|
||||
get_v_ptr_ExpectWithArray(b,5);
|
||||
get_v_ptr_typedefed_ExpectWithArray((VOID_PTR)b,5);
|
||||
@@ -73,8 +73,8 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* b = "Jello";
|
||||
char* a = (char*)("Hello");
|
||||
char* b = (char*)("Jello");
|
||||
ret_v_ptr_ExpectAndReturn(a);
|
||||
get_v_ptr_Expect(b);
|
||||
get_v_ptr_typedefed_Expect((VOID_PTR)b);
|
||||
@@ -87,8 +87,8 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* b = "Hella";
|
||||
char* a = (char*)("Hello");
|
||||
char* b = (char*)("Hella");
|
||||
ret_v_ptr_ExpectAndReturn(a);
|
||||
get_v_ptr_ExpectWithArray(b,5);
|
||||
get_v_ptr_typedefed_ExpectWithArray((VOID_PTR)b,5);
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* a = (char*)("Hello");
|
||||
get_v_ptr_Expect(a);
|
||||
function_a(a);
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* a = (char*)("Hello");
|
||||
get_v_ptr_Expect(NULL);
|
||||
function_a(a);
|
||||
}
|
||||
@@ -94,7 +94,7 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* a = (char*)("Hello");
|
||||
get_const_v_ptr_Expect(a);
|
||||
function_b(a);
|
||||
}
|
||||
@@ -115,7 +115,7 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* a = (char*)("Hello");
|
||||
get_my_void_ptr_Expect(a);
|
||||
function_c(a);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* a = (char*)("Hello");
|
||||
get_my_void_ptr_Expect(a);
|
||||
function_a(a);
|
||||
}
|
||||
@@ -53,8 +53,8 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* b = "Hello";
|
||||
char* a = (char*)("Hello");
|
||||
char* b = (char*)("Hello");
|
||||
get_my_void_ptr_ExpectWithArray(a, 5);
|
||||
function_a(b);
|
||||
}
|
||||
@@ -64,8 +64,8 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* b = "Jello";
|
||||
char* a = (char*)("Hello");
|
||||
char* b = (char*)("Jello");
|
||||
get_my_void_ptr_ExpectWithArray(a, 5);
|
||||
function_a(b);
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
char* a = "Hello";
|
||||
char* a = (char*)("Hello");
|
||||
get_my_void_ptr_ExpectWithArray(a, 0);
|
||||
function_a(a);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,14 @@
|
||||
- :ignore
|
||||
- :expect_any_args
|
||||
|
||||
# We are purposefully testing some unreachable code in this module, so
|
||||
# we need to block this warning so we can run this test
|
||||
:flags:
|
||||
:gcc:
|
||||
- -Wno-unreachable-code
|
||||
:clang:
|
||||
- -Wno-unreachable-code
|
||||
|
||||
:systest:
|
||||
:types: |
|
||||
#define UINT32 unsigned int
|
||||
|
||||
Vendored
+1
-1
Submodule vendor/unity updated: bbf8f3728a...76e0803cb4
Reference in New Issue
Block a user