mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-05 21:15:20 +00:00
Force ourselves to test with Ruby 3.
Fix some issues that have been lurking.
This commit is contained in:
@@ -16,6 +16,11 @@ jobs:
|
||||
name: "Unit Tests"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '3.0' # Not needed with a .ruby-version file
|
||||
bundler-cache: true # runs 'bundle install' and caches
|
||||
|
||||
# Install Multilib
|
||||
- name: Install Multilib
|
||||
run: |
|
||||
|
||||
@@ -137,7 +137,11 @@ class CMockGenerator
|
||||
@file_writer.create_file(mock_project[:module_name] + '.c', @subdir) do |file, fullname|
|
||||
blank_project = mock_project.clone
|
||||
blank_project[:parsed_stuff] = { :functions => [] }
|
||||
create_source_header_section(file, fullname, blank_project) if existing.empty?
|
||||
if (existing.empty?)
|
||||
create_source_header_section(file, fullname, blank_project)
|
||||
else
|
||||
file << existing << "\n"
|
||||
end
|
||||
mock_project[:parsed_stuff][:functions].each do |function|
|
||||
create_function_skeleton(file, function, existing)
|
||||
end
|
||||
|
||||
+16
-3
@@ -25,10 +25,9 @@ static unsigned char* CMock_Guts_Buffer = NULL;
|
||||
static CMOCK_MEM_INDEX_TYPE CMock_Guts_BufferSize = CMOCK_MEM_ALIGN_SIZE;
|
||||
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr = CMOCK_MEM_ALIGN_SIZE;
|
||||
#else
|
||||
static long long CMock_Guts_Space[(CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE + sizeof(long long) - 1) /
|
||||
sizeof(long long)];
|
||||
static long long CMock_Guts_Space[(CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE + sizeof(long long) - 1) / sizeof(long long)];
|
||||
static unsigned char* CMock_Guts_Buffer = (unsigned char *)CMock_Guts_Space;
|
||||
static CMOCK_MEM_INDEX_TYPE CMock_Guts_BufferSize = sizeof(CMock_Guts_Space);
|
||||
static CMOCK_MEM_INDEX_TYPE CMock_Guts_BufferSize = CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE;//sizeof(CMock_Guts_Space);
|
||||
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr = CMOCK_MEM_ALIGN_SIZE;
|
||||
#endif
|
||||
|
||||
@@ -41,12 +40,16 @@ CMOCK_MEM_INDEX_TYPE CMock_Guts_MemNew(CMOCK_MEM_INDEX_TYPE size)
|
||||
|
||||
/* verify arguments valid (we must be allocating space for at least 1 byte, and the existing chain must be in memory somewhere) */
|
||||
if (size < 1)
|
||||
{
|
||||
return CMOCK_GUTS_NONE;
|
||||
}
|
||||
|
||||
/* verify we have enough room */
|
||||
size = size + CMOCK_MEM_INDEX_SIZE;
|
||||
if (size & CMOCK_MEM_ALIGN_MASK)
|
||||
{
|
||||
size = (size + CMOCK_MEM_ALIGN_MASK) & ~CMOCK_MEM_ALIGN_MASK;
|
||||
}
|
||||
if ((CMock_Guts_BufferSize - CMock_Guts_FreePtr) < size)
|
||||
{
|
||||
#ifndef CMOCK_MEM_DYNAMIC
|
||||
@@ -105,9 +108,13 @@ CMOCK_MEM_INDEX_TYPE CMock_Guts_MemChain(CMOCK_MEM_INDEX_TYPE root_index, CMOCK_
|
||||
do {
|
||||
index = *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)next - CMOCK_MEM_INDEX_SIZE);
|
||||
if (index >= CMock_Guts_FreePtr)
|
||||
{
|
||||
return CMOCK_GUTS_NONE;
|
||||
}
|
||||
if (index > 0)
|
||||
{
|
||||
next = (void*)(&CMock_Guts_Buffer[index]);
|
||||
}
|
||||
} while (index > 0);
|
||||
*(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)next - CMOCK_MEM_INDEX_SIZE) = (CMOCK_MEM_INDEX_TYPE)((CMOCK_MEM_PTR_AS_INT)obj - (CMOCK_MEM_PTR_AS_INT)CMock_Guts_Buffer);
|
||||
return root_index;
|
||||
@@ -124,16 +131,22 @@ CMOCK_MEM_INDEX_TYPE CMock_Guts_MemNext(CMOCK_MEM_INDEX_TYPE previous_item_index
|
||||
|
||||
/* There is nothing "next" if the pointer isn't from our buffer */
|
||||
if ((previous_item_index < CMOCK_MEM_ALIGN_SIZE) || (previous_item_index >= CMock_Guts_FreePtr))
|
||||
{
|
||||
return CMOCK_GUTS_NONE;
|
||||
}
|
||||
previous_item = (void*)(&CMock_Guts_Buffer[previous_item_index]);
|
||||
|
||||
/* if the pointer is good, then use it to look up the next index
|
||||
* (we know the first element always goes in zero, so NEXT must always be > 1) */
|
||||
index = *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)previous_item - CMOCK_MEM_INDEX_SIZE);
|
||||
if ((index > 1) && (index < CMock_Guts_FreePtr))
|
||||
{
|
||||
return index;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CMOCK_GUTS_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ void test_MemNewWillReturnNullIfGivenIllegalSizes(void)
|
||||
|
||||
void test_MemShouldProtectAgainstMemoryOverflow(void)
|
||||
{
|
||||
(void)CMock_Guts_MemNew(CMOCK_MEM_SIZE - TEST_MEM_INDEX_SIZE);
|
||||
TEST_ASSERT_NOT_EQUAL_UINT( CMOCK_GUTS_NONE, CMock_Guts_MemNew(CMOCK_MEM_SIZE - TEST_MEM_INDEX_SIZE) );
|
||||
|
||||
//verify we've used all the memory
|
||||
TEST_ASSERT_LESS_OR_EQUAL_UINT32(TEST_MEM_INDEX_SIZE, CMock_Guts_MemBytesFree());
|
||||
|
||||
@@ -41,7 +41,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
end
|
||||
|
||||
it "create and initialize variables to defaults appropriately" do
|
||||
assert_equal(nil, @parser.funcs)
|
||||
assert_nil(@parser.funcs)
|
||||
assert_equal(['const', '__ramfunc', 'funky_attrib', 'SQLITE_API'], @parser.c_attributes)
|
||||
assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
|
||||
end
|
||||
@@ -377,7 +377,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@parser.parse("module", source)
|
||||
end
|
||||
|
||||
assert_equal(nil, @parser.funcs)
|
||||
assert_nil(@parser.funcs)
|
||||
|
||||
# verify exception message
|
||||
begin
|
||||
@@ -401,7 +401,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@parser.parse("module", source)
|
||||
end
|
||||
|
||||
assert_equal(nil, @parser.funcs)
|
||||
assert_nil(@parser.funcs)
|
||||
|
||||
# verify exception message
|
||||
begin
|
||||
@@ -429,7 +429,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@parser.parse("module", source)
|
||||
end
|
||||
|
||||
assert_equal(nil, @parser.funcs)
|
||||
assert_nil(@parser.funcs)
|
||||
|
||||
# verify exception message
|
||||
begin
|
||||
@@ -670,7 +670,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@parser.parse("module", source)
|
||||
end
|
||||
|
||||
assert_equal(nil, @parser.funcs)
|
||||
assert_nil(@parser.funcs)
|
||||
|
||||
# verify exception message
|
||||
begin
|
||||
@@ -699,7 +699,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@parser.parse("module", source)
|
||||
end
|
||||
|
||||
assert_equal(nil, @parser.funcs)
|
||||
assert_nil(@parser.funcs)
|
||||
|
||||
# verify exception message
|
||||
begin
|
||||
|
||||
Reference in New Issue
Block a user