1 /* This test is designed to test the ux_utility_descriptor_pack. */
2
3 #include <stdio.h>
4 #include "tx_api.h"
5 #include "ux_api.h"
6 #include "ux_system.h"
7 #include "ux_utility.h"
8
9 #include "ux_host_stack.h"
10 #include "ux_device_stack.h"
11
12
13 #include "ux_test.h"
14
15 /* Define USBX test constants. */
16
17 #define UX_TEST_STACK_SIZE 4096
18 #define UX_TEST_BUFFER_SIZE 2048
19 #define UX_TEST_MEMORY_SIZE (64*1024)
20
21
22 /* Define the counters used in the test application... */
23
24 static ULONG thread_0_counter;
25 static ULONG thread_1_counter;
26 static ULONG error_counter;
27
28 static UCHAR error_callback_ignore = UX_FALSE;
29 static ULONG error_callback_counter;
30
31
32 /* Define USBX test global variables. */
33
34
35 /* Define prototypes for external Host Controller's (HCDs), classes and clients. */
36
37 static TX_THREAD ux_test_thread_simulation_0;
38 static TX_THREAD ux_test_thread_simulation_1;
39 static void ux_test_thread_simulation_0_entry(ULONG);
40 static void ux_test_thread_simulation_1_entry(ULONG);
41
42
43 /* Prototype for test control return. */
44
45 void test_control_return(UINT status);
46
47
48 /* Define what the initial system looks like. */
49
50 #ifdef CTEST
test_application_define(void * first_unused_memory)51 void test_application_define(void *first_unused_memory)
52 #else
53 void usbx_uxe_system_test_application_define(void *first_unused_memory)
54 #endif
55 {
56
57 UINT status;
58 CHAR *stack_pointer;
59 CHAR *memory_pointer;
60
61 /* Inform user. */
62 printf("Running uxe_system APIs Test........................................ ");
63 #if !defined(UX_DEVICE_CLASS_AUDIO_ENABLE_ERROR_CHECKING)
64 #warning Tests skipped due to compile option!
65 printf("SKIP SUCCESS!\n");
66 test_control_return(0);
67 return;
68 #endif
69
70 /* Initialize the free memory pointer. */
71 stack_pointer = (CHAR *) first_unused_memory;
72 memory_pointer = stack_pointer + (UX_TEST_STACK_SIZE * 2);
73 #if 0
74 /* Initialize USBX Memory. */
75 status = ux_system_initialize(memory_pointer, UX_TEST_MEMORY_SIZE, UX_NULL, 0);
76
77 /* Check for error. */
78 if (status != UX_SUCCESS)
79 {
80
81 printf("ERROR #%d\n", __LINE__);
82 test_control_return(1);
83 }
84 #endif
85 /* Create the simulation thread. */
86 status = tx_thread_create(&ux_test_thread_simulation_0, "test simulation", ux_test_thread_simulation_0_entry, 0,
87 stack_pointer, UX_TEST_STACK_SIZE,
88 20, 20, 1, TX_AUTO_START);
89
90 /* Check for error. */
91 if (status != TX_SUCCESS)
92 {
93
94 printf("ERROR #%d\n", __LINE__);
95 test_control_return(1);
96 }
97 }
98
99
ux_test_thread_simulation_0_entry(ULONG arg)100 static void ux_test_thread_simulation_0_entry(ULONG arg)
101 {
102 UINT status;
103 UCHAR *buffer = (UCHAR *)&status;
104
105 /* ux_system_initialize() */
106 status = ux_system_initialize(UX_NULL, UX_TEST_MEMORY_SIZE, UX_NULL, 0);
107 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
108 status = ux_system_initialize(buffer, 0, UX_NULL, 0);
109 UX_TEST_CHECK_CODE(UX_INVALID_PARAMETER, status);
110
111 /* Sleep for a tick to make sure everything is complete. */
112 tx_thread_sleep(1);
113
114 /* Check for errors from other threads. */
115 if (error_counter)
116 {
117
118 /* Test error. */
119 printf("ERROR #%d: total %ld errors\n", __LINE__, error_counter);
120 test_control_return(1);
121 }
122 else
123 {
124
125 /* Successful test. */
126 printf("SUCCESS!\n");
127 test_control_return(0);
128 }
129 }
130