summaryrefslogtreecommitdiff
path: root/test/regression/usbxtestcontrol.c
blob: 69863cb444e24273e1d32b1726d6453a7d1e82c4 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
/***************************************************************************/
/* 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 is the test control routine of the USBX kernel.  All tests are dispatched from this routine.  */

#include "tx_api.h"
#include "fx_api.h"
#include "nx_api.h"
#include "ux_api.h"
#include <stdio.h>

#include "ux_test.h"
#include "ux_test_hcd_sim_host.h"
#include "ux_test_dcd_sim_slave.h"
#include "ux_test_utility_sim.h"

#define TEST_STACK_SIZE         6144

/* Define the test control USBX objects...  */

TX_THREAD               test_control_thread;
TX_THREAD               test_thread;


/* Define the test control global variables.   */

ULONG           test_control_return_status;
ULONG           test_control_successful_tests;
ULONG           test_control_failed_tests;
ULONG           test_control_system_errors;



/* Remember the start of free memory.  */

UCHAR           *test_free_memory_ptr;


/* Define the function pointer for ISR dispatch.  */

VOID            (*test_isr_dispatch)(void);


UCHAR           test_control_thread_stack[TEST_STACK_SIZE];
UCHAR           tests_memory[1024*1024*1024];

/* Define the external reference for the preempt disable flag.  */

extern volatile UINT   _tx_thread_preempt_disable;
extern volatile ULONG  _tx_thread_system_state;


/* Define test entry pointer type.  */

typedef  struct TEST_ENTRY_STRUCT
{

VOID        (*test_entry)(void *);
} TEST_ENTRY;

/* Demos */

void    usbx_hid_keyboard_key_press_release_demo_application_define(void *);

/* Define the prototypes for the test entry points.  */

void    usbx_dpump_basic_test_application_define(void *);

/* Utility */

void    usbx_ux_utility_descriptor_pack_test_application_define(void *);
void    usbx_ux_utility_descriptor_parse_test_application_define(void *);
void    usbx_ux_utility_event_flags_test_application_define(void *);
void    usbx_ux_utility_memory_safe_test_application_define(void *);
void    usbx_ux_utility_memory_test_application_define(void *);
void    usbx_ux_utility_mutex_test_application_define(void *);
void    usbx_ux_utility_pci_write_test_application_define(void *);
void    usbx_ux_utility_pci_read_test_application_define(void *);
void    usbx_ux_utility_pci_class_scan_test_application_define(void *);
void    usbx_ux_utility_physical_address_test_application_define(void *);
void    usbx_ux_utility_semaphore_test_application_define(void *);
void    usbx_ux_utility_string_length_check_test_application_define(void *);
void    usbx_ux_utility_thread_create_test_application_define(void *);
void    usbx_ux_utility_thread_schedule_other_test_application_define(void *);
void    usbx_ux_utility_thread_suspend_test_application_define(void *);
void    usbx_ux_utility_thread_identify_test_application_define(void *);
void    usbx_ux_utility_timer_test_application_define(void *);
void    usbx_ux_utility_unicode_to_string_test_application_define(void *);

/* General/stack */
void    usbx_host_stack_new_endpoint_create_overage_test_application_define(void*);
void    usbx_host_stack_class_unregister_coverage_test_application_define(void *);
void    usbx_host_device_basic_test_application_define(void *);
void    usbx_host_device_basic_memory_test_application_define(void *);
void    usbx_host_device_initialize_test_application_define(void *);

void    usbx_device_stack_standard_request_test_application_define(void *);
void    usbx_ux_device_stack_class_register_test_application_define(void *);
void    usbx_ux_device_stack_class_unregister_test_application_define(void *);
void    usbx_ux_device_stack_clear_feature_coverage_test_application_define(void *);
void    usbx_ux_host_stack_uninitialize_test_application_define(void *);
void    usbx_ux_host_stack_hcd_unregister_test_application_define(void *);
void    usbx_ux_host_stack_class_unregister_test_application_define(void *);

/* CDC */

void    usbx_cdc_acm_basic_test_original_application_define(void *);
void    usbx_cdc_acm_basic_test_application_define(void *);
void    usbx_cdc_acm_basic_memory_test_application_define(void *);
void    usbx_cdc_acm_configure_test_application_define(void *);
void    usbx_ux_device_class_cdc_acm_activate_test_application_define(void *);
void    usbx_cdc_acm_device_dtr_rts_reset_on_disconnect_test_application_define(void *);
void    usbx_ux_device_class_cdc_acm_deactivate_test_application_define(void *);
void    usbx_ux_device_class_cdc_acm_ioctl_test_application_define(void *);
void    usbx_ux_device_class_cdc_acm_transmission_test_application_define(void *);
void    usbx_ux_device_class_cdc_acm_write_test_application_define(void *);
void    usbx_ux_device_class_cdc_acm_timeout_test_application_define(void *);
void    usbx_ux_host_class_cdc_acm_activate_test_application_define(void *);
void    usbx_ux_host_class_cdc_acm_capabilities_get_test_application_define(void *);
void    usbx_ux_host_class_cdc_acm_deactivate_test_application_define(void *);
void    usbx_ux_host_class_cdc_acm_endpoints_get_test_application_define(void *);
void    usbx_ux_host_class_cdc_acm_entry_test_application_define(void *);
void    usbx_ux_host_class_cdc_acm_read_test_application_define(void *);
void    usbx_ux_host_class_cdc_acm_transfer_request_completed_test_application_define(void *);
void    usbx_ux_device_class_cdc_acm_bulkout_thread_test_application_define(void *);
void    usbx_uxe_device_cdc_acm_test_application_define(void *);

/* HID */

