Skip to content

Commit

Permalink
Merge d6a6b53 into 7e09f07
Browse files Browse the repository at this point in the history
  • Loading branch information
yperess authored Sep 27, 2021
2 parents 7e09f07 + d6a6b53 commit 4e3e8d6
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 52 deletions.
2 changes: 1 addition & 1 deletion examples/embedded_ui/test_suite_template.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../../test/c_test_framework.h"
#include "../../test/framework/c_test_framework.h"

/* Initialializers called for every test */
void setup()
Expand Down
10 changes: 6 additions & 4 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ $(BUILD_DIR)/global_fakes.o \
$(BUILD_DIR)/gtest-all.o \
$(BUILD_DIR)/gtest-main.o

FFF_TEST_C_OBJS = $(BUILD_DIR)/fff_test_c.o
FFF_TEST_C_OBJS = $(BUILD_DIR)/fff_test_c.o $(BUILD_DIR)/main_c.o

FFF_TEST_GLOBAL_C_OBJS += \
$(BUILD_DIR)/global_fakes.o \
$(BUILD_DIR)/fff_test_global_c.o
$(BUILD_DIR)/fff_test_global_c.o \
$(BUILD_DIR)/main_c.o

FFF_TEST_CPP_TARGET = $(BUILD_DIR)/fff_test_cpp
FFF_TEST_C_TARGET = $(BUILD_DIR)/fff_test_c
FFF_TEST_GLOBAL_C_TARGET = $(BUILD_DIR)/fff_test_glob_c
FFF_TEST_GLOBAL_CPP_TARGET = $(BUILD_DIR)/fff_test_glob_cpp

LIBS := -lpthread
INCLUDES := -I../ -I../test/framework/
# All Target
all: $(FFF_TEST_CPP_TARGET) $(FFF_TEST_C_TARGET) $(FFF_TEST_GLOBAL_C_TARGET) $(FFF_TEST_GLOBAL_CPP_TARGET)

