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