void    usbx_ux_device_class_hid_basic_memory_test_application_define(void *);
void    usbx_hid_keyboard_basic_test_application_define(void *);
void    usbx_ux_host_class_hid_report_get_test_application_define(void *);
void    usbx_hid_report_descriptor_global_item_test_application_define(void *);
void    usbx_hid_report_descriptor_item_size_test_application_define(void *);
void    usbx_hid_report_descriptor_usages_single_test_application_define(void *);
void    usbx_hid_report_descriptor_usages_min_max_test_application_define(void *);
void    usbx_hid_report_descriptor_multiple_fields_test_application_define(void *);
void    usbx_hid_report_descriptor_single_usage_multiple_data_test_application_define(void *);
void    usbx_hid_report_descriptor_multiple_reports_input_test_application_define(void *);
void    usbx_hid_report_descriptor_multiple_reports_output_test_application_define(void *);
void    usbx_hid_report_descriptor_multiple_reports_feature_test_application_define(void *);
void    usbx_hid_report_descriptor_multiple_fields_and_reports_test(void *);
void    usbx_hid_report_descriptor_previous_report_test_application_define(void *);
void    usbx_hid_report_descriptor_push_pop_test_application_define(void *);
void    usbx_hid_report_descriptor_decompress_test_application_define(void *);
void    usbx_hid_report_descriptor_decompress_array_test_application_define(void *);
void    usbx_hid_report_descriptor_delimiter_test_application_define(void *);
void    usbx_hid_report_descriptor_global_item_persist_test_application_define(void *);
void    usbx_hid_report_descriptor_extended_usage_test_application_define(void *);
void    usbx_hid_report_descriptor_multiple_collections_test_application_define(void *);
void    usbx_hid_report_descriptor_usages_overflow_test_application_define(void *);
void    usbx_hid_report_descriptor_usages_overflow_via_max_test_application_define(void *);
void    usbx_hid_report_descriptor_collection_overflow_test_application_define(void *);
void    usbx_hid_report_descriptor_end_collection_error_test_application_define(void *);
void    usbx_hid_report_descriptor_example_andisplay_test_application_define(void *);
void    usbx_hid_report_descriptor_example_delimit_test_application_define(void *);
void    usbx_hid_report_descriptor_example_digit_test_application_define(void *);
void    usbx_hid_report_descriptor_example_display_test_application_define(void *);
void    usbx_hid_report_descriptor_example_joystk_test_application_define(void *);
void    usbx_hid_report_descriptor_example_keybrd_test_application_define(void *);
void    usbx_hid_report_descriptor_example_monitor_test_application_define(void *);
void    usbx_hid_report_descriptor_example_mouse_test_application_define(void *);
void    usbx_hid_report_descriptor_example_pwr_test_application_define(void *);
void    usbx_hid_report_descriptor_example_remote_test_application_define(void *);
void    usbx_hid_report_descriptor_example_tele_test_application_define(void *);
void    usbx_hid_report_descriptor_get_zero_length_item_data_test_application_define(void *);
void    usbx_hid_report_descriptor_invalid_length_test_application_define(void *);
void    usbx_hid_report_descriptor_invalid_item_test_application_define(void *);
void    usbx_hid_report_descriptor_delimiter_nested_open_test_application_define(void *);
void    usbx_hid_report_descriptor_delimiter_nested_close_test_application_define(void *);
void    usbx_hid_report_descriptor_delimiter_unknown_test_application_define(void *);
void    usbx_hid_report_descriptor_unknown_local_tag_test_application_define(void *);
void    usbx_hid_report_descriptor_unknown_global_tag_test_application_define(void *);
void    usbx_hid_report_descriptor_incoherent_usage_min_max_test_application_define(void *);
void    usbx_hid_report_descriptor_report_size_overflow_test_application_define(void *);
void    usbx_hid_report_descriptor_report_count_overflow_test_application_define(void *);
void    usbx_hid_report_descriptor_push_overflow_tag_test_application_define(void *);
void    usbx_hid_report_descriptor_pop_underflow_tag_test_application_define(void *);
void    usbx_hid_keyboard_extraction_test_application_define(void *);
void    usbx_hid_keyboard_extraction_test2_application_define(void *);
void    usbx_hid_keyboard_callback_test_application_define(void *);
void    usbx_hid_mouse_basic_test_application_define(void *);
void    usbx_hid_mouse_extraction_test_application_define(void *);
void    usbx_hid_mouse_extraction_test2_application_define(void *);
void    usbx_hid_remote_control_tests_application_define(void *);
void    usbx_ux_host_class_hid_remote_control_entry_test2_application_define(void *);
void    usbx_ux_host_class_hid_remote_control_activate_test_application_define(void *);
void    usbx_hid_remote_control_extraction_test_application_define(void *);
void    usbx_hid_remote_control_extraction_test2_application_define(void *);
void    usbx_hid_report_descriptor_compress_test_application_define(void *);
void    usbx_hid_report_descriptor_compress_and_decompress_test_application_define(void *);
void    usbx_hid_transfer_request_completed_test_application_define(void *);
void    usbx_hid_transfer_request_completed_raw_test_application_define(void *);
void    usbx_hid_transfer_request_completed_decompressed_test_application_define(void *);
void    usbx_ux_host_class_hid_client_register_test_application_define(void *);
void    usbx_ux_host_class_hid_report_set_test_application_define(void *);
void    usbx_hid_keyboard_key_get_test_application_define(void *);
void    usbx_ux_host_class_hid_client_search_test_application_define(void *);
void    usbx_ux_device_class_hid_control_request_test_application_define(void *);
void    usbx_ux_device_class_hid_report_set_test_application_define(void *);
void    usbx_ux_device_class_hid_interrupt_thread_test_application_define(void *);
void    usbx_hid_keyboard_key_test_application_define(void *);
void    usbx_hid_keyboard_key_with_report_id_test_application_define(void *);
void    usbx_ux_device_class_hid_descriptor_send_test_application_define(void *);
void    usbx_control_transfer_stall_test(void *);
void    usbx_hid_interrupt_endpoint_get_report_test_application_define(void *);
void    usbx_ux_device_class_hid_event_get_AND_set_test_application_define(void *);
void    usbx_ux_host_class_hid_report_add_test_application_define(void *);
void    usbx_ux_host_class_hid_idle_set_test_application_define(void *);
void    usbx_ux_host_class_hid_interrupt_endpoint_search_test_application_define(void *);
void    usbx_ux_host_class_hid_keyboard_activate_test_application_define(void *);
void    usbx_ux_host_class_hid_report_id_get_test_application_define(void *);
void    usbx_ux_host_class_hid_periodic_report_start_test_application_define(void *);
void    usbx_ux_host_class_hid_descriptor_parse_coverage_test_application_define(void *);
void    usbx_ux_host_class_hid_descriptor_parse_test_application_define(void *);
void    usbx_ux_host_class_hid_descriptor_parse_test2_application_define(void *);
void    usbx_ux_host_class_hid_mouse_activate_test_application_define(void *);
void    usbx_ux_host_class_hid_activate_test_application_define(void *);
void    usbx_ux_host_class_hid_report_callback_register_test_application_define(void *);
void    usbx_ux_host_class_hid_entry_test_application_define(void *);
void    usbx_ux_host_class_hid_periodic_report_stop_test_application_define(void *);
void    usbx_ux_host_class_hid_keyboard_entry_test_application_define(void *);
void    usbx_ux_host_class_hid_keyboard_ioctl_test_application_define(void *);
void    usbx_ux_host_class_hid_mouse_entry_test_application_define(void *);
void    usbx_ux_host_class_hid_mouse_positions_get_test_application_define(void *);
void    usbx_ux_host_class_hid_mouse_buttons_get_test_application_define(void *);
void    usbx_ux_host_class_hid_mouse_wheel_get_test_application_define(void *);
void    usbx_ux_host_class_hid_remote_control_entry_test_application_define(void *);
void    usbx_ux_host_class_hid_remote_control_usage_get_test_application_define(void *);
void    usbx_ux_host_class_hid_configure_test_application_define(void *);
void    usbx_ux_device_class_hid_entry_test_application_define(void *);
void    usbx_ux_device_class_hid_deactivate_test_application_define(void *);
void    usbx_ux_device_class_hid_activate_test_application_define(void *);
void    usbx_ux_host_class_hid_keyboard_thread_test_application_define(void *);
void    usbx_ux_host_class_hid_keyboard_thread_test2_application_define(void *);
void    usbx_ux_host_class_hid_deactivate_test_application_define(void *);
void    usbx_ux_host_class_hid_deactivate_test2_application_define(void *);
void    usbx_ux_host_class_hid_descriptor_parse_test3_application_define(void *);
void    usbx_ux_host_class_hid_descriptor_parse_test4_application_define(void *);
void    usbx_ux_host_class_hid_descriptor_parse_test5_application_define(void *);
void    usbx_ux_host_class_hid_descriptor_parse_test6_application_define(void *);
void    usbx_ux_host_class_hid_descriptor_parse_test7_application_define(void *);
void    usbx_ux_host_class_hid_report_descriptor_get_test_application_define(void *);
void    usbx_ux_device_class_hid_set_protocol_callback_test_application_define(void *);
void    usbx_ux_host_class_hid_remote_control_callback_test_application_define(void *);
void    usbx_ux_host_class_hid_interrupt_endpoint_search_test2_application_define(void *);
void    usbx_ux_host_class_hid_periodic_report_start_test2_application_define(void *);
void    usbx_ux_host_class_hid_report_get_test2_application_define(void *);
void    usbx_ux_host_class_hid_main_item_parse_test_application_define(void *);
void    usbx_ux_host_class_hid_main_item_parse_test2_application_define(void *);
void    usbx_ux_host_class_hid_mouse_entry_test3_application_define(void *);
void    usbx_ux_host_class_hid_mouse_entry_test2_application_define(void *);
void    usbx_ux_host_class_hid_remote_control_entry_test3_application_define(void *);
void    usbx_ux_host_class_hid_transfer_request_completed_test_application_define(void *);
void    usbx_ux_host_class_hid_keyboard_callback_test2_application_define(void *);
void    usbx_ux_host_class_hid_idle_get_test_application_define(void *);
void    usbx_ux_host_class_hid_remote_control_activate_test2_application_define(void *);
void    usbx_ux_host_class_hid_client_register_test2_application_define(void *);
void    usbx_ux_host_class_hid_report_descriptor_get_test_application_define(void *);
void    usbx_ux_host_class_hid_report_descriptor_get_test2_application_define(void *);
void    usbx_ux_host_class_hid_report_descriptor_get_test3_application_define(void *);
void    usbx_ux_host_class_hid_report_descriptor_get_test4_application_define(void *);
void    usbx_ux_host_class_hid_deactivate_test3_application_define(void *);
void    usbx_ux_host_class_hid_local_item_parse_test_application_define(void *);
void    usbx_ux_device_class_hid_uninitialize_test_application_define(void *);
void    usbx_ux_device_class_hid_initialize_test_application_define(void *);
void    usbx_ux_device_class_hid_report_set_test2_application_define(void *);
void    usbx_ux_device_class_hid_activate_test2_application_define(void *);
void    usbx_ux_device_class_hid_activate_test3_application_define(void *);
void    usbx_ux_device_class_hid_interrupt_thread_test2_application_define(void *);
void    usbx_ux_device_class_hid_report_test_application_define(void *);
void    usbx_hid_report_descriptor_compress_array_test_application_define(void *);
void    usbx_ux_device_class_hid_idle_rate_test_application_define(void *);