Expand All @@ -32,16 +34,16 @@ all: $(FFF_TEST_CPP_TARGET) $(FFF_TEST_C_TARGET) $(FFF_TEST_GLOBAL_C_TARGET) $(F
$(BUILD_DIR)/%.o: %.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
g++ -I../ -O0 -g3 -Wall -DGTEST_USE_OWN_TR1_TUPLE=1 -c -o "$@" "$<"
g++ $(INCLUDES) -O0 -g3 -Wall -DGTEST_USE_OWN_TR1_TUPLE=1 -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

$(BUILD_DIR)/%.o: %.c
@echo 'Building file: $<'
@echo 'Invoking: GCC C Compiler'
gcc -I../ -O0 -g3 -Wall -std=c99 -c -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
gcc -v $(INCLUDES) -O0 -g3 -Wall -std=c99 -c -o "$@" "$<"


# Link targets
Expand Down
21 changes: 2 additions & 19 deletions test/fff_test_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@
#define OVERRIDE_CALL_HIST_LEN 17u
#define FFF_CALL_HISTORY_LEN OVERRIDE_CALL_HIST_LEN

#include "../fff.h"
#include "fff.h"
#include "c_test_framework.h"

#include <assert.h>
#include <stdio.h>
#include <string.h>



enum MYBOOL { FALSE = 899, TRUE };
struct MyStruct {
Expand Down Expand Up @@ -72,14 +67,8 @@ TEST_F(FFFTestSuite, default_constants_can_be_overridden)
}

DEFINE_FFF_GLOBALS;
int main()
void fff_test_suite()
{
setbuf(stdout, NULL);
fprintf(stdout, "-------------\n");
fprintf(stdout, "Running Tests\n");
fprintf(stdout, "-------------\n\n");
fflush(0);

/* Run tests */
RUN_TEST(FFFTestSuite, when_void_func_never_called_then_callcount_is_zero);
RUN_TEST(FFFTestSuite, when_void_func_called_once_then_callcount_is_one);
Expand Down Expand Up @@ -123,10 +112,4 @@ int main()

RUN_TEST(FFFTestSuite, can_capture_upto_20_arguments_correctly);
RUN_TEST(FFFTestSuite, value_func_can_capture_upto_20_arguments_correctly);

printf("\n-------------\n");
printf("Complete\n");
printf("-------------\n\n");

return 0;
}
14 changes: 1 addition & 13 deletions test/fff_test_global_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ void setup()
#include "test_cases.include"


int main()
void fff_test_suite()
{
setbuf(stdout, NULL);
fprintf(stdout, "-------------\n");
fprintf(stdout, "Running Tests\n");
fprintf(stdout, "-------------\n\n");
fflush(0);

/* Run tests */
RUN_TEST(FFFTestSuite, when_void_func_never_called_then_callcount_is_zero);
RUN_TEST(FFFTestSuite, when_void_func_called_once_then_callcount_is_one);
Expand Down Expand Up @@ -75,10 +69,4 @@ int main()

RUN_TEST(FFFTestSuite, can_capture_upto_20_arguments_correctly);
RUN_TEST(FFFTestSuite, value_func_can_capture_upto_20_arguments_correctly);

printf("\n-------------\n");
printf("Complete\n");
printf("-------------\n\n");

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

/* Test Framework :-) */
void setup();
void fff_test_suite();

#define PRINTF(FMT, ...) printf(FMT, __VA_ARGS__)

#define TEST_F(SUITE, NAME) void NAME()
#define RUN_TEST(SUITE, TESTNAME) do { printf(" Running %s.%s: \n", #SUITE, #TESTNAME); setup(); TESTNAME(); printf(" SUCCESS\n"); } while (0)
#define RUN_TEST(SUITE, TESTNAME) do { PRINTF(stdout, " Running %s.%s: \n", #SUITE, #TESTNAME); setup(); TESTNAME(); PRINTF(stdout, " SUCCESS\n"); } while (0)
#define ASSERT_EQ(A, B) assert((A) == (B))
#define ASSERT_TRUE(A) assert((A))

Expand Down
17 changes: 17 additions & 0 deletions test/main_c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "c_test_framework.h"

int main()
{
setbuf(stdout, NULL);
fprintf(stdout, "-------------\n");
fprintf(stdout, "Running Tests\n");
fprintf(stdout, "-------------\n\n");
fflush(0);

fff_test_suite();

printf("\n-------------\n");
printf("Complete\n");
printf("-------------\n\n");
return 0;
}
11 changes: 6 additions & 5 deletions test/ms_vc_fff_test/ms_vc_fff_test_c/ms_vc_fff_test_c.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\fff_test_c.c" />
<ClCompile Include="..\..\main_c.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\fff.h" />
<ClInclude Include="..\..\c_test_framework.h" />
<ClInclude Include="..\..\framework\c_test_framework.h" />
</ItemGroup>
<PropertyGroup>
<CustomBuildBeforeTargets>ClCompile</CustomBuildBeforeTargets>
Expand Down Expand Up @@ -81,16 +82,16 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(SolutionDir)..\..\test\framework;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(SolutionDir)..\..\test\framework;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(SolutionDir)..\..\test\framework;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(IncludePath)</IncludePath>
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(SolutionDir)..\..\test\framework;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
<ClCompile Include="..\..\fff_test_c.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\main_c.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\c_test_framework.h">
<ClInclude Include="..\..\framework\c_test_framework.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\fff.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(SolutionDir)..\..\test\framework;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(SolutionDir)..\..\test\framework;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(SolutionDir)..\..\test\framework;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<IncludePath>$(SolutionDir)..\..\gtest;$(SolutionDir)..\..\;$(SolutionDir)..\..\test\framework;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
Expand Down Expand Up @@ -133,12 +133,13 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\main_c.c" />
<ClCompile Include="..\..\fff_test_global_c.c" />
<ClCompile Include="..\..\global_fakes.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\fff.h" />
<ClInclude Include="..\..\c_test_framework.h" />
<ClInclude Include="..\..\framework\c_test_framework.h" />
<ClInclude Include="..\..\global_fakes.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@
<ClCompile Include="..\..\global_fakes.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\main_c.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\global_fakes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\c_test_framework.h">
<ClInclude Include="..\..\framework\c_test_framework.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\fff.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>
5 changes: 5 additions & 0 deletions zephyr/module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: fff
build:
cmake-ext: True
kconfig-ext: True

0 comments on commit 4e3e8d6

Please sign in to comment.