Attention is currently required from: Angel Pons, Anastasia Klimchuk.
1 comment:
File mec1308.c:
Patch Set #1, Line 115: #endif /* UNIT_TEST_ENV */
I was thinking about separate compilation units for a while, how exactly to do this. […]
I guess we could have something like a `hwaccess_unittest.h`, yes. It could be
hooked up via `-include` and `#define __HW_ACCESS_H__`. This way the original
`hwaccess.h` would be bypassed.
It could provide a single definition for the used macros, e.g.
#define OUTB(v, p) test_outb(v, p)
#define INB(p) test_inb(p)
etc.
However, the original `hwaccess.h` provides more than the I/O macros. Maybe
we should split that out?
There are probably many ways to solve the per-driver mocking issue. Two ideas
from the top of my head:
1. Build multiple test binaries, each with its own versions of test_outb() etc.
2. Provide some abstraction via function pointers. e.g. a struct per test with
struct test_io {
void (*outb)(unsigned char value, unsigned short port);
unsigned char (*inb)(unsigned short port);
/* etc. */
}
extern const struct test_io *test_io;
And then before each test, set
test_io = test_io_mec1308;
The test_*() functions would then simply call the respective function in
`test_io`, e.g.:
void test_outb(unsigned char value, unsigned short port)
{
test_io->outb(value, port);
}
To view, visit change 51487. To unsubscribe, or for help writing mail filters, visit settings.