/* Storage */
void    usbx_host_class_storage_entry_overage_test_application_define(void *);
void    usbx_host_class_storage_max_lun_get_coverage_test_application_define(void *);
void    usbx_storage_basic_memory_test_application_define(void *);
void    usbx_storage_tests_application_define(void *);
void    usbx_storage_multi_lun_test_application_define(void *);
void    usbx_storage_direct_calls_test_application_define(void *);
void    usbx_ux_device_class_storage_vendor_strings_test_application_define(void *);
void    usbx_ux_device_class_storage_test_ready_test_application_define(void *);
void    usbx_ux_device_class_storage_control_request_test_application_define(void *);
void    usbx_ux_device_class_storage_entry_test_application_define(void *);
void    usbx_ux_device_class_storage_format_test_application_define(void *);
void    usbx_ux_device_class_storage_mode_select_test_application_define(void *);
void    usbx_ux_device_class_storage_mode_sense_test_application_define(void *);
void    usbx_ux_device_class_storage_request_sense_test_application_define(void *);
void    usbx_ux_device_class_storage_start_stop_test_application_define(void *);
void    usbx_ux_device_class_storage_media_start_stop_test_application_define(void *);
void    usbx_ux_device_class_storage_prevent_allow_media_removal_test_application_define(void *);
void    usbx_ux_device_class_storage_verify_test_application_define(void *);
void    usbx_ux_device_class_storage_uninitialize_test_application_define(void *);
void    usbx_ux_device_class_storage_inquiry_test_application_define(void *);
void    usbx_ux_device_class_storage_initialize_test_application_define(void *);
void    usbx_ux_device_class_storage_synchronize_cache_test_application_define(void *);
void    usbx_ux_device_class_storage_read_test_application_define(void *);
void    usbx_ux_device_class_storage_write_test_application_define(void *);
void    usbx_ux_device_class_storage_thread_test_application_define(void *);
void    usbx_ux_device_class_storage_request_sense_coverage_test_application_define(void *);
void    usbx_ux_host_class_storage_configure_overage_test_application_define(void *);
void    usbx_ux_host_class_storage_request_sense_test_application_define(void *);
void    usbx_ux_host_class_storage_media_capacity_get_test_application_define(void *);
void    usbx_ux_host_class_storage_max_lun_get_test_application_define(void *);
void    usbx_ux_host_class_storage_configure_test_application_define(void *);
void    usbx_ux_host_class_storage_activate_test_application_define(void *);
void    usbx_ux_host_class_storage_device_support_check_test_application_define(void *);
void    usbx_ux_host_class_storage_device_initialize_test_application_define(void *);
void    usbx_ux_host_class_storage_media_get_test_application_define(void *);
void    usbx_ux_host_class_storage_media_mount_test_application_define(void *);
void    usbx_ux_host_class_storage_media_open_test_application_define(void *);
void    usbx_ux_host_class_storage_media_read_test_application_define(void *);
void    usbx_ux_host_class_storage_media_write_test_application_define(void *);
void    usbx_ux_host_class_storage_media_protection_check_test_application_define(void *);
void    usbx_ux_host_class_storage_media_recovery_sense_get_test_application_define(void *);
void    usbx_ux_host_class_storage_start_stop_test_application_define(void *);
void    usbx_ux_host_class_storage_transport_bo_test_application_define(void *);
void    usbx_ux_host_class_storage_driver_entry_test_application_define(void *);
void    usbx_ux_host_class_storage_entry_test_application_define(void *);

/* RNDIS */

void    usbx_rndis_basic_test_application_define(void *);

/* Host stack */
void    usbx_ux_host_class_stack_device_configuration_reset_coverage_test_application_define(void *);
void    usbx_ux_host_stack_bandwidth_test_application_define(void *);
void    usbx_ux_host_stack_class_device_scan_test_application_define(void *);
void    usbx_ux_host_stack_class_get_test_application_define(void *);
void    usbx_ux_host_stack_class_instance_destroy_test_application_define(void *);
void    usbx_ux_host_stack_class_instance_get_test_application_define(void *);
void    usbx_ux_host_stack_class_instance_verify_test_application_define(void *);
void    usbx_ux_host_stack_class_interface_scan_test_application_define(void *);
void    usbx_ux_host_stack_class_register_test_application_define(void *);
void    usbx_ux_host_stack_configuration_descriptor_parse_test_application_define(void *);
void    usbx_ux_host_stack_configuration_enumerate_test_application_define(void *);
void    usbx_ux_host_stack_configuration_instance_delete_test_application_define(void *);
void    usbx_ux_host_stack_configuration_interface_get_test_application_define(void *);
void    usbx_ux_host_stack_configuration_set_test_application_define(void *);
void    usbx_ux_host_stack_device_address_set_test_application_define(void *);
void    usbx_ux_host_stack_device_get_test_application_define(void *);
void    usbx_ux_host_stack_device_remove_test_application_define(void *);
void    usbx_ux_host_stack_endpoint_instance_create_test_application_define(void *);
void    usbx_ux_host_stack_endpoint_instance_test_application_define(void *);
void    usbx_ux_host_stack_endpoint_reset_test_application_define(void *);
void    usbx_ux_host_stack_hcd_transfer_request_test_application_define(void *);
void    usbx_ux_host_stack_hcd_register_test_application_define(void *);
void    usbx_ux_host_stack_interface_endpoint_get_test_application_define(void *);
void    usbx_ux_host_stack_interface_setting_select_test_application_define(void *);
void    usbx_ux_host_stack_interfaces_scan_test_application_define(void *);
void    usbx_ux_host_stack_new_configuration_create_test_application_define(void *);
void    usbx_ux_host_stack_new_device_get_test_application_define(void *);
void    usbx_ux_host_stack_new_device_create_test_application_define(void *);
void    usbx_ux_host_stack_new_interface_create_test_application_define(void *);
void    usbx_ux_host_stack_rh_change_process_test_application_define(void *);
void    usbx_ux_host_stack_rh_device_insertion_test_application_define(void *);
void    usbx_ux_host_stack_device_configuration_get_test_application_define(void *);
void    usbx_ux_host_stack_device_configuration_reset_select_test_application_define(void *);
void    usbx_ux_host_stack_hcd_thread_entry_test_application_define(void *);
void    usbx_ux_host_stack_transfer_request_test_application_define(void *);
void    usbx_ux_host_class_storage_thread_entry_test_application_define(void *);
//void    usbx_ux_host_stack_transfer_request_abort_test_application_define(void *);

/* Device Stack */
void    usbx_ux_device_stack_alternate_setting_get_test_application_define(void *);
void    usbx_ux_device_stack_alternate_setting_set_test_application_define(void *);
void    usbx_ux_device_stack_configuration_set_test_application_define(void *);
void    usbx_ux_device_stack_control_request_process_coverage_test_application_define(void *);
void    usbx_ux_device_stack_control_request_process_test_application_define(void *);
void    usbx_ux_device_stack_descriptor_send_test_application_define(void *);
void    usbx_ux_host_stack_device_descriptor_read_test_application_define(void *);
void    usbx_ux_device_stack_get_status_test_application_define(void *);
void    usbx_ux_device_stack_interface_delete_test_application_define(void *);
void    usbx_ux_device_stack_interface_set_test_application_define(void *);
void    usbx_ux_device_stack_interface_start_test_application_define(void *);
void    usbx_ux_device_stack_remote_wakeup_test_application_define(void *);
void    usbx_ux_device_stack_set_feature_test_application_define(void *);
void    usbx_ux_device_stack_transfer_request_test_application_define(void *);
void    usbx_ux_device_stack_endpoint_stall_test_application_define(void *);
void    usbx_ux_device_stack_initialize_test_application_define(void *);

/* CDC-ECM */

