summaryrefslogtreecommitdiff
path: root/test/regression/usbx_ux_host_class_hid_descriptor_parse_coverage_test.c
blob: b12492929439418b51959a5c65c5bea23035cb91 (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
73
74
75
76
77
78
79
80
/***************************************************************************/
/* 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                                            */
/***************************************************************************/

#include <stdio.h>
#include "tx_api.h"
#include "ux_api.h"
#include "ux_system.h"
#include "ux_utility.h"
#include "ux_hcd_sim_host.h"
#include "ux_test.h"
#include "ux_host_class_hid.h"
#include "ux_test_utility_sim.h"

#define                             UX_DEMO_STACK_SIZE              2048
#define                             UX_DEMO_MEMORY_SIZE             (256*1024)
#define                             UX_DEMO_BUFFER_SIZE             2048

static UX_HOST_CLASS_HID hid;
static UX_DEVICE hid_device;
static UX_CONFIGURATION config;
static UCHAR packed_configuration[100];
// static UX_SYSTEM ux_system;
UCHAR usbx_memory[UX_DEMO_MEMORY_SIZE + (UX_DEMO_STACK_SIZE * 2)];

#ifdef CTEST
void test_application_define(void *first_unused_memory)
#else
void    usbx_ux_host_class_hid_descriptor_parse_coverage_test_application_define(void *first_unused_memory)
#endif
{

UINT status = 0;
UCHAR total_configuration_length = 5;
 UINT  descriptor_type = 0;
CHAR *stack_pointer;
CHAR *memory_pointer;

    /* Inform user.  */
    printf("Running USB host Class HID Descriptor Parse Converge Coverage Test . ");

    /* Initialize the free memory pointer */
    stack_pointer = (CHAR *) usbx_memory;
    memory_pointer = stack_pointer + (UX_DEMO_STACK_SIZE * 2);

    /* Initialize USBX. Memory */
    status = ux_system_initialize(memory_pointer, UX_DEMO_MEMORY_SIZE, UX_NULL,0);
    if (status != UX_SUCCESS)
    {
        printf("ux_system_initialize failed! status = %d\n", status);
        test_control_return(status);
        return;
    }

    // _ux_system = &ux_system;
    hid.ux_host_class_hid_device = &hid_device;
    hid_device.ux_device_current_configuration = &config;
    config.ux_configuration_descriptor.wTotalLength = total_configuration_length;
    hid_device.ux_device_packed_configuration = packed_configuration;
    packed_configuration[0] = total_configuration_length + 1;
    packed_configuration[1] = descriptor_type;
    _ux_host_class_hid_descriptor_parse(&hid);

    packed_configuration[0] = total_configuration_length;
    packed_configuration[1] = descriptor_type;
    _ux_host_class_hid_descriptor_parse(&hid);


    printf("SUCCESS!\n");

    test_control_return(0);
    return;
}