Skip to content

Commit

Permalink
Merge c7ddc83 into 7e09f07
Browse files Browse the repository at this point in the history
  • Loading branch information
yperess committed Sep 27, 2021
2 parents 7e09f07 + c7ddc83 commit 7e5c108
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 42 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, args...) printf(FMT, ##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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
</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 @@ -26,7 +26,7 @@
<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">
Expand Down
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 7e5c108

Please sign in to comment.