void    usbx_cdc_ecm_basic_test_application_define(void *);
void    usbx_cdc_ecm_basic_ipv6_test_application_define(void *);
void    usbx_cdc_ecm_disconnect_and_reconnect_test_application_define(void *);
void    usbx_cdc_ecm_alternate_setting_change_to_zero_test_application_define(void *);
void    usbx_ux_host_class_cdc_ecm_transmission_callback_test_application_define(void *);
void    usbx_cdc_ecm_host_bulk_out_transfer_arming_during_link_down_test_application_define(void *);
void    usbx_cdc_ecm_host_bulk_out_transfer_fail_test_application_define(void *);
void    usbx_ux_host_class_cdc_ecm_write_test_application_define(void *);
void    usbx_cdc_ecm_host_bulk_in_transfer_arming_fails_due_to_link_down_and_thread_waiting_test_application_define(void *);
void    usbx_cdc_ecm_host_non_ip_packet_received_test_application_define(void *);
void    usbx_cdc_ecm_host_bulk_in_transfer_fail_test_application_define(void *);
void    usbx_cdc_ecm_host_thread_link_down_before_transfer_test_application_define(void *);
void    usbx_cdc_ecm_host_thread_packet_allocate_fail_test_application_define(void *);
void    usbx_cdc_ecm_mac_address_test_application_define(void *);
void    usbx_cdc_ecm_mac_address_invalid_length_test_application_define(void *);
void    usbx_cdc_ecm_no_functional_descriptor_test_application_define(void *);
void    usbx_ux_host_class_cdc_ecm_mac_address_get_test_application_define(void *);
void    usbx_cdc_ecm_host_bulk_in_transfer_arming_during_link_down_test_application_define(void *);
void    usbx_ux_host_class_cdc_ecm_interrupt_notification_test_application_define(void *);
void    usbx_cdc_ecm_link_down_while_ongoing_transfers_test_application_define(void *);
void    usbx_ux_host_class_cdc_ecm_entry_test_application_define(void *);
void    usbx_cdc_ecm_host_bulk_in_transfer_arming_during_deactivate_test_application_define(void *);
void    usbx_cdc_ecm_host_first_interrupt_transfer_fail_test_application_define(void *);
void    usbx_cdc_ecm_host_packet_pool_create_fail_test_application_define(void *);
void    usbx_cdc_ecm_host_thread_create_fail_test_application_define(void *);
void    usbx_cdc_ecm_host_interrupt_notification_semaphore_create_fail_test_application_define(void *);
void    usbx_cdc_ecm_host_bulk_out_semaphore_create_fail_test_application_define(void *);
void    usbx_cdc_ecm_host_bulk_in_semaphore_create_fail_test_application_define(void *);
void    usbx_cdc_ecm_control_interface_no_interrupt_endpoint_test_application_define(void *);
void    usbx_cdc_ecm_data_interface_no_bulk_in_endpoint_test_application_define(void *);
void    usbx_cdc_ecm_data_interface_non_bulk_out_and_non_bulk_in_endpoint_test_application_define(void *);
void    usbx_cdc_ecm_data_interface_no_bulk_out_endpoint_test_application_define(void *);
void    usbx_cdc_ecm_data_interface_setting_select_fails_test_application_define(void *);
void    usbx_cdc_ecm_invalid_alternate_setting_after_zero_endpoint_data_interface_test_application_define(void *);
void    usbx_cdc_ecm_non_data_interface_after_zero_endpoint_data_interface_test_application_define(void *);
void    usbx_cdc_ecm_one_data_interface_with_no_endpoints_test_application_define(void *);
void    usbx_cdc_ecm_no_control_interface_test_application_define(void *);
void    usbx_cdc_ecm_interface_before_control_interface_test_application_define(void *);
void    usbx_cdc_ecm_basic_memory_test_application_define(void *);
void    usbx_ux_host_class_cdc_ecm_activate_test_application_define(void *);
void    usbx_cdc_ecm_default_data_interface_with_endpoints_test_application_define(void *);
void    usbx_ux_host_class_cdc_ecm_write_test_application_define(void *);
void    usbx_ux_host_class_cdc_ecm_interrupt_notification_test_application_define(void *);
void    usbx_ux_device_class_cdc_ecm_uninitialize_test_application_define(void *);
void    usbx_ux_device_class_cdc_ecm_deactivate_test_application_define(void *);
void    usbx_ux_device_class_cdc_ecm_initialize_test_application_define(void *);
void    usbx_ux_device_class_cdc_ecm_activate_test_application_define(void *);
void    usbx_ux_device_class_cdc_ecm_interrupt_thread_test_application_define(void *);
void    usbx_ux_device_class_cdc_ecm_bulkin_thread_test_application_define(void *);
void    usbx_ux_device_class_cdc_ecm_bulkout_thread_test_application_define(void *);
void    usbx_ux_device_class_cdc_ecm_control_request_test_application_define(void *);
void    usbx_ux_device_class_cdc_ecm_change_test_application_define(void *);
void    usbx_ux_device_class_cdc_ecm_entry_test_application_define(void *);

/* Hub */
void    usbx_host_class_hub_port_change_connection_process_coverage_test_application_define(void *);
void    usbx_hub_basic_test_application_define(void *);
void    usbx_hub_basic_memory_test_application_define(void *);
void    usbx_hub_get_status_fails_during_configuration_test_application_define(void *);
void    usbx_bus_powered_hub_connected_to_self_and_bus_powered_hub_test_application_define(void *);
void    usbx_hub_invalid_hub_descriptor_length_test_application_define(void *);
void    usbx_hub_full_speed_hub_test_application_define(void *);
void    usbx_hub_multiple_tt_test_application_define(void *);
void    usbx_hub_invalid_device_protocol_test_application_define(void *);
void    usbx_ux_host_class_hub_descriptor_get_coverage_test_application_define(void *);
void    usbx_ux_host_class_hub_entry_test_application_define(void *);
void    usbx_hub_request_to_hub_itself_test_application_define(void *);
void    usbx_hub_no_endpoints_test_application_define(void *);
void    usbx_hub_interrupt_out_endpoint_test_application_define(void *);
void    usbx_hub_non_interrupt_in_endpoint_test_application_define(void *);
void    usbx_hub_hub_device_disconnect_test_application_define(void *);
void    usbx_hub_quick_hub_device_reconnection_test_application_define(void *);
void    usbx_hub_hub_device_enumeration_keeps_failing_test_application_define(void *);
void    usbx_hub_port_reset_fails_during_hub_device_enumeration_test_application_define(void *);
void    usbx_hub_get_port_status_fails_during_hub_device_enumeration_test_application_define(void *);
void    usbx_hub_low_speed_hub_device_test_application_define(void *);
void    usbx_hub_full_speed_hub_device_test_application_define(void *);
void    usbx_hub_quick_hub_device_disconnection_test_application_define(void *);
void    usbx_hub_port_change_enable_test_application_define(void *);
void    usbx_hub_get_hub_status_fails_during_hub_device_enumeration_test_application_define(void *);
void    usbx_hub_port_change_suspend_test_application_define(void *);
void    usbx_hub_port_change_over_current_test_application_define(void *);
void    usbx_hub_port_change_reset_test_application_define(void *);
void    usbx_hub_port_reset_fails_due_to_unset_port_enabled_bit_test_application_define(void *);
void    usbx_hub_get_hub_status_fails_during_port_reset_test_application_define(void *);
void    usbx_hub_no_power_switching_test_application_define(void *);
void    usbx_ux_host_class_hub_status_get_test_application_define(void *);
void    usbx_hub_hub_status_get_invalid_length_test_application_define(void *);
void    usbx_ux_host_class_hub_transfer_request_completed_test_application_define(void *);

/* Pictbridge */

void usbx_pictbridge_basic_test_application_define(void *);

/* Audio */

void    usbx_audio10_device_basic_test_application_define(void *);
void    usbx_audio10_iad_device_basic_test_application_define(void *);
void    usbx_audio10_iad_device_control_test_application_define(void *);
void    usbx_audio20_device_basic_test_application_define(void *);
void    usbx_uxe_device_audio_test_application_define(void *);

/* Video */

void    usbx_host_class_video_basic_test_application_define(void *);

/* Printer */

void    usbx_host_class_printer_basic_test_application_define(void *);
void    usbx_uxe_device_printer_test_application_define(void *);


/* CTest application define  */

void test_application_define(void *first_unused_memory);

/* Define the array of test entry points.  */

