summaryrefslogtreecommitdiff
path: root/test/regression/usbx_hub_request_to_hub_itself_test.c
blob: 8321b383af7c559cfa8353e2c2029bc95c131e46 (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
/***************************************************************************/
/* 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 host sends a request to the hub itself and
   not a port. */

#include "usbx_ux_test_hub.h"

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

    /* Inform user.  */
    printf("Running Hub Request To Hub Itself Test.............................. ");

    stepinfo("\n");

    initialize_hub(first_unused_memory);
}

static void post_init_host()
{

    /* We perform this test by creating an action match the hub device request.
       If it matches, then the request USBX sends is correct. */

    UINT command = UX_SET_FEATURE;
    UINT function = UX_HOST_CLASS_HUB_PORT_POWER;

    UX_TEST_SETUP setup = {0};
    setup.ux_test_setup_request = command;
    setup.ux_test_setup_type = UX_REQUEST_OUT | UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_DEVICE;

    UX_TEST_ACTION action = {0};
    action.usbx_function = UX_TEST_OVERRIDE_UX_HCD_SIM_HOST_ENTRY;
    action.function = UX_HCD_TRANSFER_REQUEST;
    action.req_action = UX_TEST_SETUP_MATCH_REQUEST;
    action.req_setup = &setup;
    action.no_return = 0;
    action.status = UX_SUCCESS;
    ux_test_add_action_to_main_list(action);

    UX_TEST_CHECK_SUCCESS(_ux_host_class_hub_feature(g_hub_host, 0, command, function));

    UX_TEST_ASSERT(ux_test_check_actions_empty() == UX_TRUE);
}

static void post_init_device()
{
}