mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-09-26 20:17:26 +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"
|
- "static inline"
|
||||||
- "inline static"
|
- "inline static"
|
||||||
- "inline"
|
- "inline"
|
||||||
- "static"
|
|
||||||
You can override these patterns, check out :inline_function_patterns.
|
You can override these patterns, check out :inline_function_patterns.
|
||||||
|
|
||||||
Enabling this feature does require a change in the build system that
|
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
|
is using CMock. To understand why, we need to give some more info
|
||||||
on how we are handling inline functions internally.
|
on how we are handling inline functions internally.
|
||||||
|
|
||||||
Let's say we want to mock a header called example.h. example.h
|
Let's say we want to mock a header called example.h. example.h
|
||||||
contains inline functions, we cannot include this header in the
|
contains inline functions, we cannot include this header in the
|
||||||
mocks or test code if we want to mock the inline functions simply
|
mocks or test code if we want to mock the inline functions simply
|
||||||
because the inline functions contain an implementation that we want
|
because the inline functions contain an implementation that we want
|
||||||
to override in our mocks!
|
to override in our mocks!
|
||||||
|
|
||||||
So, to circumvent this, we generate a new header, also named
|
So, to circumvent this, we generate a new header, also named
|
||||||
example.h, in the same directory as mock_example.h/c . This newly
|
example.h, in the same directory as mock_example.h/c . This newly
|
||||||
generated header should/is exactly the same as the original header,
|
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
|
functions declarations. Placing the new header in the same
|
||||||
directory as mock_example.h/c ensures that they will include the new
|
directory as mock_example.h/c ensures that they will include the new
|
||||||
header and not the old one.
|
header and not the old one.
|
||||||
|
|
||||||
However, CMock has no control in how the build system is configured
|
However, CMock has no control in how the build system is configured
|
||||||
and which include paths the test code is compiled with. In order
|
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
|
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 old header with inline functions, the build system has to add
|
||||||
the mock folder to the include paths.
|
the mock folder to the include paths.
|
||||||
|
|
||||||
Furthermore, we need to keep the order of include paths in mind. We
|
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
|
have to set the mock folder before the other includes to avoid the
|
||||||
test code including the original header instead of the newly
|
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),
|
# - 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
|
# 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
|
# - 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
|
}.freeze
|
||||||
|
|
||||||
def initialize(options = nil)
|
def initialize(options = nil)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
3.2.0
|
||||||
+1
-1
@@ -140,7 +140,7 @@ namespace :style do
|
|||||||
end
|
end
|
||||||
|
|
||||||
task :clean do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ module RakefileHelpers
|
|||||||
def find_source_file(header, paths)
|
def find_source_file(header, paths)
|
||||||
paths.each do |dir|
|
paths.each do |dir|
|
||||||
src_file = dir + header.ext(C_EXTENSION)
|
src_file = dir + header.ext(C_EXTENSION)
|
||||||
if (File.exists?(src_file))
|
if (File.exist?(src_file))
|
||||||
return src_file
|
return src_file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ void OSEKOSStartupEnable(void);
|
|||||||
void OSEKOSNop(void);
|
void OSEKOSNop(void);
|
||||||
unsigned int OSEKOSV850CheckIsrSwitch(void);
|
unsigned int OSEKOSV850CheckIsrSwitch(void);
|
||||||
void OSEKOSV850InitInterrupts(void);
|
void OSEKOSV850InitInterrupts(void);
|
||||||
void OSEKOSV850SetupInterrupts();
|
void OSEKOSV850SetupInterrupts(void);
|
||||||
void OSEKOSV850SyncContextLoad(OSEKOSSaveType);
|
void OSEKOSV850SyncContextLoad(OSEKOSSaveType);
|
||||||
void OSEKOSV850SyncContextLoadFromIRQ(OSEKOSSaveType);
|
void OSEKOSV850SyncContextLoadFromIRQ(OSEKOSSaveType);
|
||||||
void OSEKOSV850ASyncContextLoad(OSEKOSSaveType);
|
void OSEKOSV850ASyncContextLoad(OSEKOSSaveType);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
:common: |
|
:common: |
|
||||||
void setUp(void) {}
|
void setUp(void) {}
|
||||||
void tearDown(void) {}
|
void tearDown(void) {}
|
||||||
extern int function_d();
|
extern int function_d(void);
|
||||||
|
|
||||||
:units:
|
:units:
|
||||||
- :pass: TRUE
|
- :pass: TRUE
|
||||||
|
|||||||
Reference in New Issue
Block a user