TEST_ENTRY  test_control_tests[] =
{
#ifdef CTEST
    test_application_define,
#else

    /* MSC */
    // usbx_storage_tests_application_define,
    usbx_host_class_storage_entry_overage_test_application_define,
    usbx_host_class_storage_max_lun_get_coverage_test_application_define,

    usbx_host_stack_new_endpoint_create_overage_test_application_define,
    usbx_host_stack_class_unregister_coverage_test_application_define,
    usbx_storage_basic_memory_test_application_define,
    usbx_storage_multi_lun_test_application_define,
    usbx_ux_device_class_storage_request_sense_coverage_test_application_define,
    usbx_ux_device_class_storage_vendor_strings_test_application_define,
    usbx_ux_device_class_storage_test_ready_test_application_define,
    usbx_ux_device_class_storage_control_request_test_application_define,
    usbx_ux_device_class_storage_entry_test_application_define,
    usbx_ux_device_class_storage_format_test_application_define,
    usbx_ux_device_class_storage_mode_select_test_application_define,
    usbx_ux_device_class_storage_mode_sense_test_application_define,
    usbx_ux_device_class_storage_request_sense_test_application_define,
    usbx_ux_device_class_storage_start_stop_test_application_define,
    usbx_ux_device_class_storage_media_start_stop_test_application_define,
    usbx_ux_device_class_storage_prevent_allow_media_removal_test_application_define,
    usbx_ux_device_class_storage_verify_test_application_define,
    usbx_ux_device_class_storage_uninitialize_test_application_define,
    usbx_ux_device_class_storage_inquiry_test_application_define,
    usbx_ux_device_class_storage_initialize_test_application_define,
    usbx_ux_device_class_storage_synchronize_cache_test_application_define,
    usbx_ux_device_class_storage_read_test_application_define,

    usbx_ux_device_class_storage_write_test_application_define,
    usbx_ux_device_class_storage_thread_test_application_define,
    usbx_ux_host_class_storage_configure_overage_test_application_define,
    usbx_ux_host_class_storage_request_sense_test_application_define,
    usbx_ux_host_class_storage_media_capacity_get_test_application_define,
    usbx_ux_host_class_storage_max_lun_get_test_application_define,
    usbx_ux_host_class_storage_configure_test_application_define,
    usbx_ux_host_class_storage_activate_test_application_define,
    usbx_ux_host_class_storage_device_support_check_test_application_define,
    usbx_ux_host_class_storage_device_initialize_test_application_define,
    usbx_ux_host_class_storage_media_mount_test_application_define,
    usbx_ux_host_class_storage_media_open_test_application_define,
    usbx_ux_host_class_storage_media_read_test_application_define,
    usbx_ux_host_class_storage_media_write_test_application_define,
    usbx_ux_host_class_storage_media_protection_check_test_application_define,
    usbx_ux_host_class_storage_media_recovery_sense_get_test_application_define,
    usbx_ux_host_class_storage_start_stop_test_application_define,
    usbx_ux_host_class_storage_transport_bo_test_application_define,
    usbx_ux_host_class_storage_driver_entry_test_application_define,
    usbx_ux_host_class_storage_thread_entry_test_application_define,
    usbx_ux_host_class_storage_entry_test_application_define,

    /* Utility */

    usbx_ux_utility_descriptor_pack_test_application_define,
    usbx_ux_utility_descriptor_parse_test_application_define,
    usbx_ux_utility_event_flags_test_application_define,
    usbx_ux_utility_memory_safe_test_application_define,
    usbx_ux_utility_memory_test_application_define,
    usbx_ux_utility_mutex_test_application_define,
    usbx_ux_utility_pci_write_test_application_define,
    usbx_ux_utility_pci_read_test_application_define,
    usbx_ux_utility_pci_class_scan_test_application_define,
    usbx_ux_utility_physical_address_test_application_define,
    usbx_ux_utility_semaphore_test_application_define,
    usbx_ux_utility_string_length_check_test_application_define,
    usbx_ux_utility_thread_create_test_application_define,
    usbx_ux_utility_thread_schedule_other_test_application_define,
    usbx_ux_utility_thread_suspend_test_application_define,
    usbx_ux_utility_thread_identify_test_application_define,
    usbx_ux_utility_timer_test_application_define,
    usbx_ux_utility_unicode_to_string_test_application_define,

    /* Host stack */

    usbx_ux_host_stack_uninitialize_test_application_define,
    usbx_ux_host_stack_hcd_unregister_test_application_define,
    usbx_ux_host_stack_class_unregister_test_application_define,

    //usbx_ux_host_stack_transfer_request_abort_test_application_define,
    usbx_ux_host_class_stack_device_configuration_reset_coverage_test_application_define,
    usbx_ux_host_stack_bandwidth_test_application_define,
    usbx_ux_host_stack_class_device_scan_test_application_define,
    usbx_ux_host_stack_class_get_test_application_define,
    usbx_ux_host_stack_class_instance_destroy_test_application_define,
    usbx_ux_host_stack_class_instance_get_test_application_define,
    usbx_ux_host_stack_class_interface_scan_test_application_define,
    usbx_ux_host_stack_class_register_test_application_define,
    usbx_ux_host_stack_configuration_descriptor_parse_test_application_define,
    usbx_ux_host_stack_configuration_enumerate_test_application_define,
    usbx_ux_host_stack_configuration_instance_delete_test_application_define,
    usbx_ux_host_stack_configuration_interface_get_test_application_define,
    usbx_ux_host_stack_configuration_set_test_application_define,
    usbx_ux_host_stack_device_address_set_test_application_define,
    usbx_ux_host_stack_device_get_test_application_define,
    usbx_ux_host_stack_device_remove_test_application_define,
    usbx_ux_host_stack_endpoint_instance_create_test_application_define,
    usbx_ux_host_stack_endpoint_instance_test_application_define,
    usbx_ux_host_stack_hcd_transfer_request_test_application_define,
    usbx_ux_host_stack_hcd_register_test_application_define,
    usbx_ux_host_stack_interface_endpoint_get_test_application_define,
    usbx_ux_host_stack_interfaces_scan_test_application_define,
    usbx_ux_host_stack_new_device_get_test_application_define,
    usbx_ux_host_stack_rh_device_insertion_test_application_define,
    usbx_ux_host_stack_device_configuration_get_test_application_define,
    usbx_ux_host_stack_device_configuration_reset_select_test_application_define,
    usbx_ux_host_stack_hcd_thread_entry_test_application_define,
    usbx_ux_host_stack_transfer_request_test_application_define,

    /* Device Stack */

    usbx_ux_device_stack_alternate_setting_get_test_application_define,
    usbx_ux_device_stack_alternate_setting_set_test_application_define,
    usbx_ux_device_stack_class_register_test_application_define,
    usbx_ux_device_stack_class_unregister_test_application_define,
    usbx_ux_device_stack_configuration_set_test_application_define,
    usbx_ux_device_stack_control_request_process_coverage_test_application_define,
    usbx_ux_device_stack_control_request_process_test_application_define,
    usbx_ux_host_stack_device_descriptor_read_test_application_define,
    usbx_ux_device_stack_get_status_test_application_define,
    usbx_ux_device_stack_interface_delete_test_application_define,
    usbx_ux_device_stack_interface_set_test_application_define,
    usbx_ux_device_stack_interface_start_test_application_define,
    usbx_ux_device_stack_set_feature_test_application_define,
    usbx_ux_device_stack_transfer_request_test_application_define,
    usbx_ux_device_stack_endpoint_stall_test_application_define,
    usbx_ux_device_stack_initialize_test_application_define,
    usbx_ux_device_stack_clear_feature_coverage_test_application_define,

#if !defined(UX_DEVICE_STANDALONE) && !defined(UX_HOST_STANDALONE)

    /* MSC */
    usbx_storage_tests_application_define,

    /* Stack (with CDC ACM)  */
    usbx_ux_host_stack_class_instance_verify_test_application_define,
    usbx_ux_host_stack_endpoint_reset_test_application_define,
    usbx_ux_host_stack_interface_setting_select_test_application_define,
    usbx_ux_host_stack_new_configuration_create_test_application_define,
    usbx_ux_host_stack_new_device_create_test_application_define,
    usbx_ux_host_stack_new_interface_create_test_application_define,
    usbx_ux_host_stack_rh_change_process_test_application_define,

    usbx_device_stack_standard_request_test_application_define,
    usbx_ux_device_stack_descriptor_send_test_application_define,
    usbx_ux_device_stack_remote_wakeup_test_application_define,

    /* Audio */
    usbx_audio10_device_basic_test_application_define,
    usbx_audio10_iad_device_basic_test_application_define,
    usbx_audio10_iad_device_control_test_application_define,
    usbx_audio20_device_basic_test_application_define,
    usbx_uxe_device_audio_test_application_define,

    /* Hub */
    usbx_host_class_hub_port_change_connection_process_coverage_test_application_define,
    usbx_ux_host_class_hub_transfer_request_completed_test_application_define,
    usbx_hub_hub_status_get_invalid_length_test_application_define,
    usbx_ux_host_class_hub_status_get_test_application_define,
    usbx_hub_no_power_switching_test_application_define,
    usbx_hub_get_hub_status_fails_during_port_reset_test_application_define,
    usbx_hub_port_reset_fails_due_to_unset_port_enabled_bit_test_application_define,
    usbx_hub_port_change_reset_test_application_define,
    usbx_hub_port_change_over_current_test_application_define,
    usbx_hub_port_change_suspend_test_application_define,
    usbx_hub_get_hub_status_fails_during_hub_device_enumeration_test_application_define,
    usbx_hub_port_change_enable_test_application_define,
    usbx_hub_quick_hub_device_disconnection_test_application_define,
    usbx_hub_full_speed_hub_device_test_application_define,
    usbx_hub_low_speed_hub_device_test_application_define,
    usbx_hub_port_reset_fails_during_hub_device_enumeration_test_application_define,
    usbx_hub_get_port_status_fails_during_hub_device_enumeration_test_application_define,
    usbx_hub_hub_device_enumeration_keeps_failing_test_application_define,
    usbx_hub_quick_hub_device_reconnection_test_application_define,
    usbx_hub_hub_device_disconnect_test_application_define,
    usbx_hub_non_interrupt_in_endpoint_test_application_define,
    usbx_hub_interrupt_out_endpoint_test_application_define,
    usbx_hub_no_endpoints_test_application_define,
    usbx_hub_request_to_hub_itself_test_application_define,
    usbx_ux_host_class_hub_descriptor_get_coverage_test_application_define,
    usbx_ux_host_class_hub_entry_test_application_define,
    usbx_hub_invalid_device_protocol_test_application_define,
    usbx_hub_basic_test_application_define,
    usbx_hub_basic_memory_test_application_define,
    usbx_hub_get_status_fails_during_configuration_test_application_define,
    usbx_bus_powered_hub_connected_to_self_and_bus_powered_hub_test_application_define,
    usbx_hub_invalid_hub_descriptor_length_test_application_define,
    usbx_hub_full_speed_hub_test_application_define,
    usbx_hub_multiple_tt_test_application_define,

    /* CDC-ECM */

    usbx_cdc_ecm_disconnect_and_reconnect_test_application_define,
    usbx_cdc_ecm_alternate_setting_change_to_zero_test_application_define,
    usbx_ux_host_class_cdc_ecm_interrupt_notification_test_application_define,
    usbx_ux_host_class_cdc_ecm_transmission_callback_test_application_define,
    usbx_cdc_ecm_host_bulk_out_transfer_arming_during_link_down_test_application_define,
    usbx_cdc_ecm_host_bulk_out_transfer_fail_test_application_define,
    usbx_ux_host_class_cdc_ecm_write_test_application_define,
    usbx_cdc_ecm_host_bulk_in_transfer_arming_fails_due_to_link_down_and_thread_waiting_test_application_define,
    usbx_cdc_ecm_host_non_ip_packet_received_test_application_define,
    usbx_cdc_ecm_host_bulk_in_transfer_fail_test_application_define,
    usbx_cdc_ecm_host_thread_packet_allocate_fail_test_application_define,
    usbx_cdc_ecm_host_thread_link_down_before_transfer_test_application_define,
    usbx_cdc_ecm_host_packet_pool_create_fail_test_application_define,
    usbx_cdc_ecm_mac_address_test_application_define,
    usbx_cdc_ecm_basic_test_application_define,
    usbx_cdc_ecm_basic_ipv6_test_application_define,
    usbx_cdc_ecm_mac_address_invalid_length_test_application_define,
    usbx_cdc_ecm_no_functional_descriptor_test_application_define,
    usbx_ux_host_class_cdc_ecm_mac_address_get_test_application_define,
    usbx_cdc_ecm_host_bulk_in_transfer_arming_during_link_down_test_application_define,
    usbx_ux_host_class_cdc_ecm_entry_test_application_define,
    usbx_cdc_ecm_host_bulk_in_transfer_arming_during_deactivate_test_application_define,
    usbx_cdc_ecm_host_first_interrupt_transfer_fail_test_application_define,
    usbx_cdc_ecm_host_thread_create_fail_test_application_define,
    usbx_cdc_ecm_host_interrupt_notification_semaphore_create_fail_test_application_define,
    usbx_cdc_ecm_host_bulk_out_semaphore_create_fail_test_application_define,
    usbx_cdc_ecm_host_bulk_in_semaphore_create_fail_test_application_define,
    usbx_cdc_ecm_control_interface_no_interrupt_endpoint_test_application_define,
    usbx_cdc_ecm_data_interface_setting_select_fails_test_application_define,
    usbx_cdc_ecm_data_interface_no_bulk_in_endpoint_test_application_define,
    usbx_cdc_ecm_data_interface_non_bulk_out_and_non_bulk_in_endpoint_test_application_define,
    usbx_cdc_ecm_data_interface_no_bulk_out_endpoint_test_application_define,
    usbx_cdc_ecm_one_data_interface_with_no_endpoints_test_application_define,
    usbx_cdc_ecm_invalid_alternate_setting_after_zero_endpoint_data_interface_test_application_define,
    usbx_cdc_ecm_non_data_interface_after_zero_endpoint_data_interface_test_application_define,
    usbx_cdc_ecm_default_data_interface_with_endpoints_test_application_define,
    usbx_cdc_ecm_no_control_interface_test_application_define,
    usbx_cdc_ecm_interface_before_control_interface_test_application_define,
    usbx_cdc_ecm_basic_memory_test_application_define,
    usbx_ux_device_class_cdc_ecm_uninitialize_test_application_define,
    usbx_ux_device_class_cdc_ecm_deactivate_test_application_define,
    usbx_ux_device_class_cdc_ecm_initialize_test_application_define,
    usbx_ux_device_class_cdc_ecm_activate_test_application_define,
    usbx_ux_device_class_cdc_ecm_interrupt_thread_test_application_define,
    usbx_ux_device_class_cdc_ecm_bulkin_thread_test_application_define,
    usbx_ux_device_class_cdc_ecm_bulkout_thread_test_application_define,
    usbx_ux_device_class_cdc_ecm_control_request_test_application_define,
    usbx_ux_device_class_cdc_ecm_change_test_application_define,
    usbx_ux_device_class_cdc_ecm_entry_test_application_define,
    usbx_cdc_ecm_link_down_while_ongoing_transfers_test_application_define,

    /* RNDIS */

    usbx_rndis_basic_test_application_define,

    /* CDC-ACM. */

    usbx_cdc_acm_basic_test_application_define,
    usbx_cdc_acm_basic_memory_test_application_define,
    usbx_cdc_acm_configure_test_application_define,
    usbx_cdc_acm_device_dtr_rts_reset_on_disconnect_test_application_define,
    usbx_ux_device_class_cdc_acm_activate_test_application_define,
    usbx_ux_device_class_cdc_acm_deactivate_test_application_define,
    usbx_ux_device_class_cdc_acm_ioctl_test_application_define,
    usbx_ux_device_class_cdc_acm_transmission_test_application_define,
    usbx_ux_device_class_cdc_acm_write_test_application_define,
    usbx_ux_device_class_cdc_acm_timeout_test_application_define,
    usbx_ux_host_class_cdc_acm_activate_test_application_define,
    usbx_ux_host_class_cdc_acm_capabilities_get_test_application_define,
    usbx_ux_host_class_cdc_acm_deactivate_test_application_define,
    usbx_ux_host_class_cdc_acm_endpoints_get_test_application_define,
    usbx_ux_host_class_cdc_acm_entry_test_application_define,
    usbx_ux_host_class_cdc_acm_read_test_application_define,
    usbx_ux_host_class_cdc_acm_transfer_request_completed_test_application_define,
    usbx_ux_device_class_cdc_acm_bulkout_thread_test_application_define,
    usbx_uxe_device_cdc_acm_test_application_define,

    /* DPUMP. */

    usbx_dpump_basic_test_application_define,

    /* Printer */

    usbx_host_class_printer_basic_test_application_define,
    usbx_uxe_device_printer_test_application_define,

    /* Host & Device basic. */

    usbx_host_device_basic_test_application_define,
    usbx_host_device_basic_memory_test_application_define,
    usbx_host_device_initialize_test_application_define,

    /* HID */

    usbx_hid_report_descriptor_compress_array_test_application_define,
    usbx_hid_remote_control_tests_application_define,
    usbx_ux_host_class_hid_remote_control_entry_test_application_define,
    usbx_ux_host_class_hid_remote_control_entry_test2_application_define,
    usbx_ux_host_class_hid_remote_control_entry_test3_application_define,
    usbx_ux_host_class_hid_remote_control_usage_get_test_application_define,
    usbx_hid_keyboard_basic_test_application_define,
    usbx_hid_keyboard_key_test_application_define,
    usbx_ux_device_class_hid_activate_test_application_define,
    usbx_ux_device_class_hid_control_request_test_application_define,
    usbx_ux_device_class_hid_deactivate_test_application_define,
    usbx_ux_device_class_hid_descriptor_send_test_application_define,
    usbx_ux_device_class_hid_entry_test_application_define,
    usbx_ux_device_class_hid_event_get_AND_set_test_application_define,
    usbx_ux_device_class_hid_set_protocol_callback_test_application_define,
    usbx_ux_device_class_hid_initialize_test_application_define,
    usbx_ux_device_class_hid_interrupt_thread_test_application_define,
    usbx_ux_device_class_hid_interrupt_thread_test2_application_define,
    usbx_ux_device_class_hid_report_test_application_define,
    usbx_ux_host_class_hid_activate_test_application_define,
    usbx_ux_host_class_hid_client_register_test_application_define,
    usbx_ux_host_class_hid_client_register_test2_application_define,
    usbx_ux_host_class_hid_client_search_test_application_define,
    usbx_ux_host_class_hid_configure_test_application_define,
    usbx_ux_host_class_hid_deactivate_test_application_define,
    usbx_ux_host_class_hid_deactivate_test3_application_define,
    usbx_ux_host_class_hid_descriptor_parse_coverage_test_application_define,
    usbx_ux_host_class_hid_descriptor_parse_test_application_define,
    usbx_ux_host_class_hid_descriptor_parse_test2_application_define,
    usbx_ux_host_class_hid_descriptor_parse_test4_application_define,
    usbx_ux_host_class_hid_descriptor_parse_test5_application_define,
    usbx_ux_host_class_hid_entry_test_application_define,
    usbx_ux_host_class_hid_idle_get_test_application_define,
    usbx_ux_host_class_hid_idle_set_test_application_define,
    usbx_ux_host_class_hid_keyboard_activate_test_application_define,
    usbx_ux_host_class_hid_keyboard_entry_test_application_define,
    usbx_ux_host_class_hid_keyboard_ioctl_test_application_define,
    usbx_ux_host_class_hid_keyboard_thread_test_application_define,
    usbx_ux_host_class_hid_keyboard_thread_test2_application_define,
    usbx_ux_host_class_hid_main_item_parse_test_application_define,
    usbx_ux_host_class_hid_main_item_parse_test2_application_define,
    usbx_ux_host_class_hid_mouse_activate_test_application_define,
    usbx_ux_host_class_hid_mouse_entry_test_application_define,
    usbx_ux_host_class_hid_mouse_entry_test3_application_define,
    usbx_ux_host_class_hid_mouse_buttons_get_test_application_define,
    usbx_ux_host_class_hid_mouse_positions_get_test_application_define,
    usbx_ux_host_class_hid_mouse_wheel_get_test_application_define,
    usbx_ux_host_class_hid_periodic_report_start_test_application_define,
    usbx_ux_host_class_hid_periodic_report_start_test2_application_define,
    usbx_ux_host_class_hid_periodic_report_stop_test_application_define,
    usbx_ux_host_class_hid_remote_control_activate_test_application_define,
    usbx_ux_host_class_hid_report_add_test_application_define,
    usbx_ux_host_class_hid_report_callback_register_test_application_define,
    usbx_ux_host_class_hid_report_get_test_application_define,
    usbx_ux_host_class_hid_report_get_test2_application_define,
    usbx_ux_host_class_hid_report_id_get_test_application_define,
    usbx_ux_host_class_hid_report_set_test_application_define,
    usbx_ux_host_class_hid_transfer_request_completed_test_application_define,
    usbx_hid_keyboard_key_get_test_application_define,
    usbx_hid_transfer_request_completed_decompressed_test_application_define,
    usbx_hid_transfer_request_completed_test_application_define,
    usbx_hid_transfer_request_completed_raw_test_application_define,
    usbx_hid_report_descriptor_compress_test_application_define,
    usbx_hid_report_descriptor_compress_and_decompress_test_application_define,
    usbx_hid_report_descriptor_get_zero_length_item_data_test_application_define,
    usbx_hid_report_descriptor_global_item_test_application_define,
    usbx_hid_report_descriptor_global_item_persist_test_application_define,
    usbx_hid_report_descriptor_report_size_overflow_test_application_define,
    usbx_hid_report_descriptor_report_count_overflow_test_application_define,
    usbx_hid_report_descriptor_pop_underflow_tag_test_application_define,
    usbx_hid_report_descriptor_push_overflow_tag_test_application_define,
    usbx_hid_report_descriptor_push_pop_test_application_define,
    usbx_hid_report_descriptor_unknown_global_tag_test_application_define,
    usbx_hid_report_descriptor_end_collection_error_test_application_define,
    usbx_hid_report_descriptor_collection_overflow_test_application_define,
    usbx_hid_report_descriptor_multiple_collections_test_application_define,
    usbx_hid_report_descriptor_unknown_local_tag_test_application_define,
    usbx_hid_report_descriptor_incoherent_usage_min_max_test_application_define,
    usbx_hid_report_descriptor_delimiter_unknown_test_application_define,
    usbx_hid_report_descriptor_delimiter_nested_close_test_application_define,
    usbx_hid_report_descriptor_delimiter_nested_open_test_application_define,
    usbx_hid_report_descriptor_invalid_length_test_application_define,
    usbx_hid_report_descriptor_invalid_item_test_application_define,
    usbx_ux_host_class_hid_local_item_parse_test_application_define,
    usbx_hid_mouse_basic_test_application_define,
    usbx_ux_device_class_hid_basic_memory_test_application_define,
    usbx_ux_device_class_hid_idle_rate_test_application_define,

    usbx_host_class_video_basic_test_application_define,

#endif /* !defined(UX_DEVICE_STANDALONE) && !defined(UX_HOST_STANDALONE) */
#endif /* CTEST */
    TX_NULL,
};

