summaryrefslogtreecommitdiff
path: root/test/regression/usbx_hub_hub_status_get_invalid_length_test.c
blob: 249e57767dd3063fdad70bb860f47497368c1205 (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
/***************************************************************************/
/* 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                                            */
/***************************************************************************/

/* This tests the case where the transfer length of the GetHubStatus request is invalid.
   The specific test case is in ux_host_class_hub_status_get.c. */

#include "usbx_ux_test_hub.h"

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

    /* Inform user.  */
    printf("Running Hub Hub Status Get Invalid Length Test...................... ");

    stepinfo("\n");

    initialize_hub(first_unused_memory);
}

static void post_init_host()
{
#if UX_MAX_DEVICES > 1
    UX_TEST_SETUP get_port_status_setup = {0};
    get_port_status_setup.ux_test_setup_request = UX_HOST_CLASS_HUB_GET_STATUS;
    get_port_status_setup.ux_test_setup_type = UX_REQUEST_IN | UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_OTHER;

    UX_TEST_ACTION get_port_status_match_action = {0};
    get_port_status_match_action.usbx_function = UX_TEST_OVERRIDE_UX_HCD_SIM_HOST_ENTRY;
    get_port_status_match_action.function = UX_HCD_TRANSFER_REQUEST;
    get_port_status_match_action.req_action = UX_TEST_SETUP_MATCH_REQUEST | UX_TEST_SIM_REQ_ANSWER;
    get_port_status_match_action.req_setup = &get_port_status_setup;
    get_port_status_match_action.req_actual_len = 3; /* valid length is supposed to be 4. */
    get_port_status_match_action.no_return = 0;
    get_port_status_match_action.status = UX_SUCCESS;

    ux_test_add_action_to_main_list(get_port_status_match_action);

    connect_device_to_hub();
    tx_thread_sleep(100);
    ux_test_wait_for_enum_thread_completion();
    UX_TEST_ASSERT(g_dpump_host_from_system_change_function == UX_NULL);
#endif
}

static void post_init_device()
{
}