From be1c831d250753b846053790235c1520c2ef9a3e Mon Sep 17 00:00:00 2001 From: Mike Long Date: Thu, 6 Sep 2012 07:45:05 +0800 Subject: [PATCH] Added driver testing example and cleanup the buildandtest script --- buildandtest | 15 +- examples/Makefile | 2 + examples/driver_testing/Makefile | 66 + examples/driver_testing/driver.c | 24 + examples/driver_testing/driver.h | 11 + examples/driver_testing/driver.test.cpp | 52 + examples/driver_testing/driver.test.fff.cpp | 58 + examples/driver_testing/fff.h | 2583 +++++++++++++++++ .../driver_testing/hardware_abstraction.h | 15 + examples/driver_testing/registers.h | 13 + 10 files changed, 2837 insertions(+), 2 deletions(-) create mode 100644 examples/driver_testing/Makefile create mode 100644 examples/driver_testing/driver.c create mode 100644 examples/driver_testing/driver.h create mode 100644 examples/driver_testing/driver.test.cpp create mode 100644 examples/driver_testing/driver.test.fff.cpp create mode 100644 examples/driver_testing/fff.h create mode 100644 examples/driver_testing/hardware_abstraction.h create mode 100644 examples/driver_testing/registers.h diff --git a/buildandtest b/buildandtest index b3fc628..eb3bc12 100755 --- a/buildandtest +++ b/buildandtest @@ -1,3 +1,14 @@ -#!/bin/sh -ruby fakegen.rb > fff.h && make clean && make all && build/fff_test_c && build/fff_test_cpp --gtest_output=xml:build/test_results.xml && build/ui_test_ansic && build/ui_test_cpp --gtest_output=xml:build/example_results.xml && build/fff_test_glob_c && build/fff_test_glob_cpp --gtest_output=xml:build/test_global_results.xml +#!/bin/bash +set -e +ruby fakegen.rb > fff.h +make clean +make all +build/fff_test_c +build/fff_test_cpp --gtest_output=xml:build/test_results.xml +build/ui_test_ansic +build/ui_test_cpp --gtest_output=xml:build/example_results.xml +build/fff_test_glob_c +build/fff_test_glob_cpp --gtest_output=xml:build/test_global_results.xml +build/driver_testing --gtest_output=xml:build/driver_testing.xml +build/driver_testing_fff --gtest_output=xml:build/driver_testing_fff.xml diff --git a/examples/Makefile b/examples/Makefile index 49a2e20..c49de2b 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,5 +1,7 @@ all: cd embedded_ui; make all + cd driver_testing; make all clean: cd embedded_ui; make clean + cd driver_testing; make clean diff --git a/examples/driver_testing/Makefile b/examples/driver_testing/Makefile new file mode 100644 index 0000000..108cb32 --- /dev/null +++ b/examples/driver_testing/Makefile @@ -0,0 +1,66 @@ +$(VERBOSE).SILENT: + +BUILD_DIR = ../../build +TEMPLATE_PROGNAME = $(BUILD_DIR)/template +CPP_PROGNAME_NOFFF = $(BUILD_DIR)/driver_testing +CPP_PROGNAME_FFF = $(BUILD_DIR)/driver_testing_fff +CC = gcc +CC += -c +CPP = g++ +CPP += -c +LD = g++ + +GTEST_OBJS = $(BUILD_DIR)/gtest-all.o $(BUILD_DIR)/gtest-main.o +C_OBJFILES = $(BUILD_DIR)/driver.o +TEMPLATE_OBJFILES = $(BUILD_DIR)/test_suite_template.o +FFF_OBJFILES = $(BUILD_DIR)/driver.test.fff.o $(GTEST_OBJS) +NOFFF_OBJFILES = $(BUILD_DIR)/driver.test.o $(GTEST_OBJS) +CPP_LIBS = -lpthread + + +all: $(CPP_PROGNAME_NOFFF) $(CPP_PROGNAME_FFF) $(TEMPLATE_PROGNAME) + +.PHONY: clean + +clean: + @echo "Cleaning object files" + @echo " rm -f $(BUILD_DIR)/*.o" + rm -f $(BUILD_DIR)/*.o + @echo "Cleaning backups" + @echo " rm -f *~" + rm -f *~ + @echo "Removing programs" + @echo " rm -f "$(C_PROGNAME) + rm -f $(C_PROGNAME) + @echo " rm -f "$(CPP_PROGNAME) $(TEMPLATE_PROGNAME) + rm -f $(CPP_PROGNAME) $(TEMPLATE_PROGNAME) + + +$(BUILD_DIR)/%.o: %.c + @echo "Compiling "$@ + @echo " CC "$< + $(CC) -o $@ $< -DTESTING + +$(BUILD_DIR)/%.o: %.cpp + @echo "Compiling "$@ + @echo " CPP "$< + $(CPP) -I../.. -o $@ $< -DTESTING + +$(TEMPLATE_PROGNAME): $(TEMPLATE_OBJFILES) + @echo "Linking "$@ + @echo " LD -o "ctemplate" "$(TEMPLATE_OBJFILES) + $(LD) -o $(TEMPLATE_PROGNAME) $(TEMPLATE_OBJFILES) + +$(CPP_PROGNAME_FFF): $(FFF_OBJFILES) $(C_OBJFILES) + @echo "Linking "$@ + @echo " LD -o "$(CPP_PROGNAME_FFF)" "$(FFF_OBJFILES) + $(LD) -o $(CPP_PROGNAME_FFF) $(FFF_OBJFILES) $(C_OBJFILES) $(CPP_LIBS) + +$(CPP_PROGNAME_NOFFF): $(NOFFF_OBJFILES) $(C_OBJFILES) + @echo "Linking "$@ + @echo " LD -o "$(CPP_PROGNAME_NOFFF)" "$(NOFFF_OBJFILES) + $(LD) -o $(CPP_PROGNAME_NOFFF) $(NOFFF_OBJFILES) $(C_OBJFILES) $(CPP_LIBS) + +nothing: + @echo "Nothing to do; quitting :(" + @echo "HINT: Try make all" diff --git a/examples/driver_testing/driver.c b/examples/driver_testing/driver.c new file mode 100644 index 0000000..9454ba6 --- /dev/null +++ b/examples/driver_testing/driver.c @@ -0,0 +1,24 @@ + + +#include "hardware_abstraction.h" +#include "registers.h" + +void driver_write(uint8_t val) +{ + IO_MEM_WR8(DRIVER_OUTPUT_REGISTER, val); +} + +uint8_t driver_read() +{ + return IO_MEM_RD8(DRIVER_INPUT_REGISTER); +} + +void driver_init_device() +{ + uint8_t hw_version = IO_MEM_RD8(HARDWARE_VERSION_REGISTER); + if(HARDWARE_REV_B == hw_version) + { + IO_MEM_WR8(DRIVER_PERIPHERAL_ENABLE_REG, 1); + } + IO_MEM_WR8(DRIVER_PERIPHERAL_INITIALIZE_REG, 1); +} diff --git a/examples/driver_testing/driver.h b/examples/driver_testing/driver.h new file mode 100644 index 0000000..b7406d4 --- /dev/null +++ b/examples/driver_testing/driver.h @@ -0,0 +1,11 @@ + +#ifndef DRIVER +#define DRIVER + +#include + +void driver_write(uint8_t val); +uint8_t driver_read(); +void driver_init_device(); + +#endif /*include guard*/ diff --git a/examples/driver_testing/driver.test.cpp b/examples/driver_testing/driver.test.cpp new file mode 100644 index 0000000..e229460 --- /dev/null +++ b/examples/driver_testing/driver.test.cpp @@ -0,0 +1,52 @@ +#if 1 +extern "C" +{ +#include "driver.h" +#include "registers.h" +} +#include "../../fff.h" +#include + + +extern "C" +{ + static uint8_t readVal; + static int readCalled; + static uint32_t readRegister; + uint8_t IO_MEM_RD8(uint32_t reg) + { + readRegister = reg; + readCalled++; + return readVal; + } + + static uint32_t writeRegister; + static uint8_t writeVal; + static int writeCalled; + void IO_MEM_WR8(uint32_t reg, uint8_t val) + { + writeRegister = reg; + writeVal = val; + writeCalled++; + } +} + +TEST(Driver, When_writing_Then_writes_data_to_DRIVER_OUTPUT_REGISTER) +{ + driver_write(0x34); + ASSERT_EQ(1u, writeCalled); + ASSERT_EQ(0x34u, writeVal); + ASSERT_EQ(DRIVER_OUTPUT_REGISTER, writeRegister); +} + + +TEST(Driver, When_reading_data_Then_reads_from_DRIVER_INPUT_REGISTER) +{ + readVal = 0x55; + uint8_t returnedValue = driver_read(); + ASSERT_EQ(1u, readCalled); + ASSERT_EQ(0x55u, returnedValue); + ASSERT_EQ(readRegister, DRIVER_INPUT_REGISTER); +} + +#endif diff --git a/examples/driver_testing/driver.test.fff.cpp b/examples/driver_testing/driver.test.fff.cpp new file mode 100644 index 0000000..b5a1b23 --- /dev/null +++ b/examples/driver_testing/driver.test.fff.cpp @@ -0,0 +1,58 @@ +extern "C"{ + #include "driver.h" + #include "registers.h" +} +#include "../../fff.h" +#include + +DEFINE_FFF_GLOBALS; + +FAKE_VOID_FUNC(IO_MEM_WR8, uint32_t, uint8_t); +FAKE_VALUE_FUNC(uint8_t, IO_MEM_RD8, uint32_t); + +class DriverTest : public testing::Test +{ +public: + void SetUp() + { + RESET_FAKE(IO_MEM_WR8); + RESET_FAKE(IO_MEM_RD8); + FFF_RESET_HISTORY(); + } + +}; + +TEST_F(DriverTest, When_writing_Then_writes_data_to_DRIVER_OUTPUT_REGISTER) +{ + driver_write(0x34); + ASSERT_EQ(1u, IO_MEM_WR8_fake.call_count); + ASSERT_EQ(0x34u, IO_MEM_WR8_fake.arg1_val); + ASSERT_EQ(DRIVER_OUTPUT_REGISTER, IO_MEM_WR8_fake.arg0_val); +} + + +TEST_F(DriverTest, When_reading_data_Then_reads_from_DRIVER_INPUT_REGISTER) +{ + IO_MEM_RD8_fake.return_val = 0x55; + uint8_t returnedValue = driver_read(); + ASSERT_EQ(1u, IO_MEM_RD8_fake.call_count); + ASSERT_EQ(0x55u, returnedValue); + ASSERT_EQ(IO_MEM_RD8_fake.arg0_val, DRIVER_INPUT_REGISTER); +} + +TEST_F(DriverTest, Given_revisionB_device_When_initialize_Then_enable_peripheral_before_initializing_it) +{ + IO_MEM_RD8_fake.return_val = HARDWARE_REV_B; + driver_init_device(); + // Gets the hardware revision + ASSERT_EQ((void*) IO_MEM_RD8, fff.call_history[0]); + ASSERT_EQ(HARDWARE_VERSION_REGISTER, IO_MEM_RD8_fake.arg0_history[0]); + // Enables Peripheral + ASSERT_EQ((void*) IO_MEM_WR8, fff.call_history[1]); + ASSERT_EQ(DRIVER_PERIPHERAL_ENABLE_REG, IO_MEM_WR8_fake.arg0_history[0]); + ASSERT_EQ(1, IO_MEM_WR8_fake.arg1_history[0]); + // Initializes Peripheral + ASSERT_EQ((void*) IO_MEM_WR8, fff.call_history[2]); + ASSERT_EQ(DRIVER_PERIPHERAL_INITIALIZE_REG,IO_MEM_WR8_fake.arg0_history[1]); + ASSERT_EQ(1, IO_MEM_WR8_fake.arg1_history[1]); +} diff --git a/examples/driver_testing/fff.h b/examples/driver_testing/fff.h new file mode 100644 index 0000000..a5f78c5 --- /dev/null +++ b/examples/driver_testing/fff.h @@ -0,0 +1,2583 @@ +#ifndef FAKE_FUNCTIONS +#define FAKE_FUNCTIONS + +#define FFF_MAX_ARGS (10u) +#ifndef FFF_ARG_HISTORY_LEN + #define FFF_ARG_HISTORY_LEN (50u) +#endif +#ifndef FFF_CALL_HISTORY_LEN + #define FFF_CALL_HISTORY_LEN (50u) +#endif +#ifdef __cplusplus + +/* Defining a function to reset a fake function */ +#define RESET_FAKE(FUNCNAME) { \ + FUNCNAME##_reset(); \ +} \ + +static void * call_history[FFF_CALL_HISTORY_LEN]; +static unsigned int call_history_idx; +static void RESET_HISTORY() { + call_history_idx = 0; +} +#define REGISTER_CALL(function) \ + if(call_history_idx < FFF_CALL_HISTORY_LEN) call_history[call_history_idx++] = (void *)function; +#define SET_RETURN_SEQ( FUNCNAME, ARRAY_POINTER, ARRAY_LEN) \ + FUNCNAME##_return_val_seq = ARRAY_POINTER; \ + FUNCNAME##_return_val_seq_len = ARRAY_LEN; +#include +typedef void (*void_fptr)(); +std::vector reset_functions; +static void RESET_FAKES() +{ + std::vector::iterator it = reset_functions.begin(); + for( ; it != reset_functions.end(); ++it) + { + void_fptr ptr = *it; + ptr(); + } + +} +#define STATIC_INIT(FUNCNAME) \ +class StaticInitializer_##FUNCNAME \ +{ \ +public: \ + StaticInitializer_##FUNCNAME() \ + { \ + reset_functions.push_back(FUNCNAME##_reset); \ + } \ +}; \ +static StaticInitializer_##FUNCNAME staticInitializer_##FUNCNAME; \ + + +/* Defining a void function with 0 parameters*/ +#define FAKE_VOID_FUNC0(FUNCNAME) \ +extern "C"{ \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(){ \ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_call_count = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a void function with 1 parameters*/ +#define FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0){ \ + FUNCNAME##_arg0_val = arg0; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_call_count = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a void function with 2 parameters*/ +#define FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_call_count = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a void function with 3 parameters*/ +#define FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_call_count = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a void function with 4 parameters*/ +#define FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_call_count = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a void function with 5 parameters*/ +#define FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_call_count = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a void function with 6 parameters*/ +#define FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_call_count = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a void function with 7 parameters*/ +#define FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_call_count = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a void function with 8 parameters*/ +#define FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static ARG7_TYPE FUNCNAME##_arg7_val; \ + static ARG7_TYPE FUNCNAME##_arg7_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + FUNCNAME##_arg7_val = arg7; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg7_history[FUNCNAME##_call_count] = arg7; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_arg7_val = (ARG7_TYPE) 0; \ + memset(FUNCNAME##_arg7_history, 0, sizeof(FUNCNAME##_arg7_history)); \ + FUNCNAME##_call_count = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a void function with 9 parameters*/ +#define FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static ARG7_TYPE FUNCNAME##_arg7_val; \ + static ARG7_TYPE FUNCNAME##_arg7_history[FFF_ARG_HISTORY_LEN];\ + static ARG8_TYPE FUNCNAME##_arg8_val; \ + static ARG8_TYPE FUNCNAME##_arg8_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + FUNCNAME##_arg7_val = arg7; \ + FUNCNAME##_arg8_val = arg8; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg7_history[FUNCNAME##_call_count] = arg7; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg8_history[FUNCNAME##_call_count] = arg8; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_arg7_val = (ARG7_TYPE) 0; \ + memset(FUNCNAME##_arg7_history, 0, sizeof(FUNCNAME##_arg7_history)); \ + FUNCNAME##_arg8_val = (ARG8_TYPE) 0; \ + memset(FUNCNAME##_arg8_history, 0, sizeof(FUNCNAME##_arg8_history)); \ + FUNCNAME##_call_count = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a function returning a value with 0 parameters*/ +#define FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ +extern "C"{ \ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(){ \ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a function returning a value with 1 parameters*/ +#define FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0){ \ + FUNCNAME##_arg0_val = arg0; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a function returning a value with 2 parameters*/ +#define FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a function returning a value with 3 parameters*/ +#define FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a function returning a value with 4 parameters*/ +#define FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a function returning a value with 5 parameters*/ +#define FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a function returning a value with 6 parameters*/ +#define FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a function returning a value with 7 parameters*/ +#define FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a function returning a value with 8 parameters*/ +#define FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static ARG7_TYPE FUNCNAME##_arg7_val; \ + static ARG7_TYPE FUNCNAME##_arg7_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + FUNCNAME##_arg7_val = arg7; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg7_history[FUNCNAME##_call_count] = arg7; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_arg7_val = (ARG7_TYPE) 0; \ + memset(FUNCNAME##_arg7_history, 0, sizeof(FUNCNAME##_arg7_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + + +/* Defining a function returning a value with 9 parameters*/ +#define FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ +extern "C"{ \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static ARG7_TYPE FUNCNAME##_arg7_val; \ + static ARG7_TYPE FUNCNAME##_arg7_history[FFF_ARG_HISTORY_LEN];\ + static ARG8_TYPE FUNCNAME##_arg8_val; \ + static ARG8_TYPE FUNCNAME##_arg8_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + FUNCNAME##_arg7_val = arg7; \ + FUNCNAME##_arg8_val = arg8; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg7_history[FUNCNAME##_call_count] = arg7; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg8_history[FUNCNAME##_call_count] = arg8; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_arg7_val = (ARG7_TYPE) 0; \ + memset(FUNCNAME##_arg7_history, 0, sizeof(FUNCNAME##_arg7_history)); \ + FUNCNAME##_arg8_val = (ARG8_TYPE) 0; \ + memset(FUNCNAME##_arg8_history, 0, sizeof(FUNCNAME##_arg8_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ +} \ +STATIC_INIT(FUNCNAME) \ + +#else /* ansi c */ + +/* Defining a function to reset a fake function */ +#define RESET_FAKE(FUNCNAME) { \ + FUNCNAME##_reset(); \ +} \ + +static void * call_history[FFF_CALL_HISTORY_LEN]; +static unsigned int call_history_idx; +static void RESET_HISTORY() { + call_history_idx = 0; +} +#define REGISTER_CALL(function) \ + if(call_history_idx < FFF_CALL_HISTORY_LEN) call_history[call_history_idx++] = (void *)function; +#define SET_RETURN_SEQ( FUNCNAME, ARRAY_POINTER, ARRAY_LEN) \ + FUNCNAME##_return_val_seq = ARRAY_POINTER; \ + FUNCNAME##_return_val_seq_len = ARRAY_LEN; + +/* Defining a void function with 0 parameters*/ +#define FAKE_VOID_FUNC0(FUNCNAME) \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(){ \ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_call_count = 0; \ + } \ + + +/* Defining a void function with 1 parameters*/ +#define FAKE_VOID_FUNC1(FUNCNAME, ARG0_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0){ \ + FUNCNAME##_arg0_val = arg0; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_call_count = 0; \ + } \ + + +/* Defining a void function with 2 parameters*/ +#define FAKE_VOID_FUNC2(FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_call_count = 0; \ + } \ + + +/* Defining a void function with 3 parameters*/ +#define FAKE_VOID_FUNC3(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_call_count = 0; \ + } \ + + +/* Defining a void function with 4 parameters*/ +#define FAKE_VOID_FUNC4(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_call_count = 0; \ + } \ + + +/* Defining a void function with 5 parameters*/ +#define FAKE_VOID_FUNC5(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_call_count = 0; \ + } \ + + +/* Defining a void function with 6 parameters*/ +#define FAKE_VOID_FUNC6(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_call_count = 0; \ + } \ + + +/* Defining a void function with 7 parameters*/ +#define FAKE_VOID_FUNC7(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_call_count = 0; \ + } \ + + +/* Defining a void function with 8 parameters*/ +#define FAKE_VOID_FUNC8(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static ARG7_TYPE FUNCNAME##_arg7_val; \ + static ARG7_TYPE FUNCNAME##_arg7_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + FUNCNAME##_arg7_val = arg7; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg7_history[FUNCNAME##_call_count] = arg7; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_arg7_val = (ARG7_TYPE) 0; \ + memset(FUNCNAME##_arg7_history, 0, sizeof(FUNCNAME##_arg7_history)); \ + FUNCNAME##_call_count = 0; \ + } \ + + +/* Defining a void function with 9 parameters*/ +#define FAKE_VOID_FUNC9(FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static ARG7_TYPE FUNCNAME##_arg7_val; \ + static ARG7_TYPE FUNCNAME##_arg7_history[FFF_ARG_HISTORY_LEN];\ + static ARG8_TYPE FUNCNAME##_arg8_val; \ + static ARG8_TYPE FUNCNAME##_arg8_history[FFF_ARG_HISTORY_LEN];\ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + void FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + FUNCNAME##_arg7_val = arg7; \ + FUNCNAME##_arg8_val = arg8; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg7_history[FUNCNAME##_call_count] = arg7; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg8_history[FUNCNAME##_call_count] = arg8; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_arg7_val = (ARG7_TYPE) 0; \ + memset(FUNCNAME##_arg7_history, 0, sizeof(FUNCNAME##_arg7_history)); \ + FUNCNAME##_arg8_val = (ARG8_TYPE) 0; \ + memset(FUNCNAME##_arg8_history, 0, sizeof(FUNCNAME##_arg8_history)); \ + FUNCNAME##_call_count = 0; \ + } \ + + +/* Defining a function returning a value with 0 parameters*/ +#define FAKE_VALUE_FUNC0(RETURN_TYPE, FUNCNAME) \ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(){ \ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ + + +/* Defining a function returning a value with 1 parameters*/ +#define FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0){ \ + FUNCNAME##_arg0_val = arg0; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ + + +/* Defining a function returning a value with 2 parameters*/ +#define FAKE_VALUE_FUNC2(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ + + +/* Defining a function returning a value with 3 parameters*/ +#define FAKE_VALUE_FUNC3(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ + + +/* Defining a function returning a value with 4 parameters*/ +#define FAKE_VALUE_FUNC4(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ + + +/* Defining a function returning a value with 5 parameters*/ +#define FAKE_VALUE_FUNC5(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ + + +/* Defining a function returning a value with 6 parameters*/ +#define FAKE_VALUE_FUNC6(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ + + +/* Defining a function returning a value with 7 parameters*/ +#define FAKE_VALUE_FUNC7(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ + + +/* Defining a function returning a value with 8 parameters*/ +#define FAKE_VALUE_FUNC8(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static ARG7_TYPE FUNCNAME##_arg7_val; \ + static ARG7_TYPE FUNCNAME##_arg7_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + FUNCNAME##_arg7_val = arg7; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg7_history[FUNCNAME##_call_count] = arg7; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_arg7_val = (ARG7_TYPE) 0; \ + memset(FUNCNAME##_arg7_history, 0, sizeof(FUNCNAME##_arg7_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ + + +/* Defining a function returning a value with 9 parameters*/ +#define FAKE_VALUE_FUNC9(RETURN_TYPE, FUNCNAME, ARG0_TYPE, ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE, ARG6_TYPE, ARG7_TYPE, ARG8_TYPE) \ + static ARG0_TYPE FUNCNAME##_arg0_val; \ + static ARG0_TYPE FUNCNAME##_arg0_history[FFF_ARG_HISTORY_LEN];\ + static ARG1_TYPE FUNCNAME##_arg1_val; \ + static ARG1_TYPE FUNCNAME##_arg1_history[FFF_ARG_HISTORY_LEN];\ + static ARG2_TYPE FUNCNAME##_arg2_val; \ + static ARG2_TYPE FUNCNAME##_arg2_history[FFF_ARG_HISTORY_LEN];\ + static ARG3_TYPE FUNCNAME##_arg3_val; \ + static ARG3_TYPE FUNCNAME##_arg3_history[FFF_ARG_HISTORY_LEN];\ + static ARG4_TYPE FUNCNAME##_arg4_val; \ + static ARG4_TYPE FUNCNAME##_arg4_history[FFF_ARG_HISTORY_LEN];\ + static ARG5_TYPE FUNCNAME##_arg5_val; \ + static ARG5_TYPE FUNCNAME##_arg5_history[FFF_ARG_HISTORY_LEN];\ + static ARG6_TYPE FUNCNAME##_arg6_val; \ + static ARG6_TYPE FUNCNAME##_arg6_history[FFF_ARG_HISTORY_LEN];\ + static ARG7_TYPE FUNCNAME##_arg7_val; \ + static ARG7_TYPE FUNCNAME##_arg7_history[FFF_ARG_HISTORY_LEN];\ + static ARG8_TYPE FUNCNAME##_arg8_val; \ + static ARG8_TYPE FUNCNAME##_arg8_history[FFF_ARG_HISTORY_LEN];\ + static RETURN_TYPE FUNCNAME##_return_val; \ + static int FUNCNAME##_return_val_seq_len = 0; \ + static int FUNCNAME##_return_val_seq_idx = 0; \ + static RETURN_TYPE * FUNCNAME##_return_val_seq = 0; \ + static unsigned int FUNCNAME##_call_count = 0; \ + static unsigned int FUNCNAME##_arg_history_len = FFF_ARG_HISTORY_LEN;\ + static unsigned int FUNCNAME##_arg_histories_dropped = 0; \ + RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2, ARG3_TYPE arg3, ARG4_TYPE arg4, ARG5_TYPE arg5, ARG6_TYPE arg6, ARG7_TYPE arg7, ARG8_TYPE arg8){ \ + FUNCNAME##_arg0_val = arg0; \ + FUNCNAME##_arg1_val = arg1; \ + FUNCNAME##_arg2_val = arg2; \ + FUNCNAME##_arg3_val = arg3; \ + FUNCNAME##_arg4_val = arg4; \ + FUNCNAME##_arg5_val = arg5; \ + FUNCNAME##_arg6_val = arg6; \ + FUNCNAME##_arg7_val = arg7; \ + FUNCNAME##_arg8_val = arg8; \ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg0_history[FUNCNAME##_call_count] = arg0; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg1_history[FUNCNAME##_call_count] = arg1; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg2_history[FUNCNAME##_call_count] = arg2; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg3_history[FUNCNAME##_call_count] = arg3; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg4_history[FUNCNAME##_call_count] = arg4; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg5_history[FUNCNAME##_call_count] = arg5; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg6_history[FUNCNAME##_call_count] = arg6; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg7_history[FUNCNAME##_call_count] = arg7; \ + }\ + if(FUNCNAME##_call_count < FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg8_history[FUNCNAME##_call_count] = arg8; \ + }\ + if(FUNCNAME##_call_count >= FUNCNAME##_arg_history_len){\ + FUNCNAME##_arg_histories_dropped++;\ + }\ + FUNCNAME##_call_count++; \ + REGISTER_CALL(FUNCNAME); \ + if(FUNCNAME##_return_val_seq_len){ /* then its a sequence */ \ + if(FUNCNAME##_return_val_seq_idx < FUNCNAME##_return_val_seq_len) {\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_idx++];\ + }\ + return FUNCNAME##_return_val_seq[FUNCNAME##_return_val_seq_len-1]; /* return last element */\ + } \ + return FUNCNAME##_return_val; \ + } \ + void FUNCNAME##_reset(){ \ + FUNCNAME##_arg0_val = (ARG0_TYPE) 0; \ + memset(FUNCNAME##_arg0_history, 0, sizeof(FUNCNAME##_arg0_history)); \ + FUNCNAME##_arg1_val = (ARG1_TYPE) 0; \ + memset(FUNCNAME##_arg1_history, 0, sizeof(FUNCNAME##_arg1_history)); \ + FUNCNAME##_arg2_val = (ARG2_TYPE) 0; \ + memset(FUNCNAME##_arg2_history, 0, sizeof(FUNCNAME##_arg2_history)); \ + FUNCNAME##_arg3_val = (ARG3_TYPE) 0; \ + memset(FUNCNAME##_arg3_history, 0, sizeof(FUNCNAME##_arg3_history)); \ + FUNCNAME##_arg4_val = (ARG4_TYPE) 0; \ + memset(FUNCNAME##_arg4_history, 0, sizeof(FUNCNAME##_arg4_history)); \ + FUNCNAME##_arg5_val = (ARG5_TYPE) 0; \ + memset(FUNCNAME##_arg5_history, 0, sizeof(FUNCNAME##_arg5_history)); \ + FUNCNAME##_arg6_val = (ARG6_TYPE) 0; \ + memset(FUNCNAME##_arg6_history, 0, sizeof(FUNCNAME##_arg6_history)); \ + FUNCNAME##_arg7_val = (ARG7_TYPE) 0; \ + memset(FUNCNAME##_arg7_history, 0, sizeof(FUNCNAME##_arg7_history)); \ + FUNCNAME##_arg8_val = (ARG8_TYPE) 0; \ + memset(FUNCNAME##_arg8_history, 0, sizeof(FUNCNAME##_arg8_history)); \ + FUNCNAME##_call_count = 0; \ + memset(&FUNCNAME##_return_val, 0, sizeof(FUNCNAME##_return_val)); \ + FUNCNAME##_return_val_seq_len = 0; \ + FUNCNAME##_return_val_seq_idx = 0; \ + FUNCNAME##_return_val_seq = 0; \ + } \ + +#endif /* cpp/ansi c */ + +#define PP_NARG_MINUS2(...) PP_NARG_MINUS2_(__VA_ARGS__, PP_RSEQ_N_MINUS2()) + +#define PP_NARG_MINUS2_(...) PP_ARG_MINUS2_N(__VA_ARGS__) + +#define PP_ARG_MINUS2_N(returnVal, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N + +#define PP_RSEQ_N_MINUS2() 9,8,7,6,5,4,3,2,1,0 + + +#define FAKE_VALUE_FUNC(...) FUNC_VALUE_(PP_NARG_MINUS2(__VA_ARGS__), __VA_ARGS__) + +#define FUNC_VALUE_(N,...) FUNC_VALUE_N(N,__VA_ARGS__) + +#define FUNC_VALUE_N(N,...) FAKE_VALUE_FUNC ## N(__VA_ARGS__) + + + +#define PP_NARG_MINUS1(...) PP_NARG_MINUS1_(__VA_ARGS__, PP_RSEQ_N_MINUS1()) + +#define PP_NARG_MINUS1_(...) PP_ARG_MINUS1_N(__VA_ARGS__) + +#define PP_ARG_MINUS1_N(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N + +#define PP_RSEQ_N_MINUS1() 9,8,7,6,5,4,3,2,1,0 + +#define FAKE_VOID_FUNC(...) FUNC_VOID_(PP_NARG_MINUS1(__VA_ARGS__), __VA_ARGS__) + +#define FUNC_VOID_(N,...) FUNC_VOID_N(N,__VA_ARGS__) + +#define FUNC_VOID_N(N,...) FAKE_VOID_FUNC ## N(__VA_ARGS__) + + +#endif // FAKE_FUNCTIONS diff --git a/examples/driver_testing/hardware_abstraction.h b/examples/driver_testing/hardware_abstraction.h new file mode 100644 index 0000000..affa92e --- /dev/null +++ b/examples/driver_testing/hardware_abstraction.h @@ -0,0 +1,15 @@ +#ifndef HARDWARE_ABSTRACTION +#define HARDWARE_ABSTRACTION + +#include + +#ifndef TESTING +#define IO_MEM_RD8(ADDR) (*((volatile uint8_t *)(ADDR))) +#define IO_MEM_WR8(ADDR, VAL_8) (*((volatile uint8_t *)(ADDR)) = (VAL_8)) +#else +/* In testing use fake functions to record calls to IO memory */ +uint8_t IO_MEM_RD8(uint32_t reg); +void IO_MEM_WR8(uint32_t reg, uint8_t val); +#endif + +#endif /* Include guard */ diff --git a/examples/driver_testing/registers.h b/examples/driver_testing/registers.h new file mode 100644 index 0000000..5c9e5a9 --- /dev/null +++ b/examples/driver_testing/registers.h @@ -0,0 +1,13 @@ +#ifndef REGISTERS_H_ +#define REGISTERS_H_ + +#define DRIVER_OUTPUT_REGISTER 0xFFAAu +#define DRIVER_INPUT_REGISTER 0XFFABu +#define DRIVER_PERIPHERAL_ENABLE_REG 0xFFACu +#define DRIVER_PERIPHERAL_INITIALIZE_REG 0xFFACu + +#define HARDWARE_VERSION_REGISTER 0xFF00u +#define HARDWARE_REV_A 0x00u +#define HARDWARE_REV_B 0x01u + +#endif /* REGISTERS_H_ */