/* Define thread prototypes.  */

void  test_control_thread_entry(ULONG thread_input);
void  test_thread_entry(ULONG thread_input);
void  test_control_return(UINT status);
void  test_control_cleanup(void);


/* Define necessary external references.  */

#ifdef __ghs
extern TX_MUTEX                 __ghLockMutex;
#endif

extern TX_TIMER                 *_tx_timer_created_ptr;
extern ULONG                    _tx_timer_created_count;
#ifndef TX_TIMER_PROCESS_IN_ISR
extern TX_THREAD                _tx_timer_thread;
#endif
extern TX_THREAD                *_tx_thread_created_ptr;
extern ULONG                    _tx_thread_created_count;
extern TX_SEMAPHORE             *_tx_semaphore_created_ptr;
extern ULONG                    _tx_semaphore_created_count;
extern TX_QUEUE                 *_tx_queue_created_ptr;
extern ULONG                    _tx_queue_created_count;
extern TX_MUTEX                 *_tx_mutex_created_ptr;
extern ULONG                    _tx_mutex_created_count;
extern TX_EVENT_FLAGS_GROUP     *_tx_event_flags_created_ptr;
extern ULONG                    _tx_event_flags_created_count;
extern TX_BYTE_POOL             *_tx_byte_pool_created_ptr;
extern ULONG                    _tx_byte_pool_created_count;
extern TX_BLOCK_POOL            *_tx_block_pool_created_ptr;
extern ULONG                    _tx_block_pool_created_count;

