1 #ifndef __TEST_UTILITY_H
2 #define __TEST_UTILITY_H
3
4 extern void test_control_return(UINT status);
5
6 // Utility function to print buffer
print_buffer(const UCHAR * buf,ULONG size)7 static void print_buffer(const UCHAR* buf, ULONG size)
8 {
9 UINT i;
10 printf("Buffer of size: %ld. Data:\n", size);
11 if(buf)
12 {
13 for(i = 0; i < size; ++i)
14 {
15 printf("%02x ", (UINT)buf[i]);
16 if((i+1) % 8 == 0)
17 {
18 printf("\n");
19 }
20 }
21 }
22 else
23 {
24 printf("NULL buffer passed as number\n");
25 }
26 printf("\n");
27 }
28
29
30 UINT _txe_mutex_get(TX_MUTEX *mutex_ptr, ULONG wait_option);
31 UINT _txe_mutex_put(TX_MUTEX *mutex_ptr);
32
33
34 #define TEST(prefix, name) void prefix ## _ ##name()
35 #define EXPECT_EQ(expected, actual) \
36 if(expected != actual) \
37 { \
38 printf("\nERROR! File: %s Line: %d\n", __FILE__, __LINE__); \
39 printf("Expected: 0x%x, (%d) Got: 0x%x (%d)\n", expected, expected, actual, actual); \
40 test_control_return(1); \
41 }
42
43 #define EXPECT_TRUE(statement) \
44 if(!statement) \
45 { \
46 printf("\nERROR! File: %s Line: %d\n", __FILE__, __LINE__); \
47 printf("Expected statement to be true!\n"); \
48 test_control_return(1); \
49 }
50
51
52
53 #endif
54