mirror of
https://github.com/meekrosoft/fff
synced 2026-01-23 00:15:59 +01:00
Add googletest library and update makefiles
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,8 +1,10 @@
|
|||||||
all:
|
all:
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
|
cd gtest; make all
|
||||||
cd test; make all
|
cd test; make all
|
||||||
cd examples; make all
|
cd examples; make all
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
cd gtest; make clean
|
||||||
cd test; make clean
|
cd test; make clean
|
||||||
cd examples; make clean
|
cd examples; make clean
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
ruby fakegen.rb > fff.h && make clean && make all && build/fff_test_c && build/fff_test_cpp
|
ruby fakegen.rb > fff3.h && make clean && make all && build/fff_test_c && build/fff_test_cpp
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ CPP = g++
|
|||||||
CPP += -c
|
CPP += -c
|
||||||
LD = g++
|
LD = g++
|
||||||
|
|
||||||
|
GTEST_OBJS = $(BUILD_DIR)/gtest-all.o $(BUILD_DIR)/gtest-main.o
|
||||||
C_OBJFILES = $(BUILD_DIR)/UI_test_ansic.o $(BUILD_DIR)/UI.o
|
C_OBJFILES = $(BUILD_DIR)/UI_test_ansic.o $(BUILD_DIR)/UI.o
|
||||||
TEMPLATE_OBJFILES = $(BUILD_DIR)/test_suite_template.o
|
TEMPLATE_OBJFILES = $(BUILD_DIR)/test_suite_template.o
|
||||||
CPP_OBJFILES = $(BUILD_DIR)/UI_test_cpp.o $(BUILD_DIR)/UI.o
|
CPP_OBJFILES = $(BUILD_DIR)/UI_test_cpp.o $(BUILD_DIR)/UI.o $(GTEST_OBJS)
|
||||||
CPP_LIBS = -lgtest -lpthread -lgtest_main
|
CPP_LIBS = -lpthread
|
||||||
|
|
||||||
|
|
||||||
all: $(C_PROGNAME) $(CPP_PROGNAME) $(TEMPLATE_PROGNAME)
|
all: $(C_PROGNAME) $(CPP_PROGNAME) $(TEMPLATE_PROGNAME)
|
||||||
@@ -42,7 +43,7 @@ $(BUILD_DIR)/%.o: %.c
|
|||||||
$(BUILD_DIR)/%.o: %.cpp
|
$(BUILD_DIR)/%.o: %.cpp
|
||||||
@echo "Compiling "$@
|
@echo "Compiling "$@
|
||||||
@echo " CPP "$<
|
@echo " CPP "$<
|
||||||
$(CPP) -I/home/mlong/tools/gtest/gtest-1.5.0/include -o $@ $<
|
$(CPP) -I.. -o $@ $<
|
||||||
|
|
||||||
$(TEMPLATE_PROGNAME): $(TEMPLATE_OBJFILES)
|
$(TEMPLATE_PROGNAME): $(TEMPLATE_OBJFILES)
|
||||||
@echo "Linking "$@
|
@echo "Linking "$@
|
||||||
@@ -57,7 +58,7 @@ $(C_PROGNAME): $(C_OBJFILES)
|
|||||||
$(CPP_PROGNAME): $(CPP_OBJFILES) $(C_OBJFILES)
|
$(CPP_PROGNAME): $(CPP_OBJFILES) $(C_OBJFILES)
|
||||||
@echo "Linking "$@
|
@echo "Linking "$@
|
||||||
@echo " LD -o "$(CPP_PROGNAME)" "$(CPP_OBJFILES)
|
@echo " LD -o "$(CPP_PROGNAME)" "$(CPP_OBJFILES)
|
||||||
$(LD) -L/home/mlong/tools/gtest -o $(CPP_PROGNAME) $(CPP_OBJFILES) $(CPP_LIBS)
|
$(LD) -o $(CPP_PROGNAME) $(CPP_OBJFILES) $(CPP_LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -276,7 +276,8 @@ def output_c_and_cpp
|
|||||||
|
|
||||||
include_guard {
|
include_guard {
|
||||||
output_constants
|
output_constants
|
||||||
|
define_reset_fake
|
||||||
|
|
||||||
puts "#ifdef __cplusplus"
|
puts "#ifdef __cplusplus"
|
||||||
$cpp_output = true
|
$cpp_output = true
|
||||||
yield
|
yield
|
||||||
@@ -293,7 +294,6 @@ end
|
|||||||
|
|
||||||
# lets generate!!
|
# lets generate!!
|
||||||
output_c_and_cpp{
|
output_c_and_cpp{
|
||||||
define_reset_fake
|
|
||||||
define_call_history
|
define_call_history
|
||||||
define_return_sequence
|
define_return_sequence
|
||||||
output_cpp_reset_code if $cpp_output
|
output_cpp_reset_code if $cpp_output
|
||||||
|
|||||||
22
gtest/Makefile
Normal file
22
gtest/Makefile
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
BUILD_DIR = ../build
|
||||||
|
LIBS := -lpthread
|
||||||
|
CPP_OBJS=$(BUILD_DIR)/gtest-all.o $(BUILD_DIR)/gtest-main.o
|
||||||
|
|
||||||
|
SOURCES=gtest-all.cc gtest-main.cc
|
||||||
|
|
||||||
|
|
||||||
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
|
$(BUILD_DIR)/%.o: %.cc
|
||||||
|
@echo 'Building file: $<'
|
||||||
|
@echo 'Invoking: GCC C++ Compiler'
|
||||||
|
g++ -I../ -O0 -g3 -Wall -c -o"$@" "$<"
|
||||||
|
@echo 'Finished building: $<'
|
||||||
|
@echo ' '
|
||||||
|
|
||||||
|
all: $(CPP_OBJS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-$(RM) $(CPP_OBJS)
|
||||||
|
-@echo ' '
|
||||||
|
|
||||||
9118
gtest/gtest-all.cc
Normal file
9118
gtest/gtest-all.cc
Normal file
File diff suppressed because it is too large
Load Diff
6
gtest/gtest-main.cc
Normal file
6
gtest/gtest-main.cc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "gtest.h"
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
19537
gtest/gtest.h
Normal file
19537
gtest/gtest.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,12 +2,14 @@
|
|||||||
BUILD_DIR = ../build
|
BUILD_DIR = ../build
|
||||||
|
|
||||||
CPP_OBJS += \
|
CPP_OBJS += \
|
||||||
$(BUILD_DIR)/fff_test_cpp.o
|
$(BUILD_DIR)/fff_test_cpp.o \
|
||||||
|
$(BUILD_DIR)/gtest-all.o \
|
||||||
|
$(BUILD_DIR)/gtest-main.o
|
||||||
|
|
||||||
C_OBJS += \
|
C_OBJS += \
|
||||||
$(BUILD_DIR)/fff_test_c.o
|
$(BUILD_DIR)/fff_test_c.o
|
||||||
|
|
||||||
LIBS := -lgtest_main -lgtest -lpthread
|
LIBS := -lpthread
|
||||||
|
|
||||||
CPPNAME = $(BUILD_DIR)/fff_test_cpp
|
CPPNAME = $(BUILD_DIR)/fff_test_cpp
|
||||||
CNAME = $(BUILD_DIR)/fff_test_c
|
CNAME = $(BUILD_DIR)/fff_test_c
|
||||||
@@ -19,14 +21,14 @@ all: $(CPPNAME) $(CNAME)
|
|||||||
$(BUILD_DIR)/%.o: %.cpp
|
$(BUILD_DIR)/%.o: %.cpp
|
||||||
@echo 'Building file: $<'
|
@echo 'Building file: $<'
|
||||||
@echo 'Invoking: GCC C++ Compiler'
|
@echo 'Invoking: GCC C++ Compiler'
|
||||||
g++ -I/home/mlong/tools/gtest/gtest-1.5.0/include -O0 -g3 -Wall -c -o"$@" "$<"
|
g++ -I../ -O0 -g3 -Wall -c -o"$@" "$<"
|
||||||
@echo 'Finished building: $<'
|
@echo 'Finished building: $<'
|
||||||
@echo ' '
|
@echo ' '
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: %.c
|
$(BUILD_DIR)/%.o: %.c
|
||||||
@echo 'Building file: $<'
|
@echo 'Building file: $<'
|
||||||
@echo 'Invoking: GCC C++ Compiler'
|
@echo 'Invoking: GCC C++ Compiler'
|
||||||
gcc -I/home/mlong/tools/gtest/gtest-1.5.0/include -O0 -g3 -Wall -std=c99 -c -o"$@" "$<"
|
gcc -I../ -O0 -g3 -Wall -std=c99 -c -o"$@" "$<"
|
||||||
@echo 'Finished building: $<'
|
@echo 'Finished building: $<'
|
||||||
@echo ' '
|
@echo ' '
|
||||||
|
|
||||||
@@ -35,14 +37,14 @@ $(BUILD_DIR)/%.o: %.c
|
|||||||
$(CPPNAME): $(CPP_OBJS)
|
$(CPPNAME): $(CPP_OBJS)
|
||||||
@echo 'Building target: $@'
|
@echo 'Building target: $@'
|
||||||
@echo 'Invoking: GCC C++ Linker'
|
@echo 'Invoking: GCC C++ Linker'
|
||||||
g++ -L/home/mlong/tools/gtest -o"$(CPPNAME)" $(CPP_OBJS) $(LIBS)
|
g++ -o "$(CPPNAME)" $(CPP_OBJS) $(LIBS)
|
||||||
@echo 'Finished building target: $@'
|
@echo 'Finished building target: $@'
|
||||||
@echo ' '
|
@echo ' '
|
||||||
|
|
||||||
$(CNAME): $(C_OBJS)
|
$(CNAME): $(C_OBJS)
|
||||||
@echo 'Building target: $@'
|
@echo 'Building target: $@'
|
||||||
@echo 'Invoking: GCC C++ Linker'
|
@echo 'Invoking: GCC C++ Linker'
|
||||||
g++ -L/home/mlong/tools/gtest -o"$(CNAME)" $(C_OBJS) $(LIBS)
|
g++ -o "$(CNAME)" $(C_OBJS) $(LIBS)
|
||||||
@echo 'Finished building target: $@'
|
@echo 'Finished building target: $@'
|
||||||
@echo ' '
|
@echo ' '
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#define OVERRIDE_CALL_HIST_LEN 17u
|
#define OVERRIDE_CALL_HIST_LEN 17u
|
||||||
#define FFF_CALL_HISTORY_LEN OVERRIDE_CALL_HIST_LEN
|
#define FFF_CALL_HISTORY_LEN OVERRIDE_CALL_HIST_LEN
|
||||||
|
|
||||||
#include "../fff.h"
|
#include "../fff3.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#define OVERRIDE_CALL_HIST_LEN 17u
|
#define OVERRIDE_CALL_HIST_LEN 17u
|
||||||
#define FFF_CALL_HISTORY_LEN OVERRIDE_CALL_HIST_LEN
|
#define FFF_CALL_HISTORY_LEN OVERRIDE_CALL_HIST_LEN
|
||||||
|
|
||||||
#include "../fff.h"
|
#include "../fff3.h"
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
FAKE_VOID_FUNC(voidfunc1, int);
|
FAKE_VOID_FUNC(voidfunc1, int);
|
||||||
|
|||||||
Reference in New Issue
Block a user