extern NX_PACKET_POOL *         _nx_packet_pool_created_ptr;
extern ULONG                    _nx_packet_pool_created_count;
extern NX_IP *                  _nx_ip_created_ptr;
extern ULONG                    _nx_ip_created_count;

#ifdef EXTERNAL_EXIT
void external_exit(UINT code);
#endif


/* Define the interrupt processing dispatcher.  The individual tests will set this up when they desire
   asynchrony processing for testing purposes.  */

void test_interrupt_dispatch(void)
{

#ifndef TX_DISABLE_ERROR_CHECKING

    /* Test calling tx_thread_relinquish from ISR to see if the error checking throws it out.  */
    tx_thread_relinquish();
#endif

    /* Check for something to run... */
    if (test_isr_dispatch)
    {

        (test_isr_dispatch)();
    }
}


/* Define init timer entry.  */

static void   init_timer_entry(ULONG timer_input)
{

}


/* Define main entry point.  */
#ifndef EXTERNAL_MAIN
void main()
{

    /* Enter the USBX kernel.  */
    tx_kernel_enter();
}
#endif


/* Define what the initial system looks like.  */

void    tx_application_define(void *first_unused_memory)
{

    /* Initialize the test error/success counters.  */
    test_control_successful_tests =  0;
    test_control_failed_tests =      0;
    test_control_system_errors =     0;

    /* Create the test control thread.  */
    tx_thread_create(&test_control_thread, "test control thread", test_control_thread_entry, 0,
            test_control_thread_stack, TEST_STACK_SIZE,
            17, 15, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Remember the free memory pointer.  */
    test_free_memory_ptr =  &tests_memory[0];
}



/* Define the test control thread.  This thread is responsible for dispatching all of the
   tests in the USBX test suite.  */

void  test_control_thread_entry(ULONG thread_input)
{

ULONG   previous_test_control_failed_tests;
ULONG   previous_thread_created_count;
UINT    i;

    /* Raise the priority of the control thread to 0.  */
    tx_thread_priority_change(&test_control_thread, 0, &i);

    /* Print out banner.  */
    printf("********************** USBX Validation/Regression Test Suite *********************************\n\n");

    /* Print version id.  */
    printf("Version: %s Data width: x%i\n\n", _ux_version_id, (int)sizeof(void*) * 8);

    /* Print out the tests... */
    printf("Running validation/regression test:\n\n");

    /* Loop to process all tests...  */
    i =  0;
    while (test_control_tests[i].test_entry != TX_NULL)
    {

        /* Clear the ISR dispatch.  */
        test_isr_dispatch =  TX_NULL;

        /* Save the number of failed tests for comparison. */
        previous_test_control_failed_tests = test_control_failed_tests;

        /* Save previous thread count.  */
        previous_thread_created_count = _tx_thread_created_count;

        /* Dispatch the test.  */
        (test_control_tests[i++].test_entry)(test_free_memory_ptr);

        /* Clear the ISR dispatch.  */
        test_isr_dispatch =  TX_NULL;

        /* Did the test entry run successfully? */
        if (test_control_failed_tests == previous_test_control_failed_tests &&
            previous_thread_created_count != _tx_thread_created_count)

            /* Suspend control test to allow test to run.  */
            tx_thread_suspend(&test_control_thread);

        /* Test finished, cleanup in preparation for the next test.  */
        test_control_cleanup();
    }

    /* Finished with all tests, print results and return!  */
    printf("**** Testing Complete ****\n");
    printf("**** Test Summary:  Tests Passed:  %lu   Tests Failed:  %lu    System Errors:   %lu\n", test_control_successful_tests, test_control_failed_tests, test_control_system_errors);

#ifndef EXTERNAL_EXIT
    exit(test_control_failed_tests);
#else
    external_exit(0);
#endif
}

static VOID disable_test_actions(VOID)
{

    /* Note: There shouldn't be any actions left. */
    ux_test_cleanup_everything();

    ux_test_utility_sim_cleanup();
    ux_test_hcd_sim_host_cleanup();
    ux_test_dcd_sim_slave_cleanup();
}


void  test_control_return(UINT status)
{

UINT    old_posture =  TX_INT_ENABLE;

    disable_test_actions();

    /* Save the status in a global.  */
    test_control_return_status =  status;

    /* Ensure interrupts are enabled.  */
    old_posture =  tx_interrupt_control(TX_INT_ENABLE);

    /* Determine if it was successful or not.  */
    if (status)
        test_control_failed_tests++;
    else
        test_control_successful_tests++;

    /* Now check for system errors.  */

    /* Is preempt disable flag set?  */
    if (_tx_thread_preempt_disable)
    {

        /* System error - preempt disable should never be set inside of a thread!  */
        printf("    ***** SYSTEM ERROR ***** _tx_thread_preempt_disable is non-zero!\n");
        test_control_system_errors++;
    }

    /* Is system state set?  */
    if (_tx_thread_system_state)
    {

        /* System error - system state should never be set inside of a thread!  */
        printf("    ***** SYSTEM ERROR ***** _tx_thread_system_state is non-zero!\n");
        test_control_system_errors++;
    }

    /* Are interrupts disabled?  */
    if (old_posture == TX_INT_DISABLE)
    {

        /* System error - interrupts should always be enabled in our test threads!  */
        printf("    ***** SYSTEM ERROR ***** test returned with interrupts disabled!\n");
        test_control_system_errors++;
    }

    /* Resume the control thread to fully exit the test.  */
    tx_thread_resume(&test_control_thread);
}


void  test_control_cleanup(void)
{

TX_MUTEX    *mutex_ptr;
TX_THREAD   *thread_ptr;


    /* FIXME: Cleanup of FileX, and USBX resources should be added here... and perhaps some checks for memory leaks, etc.  */

    /* Disable testing actions generation */
    disable_test_actions();

    /* Delete all IP instances.   */
    while (_nx_ip_created_ptr)
    {

        /* Delete all UDP sockets.  */
        while (_nx_ip_created_ptr -> nx_ip_udp_created_sockets_ptr)
        {

            /* Make sure the UDP socket is unbound.  */
            nx_udp_socket_unbind(_nx_ip_created_ptr -> nx_ip_udp_created_sockets_ptr);

            /* Delete the UDP socket.  */
            nx_udp_socket_delete(_nx_ip_created_ptr -> nx_ip_udp_created_sockets_ptr);
        }

        /* Delete all TCP sockets.  */
        while (_nx_ip_created_ptr -> nx_ip_tcp_created_sockets_ptr)
        {

            /* When disconnecting TCP sockets, NetX sends a RST packet. Since the link
               is down, the driver will report an error. So, turn of errors during this
               time.  */
            ux_test_ignore_all_errors();

            /* Disconnect.  */
            nx_tcp_socket_disconnect(_nx_ip_created_ptr -> nx_ip_tcp_created_sockets_ptr, NX_NO_WAIT);

            /* Re-enable errors.  */
            ux_test_unignore_all_errors();

            /* Make sure the TCP client socket is unbound.  */
            nx_tcp_client_socket_unbind(_nx_ip_created_ptr -> nx_ip_tcp_created_sockets_ptr);

            /* Make sure the TCP server socket is unaccepted.  */
            nx_tcp_server_socket_unaccept(_nx_ip_created_ptr -> nx_ip_tcp_created_sockets_ptr);

            /* Delete the TCP socket.  */
            nx_tcp_socket_delete(_nx_ip_created_ptr -> nx_ip_tcp_created_sockets_ptr);
        }

        /* Clear all listen requests.  */
        while (_nx_ip_created_ptr -> nx_ip_tcp_active_listen_requests)
        {

            /* Make sure the TCP server socket is unlistened.  */
            nx_tcp_server_socket_unlisten(_nx_ip_created_ptr, (_nx_ip_created_ptr -> nx_ip_tcp_active_listen_requests) -> nx_tcp_listen_port);
        }

        /* Delete the IP instance.  */
        nx_ip_delete(_nx_ip_created_ptr);
    }

    /* Delete all the packet pools.  */
    while (_nx_packet_pool_created_ptr)
    {
        nx_packet_pool_delete(_nx_packet_pool_created_ptr);
    }

    /* Delete all queues.  */
    while(_tx_queue_created_ptr)
    {

        /* Delete queue.  */
        tx_queue_delete(_tx_queue_created_ptr);
    }

    /* Delete all semaphores.  */
    while(_tx_semaphore_created_ptr)
    {

        /* Delete semaphore.  */
        tx_semaphore_delete(_tx_semaphore_created_ptr);
    }

    /* Delete all event flag groups.  */
    while(_tx_event_flags_created_ptr)
    {

        /* Delete event flag group.  */
        tx_event_flags_delete(_tx_event_flags_created_ptr);
    }

    /* Delete all byte pools.  */
    while(_tx_byte_pool_created_ptr)
    {

        /* Delete byte pool.  */
        tx_byte_pool_delete(_tx_byte_pool_created_ptr);
    }

    /* Delete all block pools.  */
    while(_tx_block_pool_created_ptr)
    {

        /* Delete block pool.  */
        tx_block_pool_delete(_tx_block_pool_created_ptr);
    }

    /* Delete all timers.  */
    while(_tx_timer_created_ptr)
    {

        /* Deactivate timer.  */
        tx_timer_deactivate(_tx_timer_created_ptr);

        /* Delete timer.  */
        tx_timer_delete(_tx_timer_created_ptr);
    }

    /* Delete all mutexes (except for system mutex).  */
    while(_tx_mutex_created_ptr)
    {

        /* Setup working mutex pointer.  */
        mutex_ptr =  _tx_mutex_created_ptr;

#ifdef __ghs

        /* Determine if the mutex is the GHS system mutex.  If so, don't delete!  */
        if (mutex_ptr == &__ghLockMutex)
        {

            /* Move to next mutex.  */
            mutex_ptr =  mutex_ptr -> tx_mutex_created_next;
        }

        /* Determine if there are no more mutexes to delete.  */
        if (_tx_mutex_created_count == 1)
            break;
#endif

        /* Delete mutex.  */
        tx_mutex_delete(mutex_ptr);
    }

    /* Delete all threads, except for timer thread, and test control thread.  */
    while (_tx_thread_created_ptr)
    {

        /* Setup working pointer.  */
        thread_ptr =  _tx_thread_created_ptr;


#ifdef TX_TIMER_PROCESS_IN_ISR

        /* Determine if there are more threads to delete.  */
        if (_tx_thread_created_count == 1)
            break;

        /* Determine if this thread is the test control thread.  */
        if (thread_ptr == &test_control_thread)
        {

            /* Move to the next thread pointer.  */
            thread_ptr =  thread_ptr -> tx_thread_created_next;
        }
#else

        /* Determine if there are more threads to delete.  */
        if (_tx_thread_created_count == 2)
            break;

        /* Move to the thread not protected.  */
        while ((thread_ptr == &_tx_timer_thread) || (thread_ptr == &test_control_thread))
        {

            /* Yes, move to the next thread.  */
            thread_ptr =  thread_ptr -> tx_thread_created_next;
        }
#endif

        /* First terminate the thread to ensure it is ready for deletion.  */
        tx_thread_terminate(thread_ptr);

        /* Delete the thread.  */
        tx_thread_delete(thread_ptr);
    }

    /* At this point, only the test control thread and the system timer thread and/or mutex should still be
       in the system.  */
}