1
0
mirror of https://github.com/meekrosoft/fff synced 2026-01-23 16:35:59 +01:00
Files
fff/examples/weak_linking/test/test_common.c
James Fraser 0b9e9f5064 Squashed commit of the following:
commit e5a5749971eb9274679699020a54c91d4053ed79
Author: James Fraser <wulfgar.pro@gmail.com>
Date:   Sun Feb 3 19:57:31 2019 +1100

    PR #47: Minor review fixes to tests files.

commit e9f11b9ec8de8f8d1f0de7b6959c575e15894526
Author: James Fraser <wulfgar.pro@gmail.com>
Date:   Sun Feb 3 19:57:04 2019 +1100

    PR #47: Minor review fixes.

commit 0a7fbeceec
Author: Pauli Salmenrinne <pauli.salmenrinne@pexraytech.com>
Date:   Tue Jan 22 15:11:10 2019 +0200

    Add example for the weak linking

commit 647737304d
Author: susundberg <susundberg@gmail.com>
Date:   Wed Mar 21 13:14:05 2018 +0200

    Add "FFF_FUNCTION_ATTRIBUTES" definition that can be used to declare attributes for functions. More specifically, allow __weak__ attribute.
2019-02-03 20:23:52 +11:00

34 lines
846 B
C

#include "test_common.h"
#include <assert.h>
#include <stdio.h>
char GLOBAL_TEST_bus_read_ret[32];
void spoof_runtime_error( const char* info )
{
fprintf(stderr, "Runtime error: %s\n", info );
assert(0);
}
bool spoof_bus_read_write( uint8_t dev, uint8_t registry, uint8_t* buffer, int len, bool assume_echo )
{
memcpy( buffer, GLOBAL_TEST_bus_read_ret, len );
fprintf(stderr, "bus spoof %d %d\n", (int)dev, (int)registry );
return true;
}
void init_tests()
{
memset( GLOBAL_TEST_bus_read_ret, 0x00, sizeof(GLOBAL_TEST_bus_read_ret));
FFF_RESET_HISTORY();
RESET_FAKE(bus_read_write);
RESET_FAKE(bus_write);
RESET_FAKE(runtime_error);
runtime_error_fake.custom_fake = spoof_runtime_error;
bus_read_write_fake.custom_fake = spoof_bus_read_write;
bus_write_fake.return_val = true;
}