mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-09-14 14:19:58 +00:00
Merge pull request #417 from ThrowTheSwitch/testing/workaround_bundler_issue
Attempt to clear permissions on the bundler scratch file
This commit is contained in:
@@ -16,6 +16,11 @@ jobs:
|
|||||||
name: "Unit Tests"
|
name: "Unit Tests"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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
|
# Install Multilib
|
||||||
- name: Install Multilib
|
- name: Install Multilib
|
||||||
run: |
|
run: |
|
||||||
@@ -34,7 +39,7 @@ jobs:
|
|||||||
sudo gem install bundler
|
sudo gem install bundler
|
||||||
sudo gem install rspec
|
sudo gem install rspec
|
||||||
sudo gem install rubocop -v 0.57.2
|
sudo gem install rubocop -v 0.57.2
|
||||||
bundle install
|
bundle install
|
||||||
|
|
||||||
# Run Tests
|
# Run Tests
|
||||||
- name: Run All Unit Tests
|
- name: Run All Unit Tests
|
||||||
|
|||||||
@@ -137,7 +137,11 @@ class CMockGenerator
|
|||||||
@file_writer.create_file(mock_project[:module_name] + '.c', @subdir) do |file, fullname|
|
@file_writer.create_file(mock_project[:module_name] + '.c', @subdir) do |file, fullname|
|
||||||
blank_project = mock_project.clone
|
blank_project = mock_project.clone
|
||||||
blank_project[:parsed_stuff] = { :functions => [] }
|
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|
|
mock_project[:parsed_stuff][:functions].each do |function|
|
||||||
create_function_skeleton(file, function, existing)
|
create_function_skeleton(file, function, existing)
|
||||||
end
|
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_BufferSize = CMOCK_MEM_ALIGN_SIZE;
|
||||||
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr = CMOCK_MEM_ALIGN_SIZE;
|
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr = CMOCK_MEM_ALIGN_SIZE;
|
||||||
#else
|
#else
|
||||||
static long long CMock_Guts_Space[(CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE + sizeof(long long) - 1) /
|
static long long CMock_Guts_Space[(CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE + sizeof(long long) - 1) / sizeof(long long)];
|
||||||
sizeof(long long)];
|
|
||||||
static unsigned char* CMock_Guts_Buffer = (unsigned char *)CMock_Guts_Space;
|
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;
|
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr = CMOCK_MEM_ALIGN_SIZE;
|
||||||
#endif
|
#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) */
|
/* 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)
|
if (size < 1)
|
||||||
|
{
|
||||||
return CMOCK_GUTS_NONE;
|
return CMOCK_GUTS_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/* verify we have enough room */
|
/* verify we have enough room */
|
||||||
size = size + CMOCK_MEM_INDEX_SIZE;
|
size = size + CMOCK_MEM_INDEX_SIZE;
|
||||||
if (size & CMOCK_MEM_ALIGN_MASK)
|
if (size & CMOCK_MEM_ALIGN_MASK)
|
||||||
|
{
|
||||||
size = (size + CMOCK_MEM_ALIGN_MASK) & ~CMOCK_MEM_ALIGN_MASK;
|
size = (size + CMOCK_MEM_ALIGN_MASK) & ~CMOCK_MEM_ALIGN_MASK;
|
||||||
|
}
|
||||||
if ((CMock_Guts_BufferSize - CMock_Guts_FreePtr) < size)
|
if ((CMock_Guts_BufferSize - CMock_Guts_FreePtr) < size)
|
||||||
{
|
{
|
||||||
#ifndef CMOCK_MEM_DYNAMIC
|
#ifndef CMOCK_MEM_DYNAMIC
|
||||||
@@ -105,9 +108,13 @@ CMOCK_MEM_INDEX_TYPE CMock_Guts_MemChain(CMOCK_MEM_INDEX_TYPE root_index, CMOCK_
|
|||||||
do {
|
do {
|
||||||
index = *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)next - CMOCK_MEM_INDEX_SIZE);
|
index = *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)next - CMOCK_MEM_INDEX_SIZE);
|
||||||
if (index >= CMock_Guts_FreePtr)
|
if (index >= CMock_Guts_FreePtr)
|
||||||
|
{
|
||||||
return CMOCK_GUTS_NONE;
|
return CMOCK_GUTS_NONE;
|
||||||
|
}
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
|
{
|
||||||
next = (void*)(&CMock_Guts_Buffer[index]);
|
next = (void*)(&CMock_Guts_Buffer[index]);
|
||||||
|
}
|
||||||
} while (index > 0);
|
} 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);
|
*(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;
|
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 */
|
/* 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))
|
if ((previous_item_index < CMOCK_MEM_ALIGN_SIZE) || (previous_item_index >= CMock_Guts_FreePtr))
|
||||||
|
{
|
||||||
return CMOCK_GUTS_NONE;
|
return CMOCK_GUTS_NONE;
|
||||||
|
}
|
||||||
previous_item = (void*)(&CMock_Guts_Buffer[previous_item_index]);
|
previous_item = (void*)(&CMock_Guts_Buffer[previous_item_index]);
|
||||||
|
|
||||||
/* if the pointer is good, then use it to look up the next 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) */
|
* (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);
|
index = *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)previous_item - CMOCK_MEM_INDEX_SIZE);
|
||||||
if ((index > 1) && (index < CMock_Guts_FreePtr))
|
if ((index > 1) && (index < CMock_Guts_FreePtr))
|
||||||
|
{
|
||||||
return index;
|
return index;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return CMOCK_GUTS_NONE;
|
return CMOCK_GUTS_NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
/*-------------------------------------------------------
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ void test_MemNewWillReturnNullIfGivenIllegalSizes(void)
|
|||||||
|
|
||||||
void test_MemShouldProtectAgainstMemoryOverflow(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
|
//verify we've used all the memory
|
||||||
TEST_ASSERT_LESS_OR_EQUAL_UINT32(TEST_MEM_INDEX_SIZE, CMock_Guts_MemBytesFree());
|
TEST_ASSERT_LESS_OR_EQUAL_UINT32(TEST_MEM_INDEX_SIZE, CMock_Guts_MemBytesFree());
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "create and initialize variables to defaults appropriately" do
|
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(['const', '__ramfunc', 'funky_attrib', 'SQLITE_API'], @parser.c_attributes)
|
||||||
assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
|
assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
|
||||||
end
|
end
|
||||||
@@ -377,7 +377,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|||||||
@parser.parse("module", source)
|
@parser.parse("module", source)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal(nil, @parser.funcs)
|
assert_nil(@parser.funcs)
|
||||||
|
|
||||||
# verify exception message
|
# verify exception message
|
||||||
begin
|
begin
|
||||||
@@ -401,7 +401,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|||||||
@parser.parse("module", source)
|
@parser.parse("module", source)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal(nil, @parser.funcs)
|
assert_nil(@parser.funcs)
|
||||||
|
|
||||||
# verify exception message
|
# verify exception message
|
||||||
begin
|
begin
|
||||||
@@ -429,7 +429,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|||||||
@parser.parse("module", source)
|
@parser.parse("module", source)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal(nil, @parser.funcs)
|
assert_nil(@parser.funcs)
|
||||||
|
|
||||||
# verify exception message
|
# verify exception message
|
||||||
begin
|
begin
|
||||||
@@ -670,7 +670,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|||||||
@parser.parse("module", source)
|
@parser.parse("module", source)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal(nil, @parser.funcs)
|
assert_nil(@parser.funcs)
|
||||||
|
|
||||||
# verify exception message
|
# verify exception message
|
||||||
begin
|
begin
|
||||||
@@ -699,7 +699,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|||||||
@parser.parse("module", source)
|
@parser.parse("module", source)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal(nil, @parser.funcs)
|
assert_nil(@parser.funcs)
|
||||||
|
|
||||||
# verify exception message
|
# verify exception message
|
||||||
begin
|
begin
|
||||||
|
|||||||
Reference in New Issue
Block a user