summaryrefslogtreecommitdiff
path: root/test/regression/nx_secure_test/tls_test_utility.h
blob: 38a245a640ca751e45cff8ec89d4acc9d0bf7b1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/***************************************************************************/
/* Copyright (c) 2024 Microsoft Corporation                                */
/* Copyright (c) 2026 Eclipse ThreadX contributors                         */
/*                                                                         */
/* This program and the accompanying materials are made available under    */
/* the terms of the MIT License which is available at                      */
/* https://opensource.org/licenses/MIT.                                    */
/*                                                                         */
/* SPDX-License-Identifier: MIT                                            */
/***************************************************************************/

#ifndef __TLS_TEST_UTILITY_H
#define __TLS_TEST_UTILITY_H

#ifndef NX_CRYPTO_STANDALONE_ENABLE
#include "nx_secure_tls_api.h"


void nx_secure_tls_test_init_utility(NX_SECURE_TLS_SESSION *tls_session);

UINT  _txe_mutex_get(TX_MUTEX *mutex_ptr, ULONG wait_option);
UINT  _txe_mutex_put(TX_MUTEX *mutex_ptr);
#else
#include "nx_crypto.h"
#endif

extern void    test_control_return(UINT status);

// Utility function to print buffer
static void print_buffer(const UCHAR* buf, ULONG size)
{
UINT i;
    printf("Buffer of size: %ld. Data:\n", size);
    if(buf)
    {
        for(i = 0; i < size; ++i)
        {
            printf("%02x ", (UINT)buf[i]);
            if((i+1) % 8 == 0)
            {
                printf("\n");
            }
        }
    }
    else
    {
        printf("NULL buffer passed as number\n");
    }
    printf("\n");
}


#define TEST(prefix, name)  void prefix ## _ ##name()
#define EXPECT_EQ(expected, actual) \
    if((expected) != (actual))          \
    {                               \
        printf("\nERROR! File: %s Line: %d\n", __FILE__, __LINE__); \
        printf("Expected: 0x%x, (%d) Got: 0x%x (%d)\n", (UINT)(expected), (INT)(expected), (UINT)(actual), (INT)(actual)); \
        test_control_return(1); \
    }

#define EXPECT_TRUE(statement) \
    if(!(statement))          \
    {                               \
        printf("\nERROR! File: %s Line: %d\n", __FILE__, __LINE__); \
        printf("Expected statement to be true!\n"); \
        test_control_return(1); \
    }



#endif