mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-05 21:15:20 +00:00
Fix to incorrect handling of static inlines.
Fix to Ruby deprecated interfaces. Fix to keep up with new C standards.
This commit is contained in:
@@ -608,17 +608,19 @@ from the defaults. We've tried to specify what the defaults are below.
|
||||
- "static inline"
|
||||
- "inline static"
|
||||
- "inline"
|
||||
- "static"
|
||||
|
||||
You can override these patterns, check out :inline_function_patterns.
|
||||
|
||||
Enabling this feature does require a change in the build system that
|
||||
is using CMock. To understand why, we need to give some more info
|
||||
on how we are handling inline functions internally.
|
||||
|
||||
Let's say we want to mock a header called example.h. example.h
|
||||
contains inline functions, we cannot include this header in the
|
||||
mocks or test code if we want to mock the inline functions simply
|
||||
because the inline functions contain an implementation that we want
|
||||
to override in our mocks!
|
||||
|
||||
So, to circumvent this, we generate a new header, also named
|
||||
example.h, in the same directory as mock_example.h/c . This newly
|
||||
generated header should/is exactly the same as the original header,
|
||||
@@ -626,11 +628,13 @@ from the defaults. We've tried to specify what the defaults are below.
|
||||
functions declarations. Placing the new header in the same
|
||||
directory as mock_example.h/c ensures that they will include the new
|
||||
header and not the old one.
|
||||
|
||||
However, CMock has no control in how the build system is configured
|
||||
and which include paths the test code is compiled with. In order
|
||||
for the test code to also see the newly generated header ,and not
|
||||
the old header with inline functions, the build system has to add
|
||||
the mock folder to the include paths.
|
||||
|
||||
Furthermore, we need to keep the order of include paths in mind. We
|
||||
have to set the mock folder before the other includes to avoid the
|
||||
test code including the original header instead of the newly
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class CMockConfig
|
||||
# - The keywords can appear before or after the return type (this is a compiler warning but people do weird stuff),
|
||||
# so we check for word boundaries when searching for them
|
||||
# - We first remove "static inline" combinations and boil down to single inline or static statements
|
||||
:inline_function_patterns => ['(static\s+inline|inline\s+static)\s*', '(\bstatic\b|\binline\b)\s*', '(?:static\s*)?(?:__inline__)?__attribute__\s*\([ (]*always_inline[ )]*\)', 'static __inline__'] # Last part (\s*) is just to remove whitespaces (only to prettify the output)
|
||||
:inline_function_patterns => ['(static\s+inline|inline\s+static)\s*', '(\binline\b)\s*', '(?:static\s*)?(?:__inline__)?__attribute__\s*\([ (]*always_inline[ )]*\)', 'static __inline__'] # Last part (\s*) is just to remove whitespaces (only to prettify the output)
|
||||
}.freeze
|
||||
|
||||
def initialize(options = nil)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
3.2.0
|
||||
+1
-1
@@ -140,7 +140,7 @@ namespace :style do
|
||||
end
|
||||
|
||||
task :clean do
|
||||
File.delete(".rubocop_todo.yml") if File.exists?(".rubocop_todo.yml")
|
||||
File.delete(".rubocop_todo.yml") if File.exist?(".rubocop_todo.yml")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ module RakefileHelpers
|
||||
def find_source_file(header, paths)
|
||||
paths.each do |dir|
|
||||
src_file = dir + header.ext(C_EXTENSION)
|
||||
if (File.exists?(src_file))
|
||||
if (File.exist?(src_file))
|
||||
return src_file
|
||||
end
|
||||
end
|
||||
|
||||
@@ -242,7 +242,7 @@ void OSEKOSStartupEnable(void);
|
||||
void OSEKOSNop(void);
|
||||
unsigned int OSEKOSV850CheckIsrSwitch(void);
|
||||
void OSEKOSV850InitInterrupts(void);
|
||||
void OSEKOSV850SetupInterrupts();
|
||||
void OSEKOSV850SetupInterrupts(void);
|
||||
void OSEKOSV850SyncContextLoad(OSEKOSSaveType);
|
||||
void OSEKOSV850SyncContextLoadFromIRQ(OSEKOSSaveType);
|
||||
void OSEKOSV850ASyncContextLoad(OSEKOSSaveType);
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
:common: |
|
||||
void setUp(void) {}
|
||||
void tearDown(void) {}
|
||||
extern int function_d();
|
||||
extern int function_d(void);
|
||||
|
||||
:units:
|
||||
- :pass: TRUE
|
||||
|
||||
Reference in New Issue
Block a user