]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.0.0/test/src/test_lfds700_queue_bounded_singleconsumer_singleproducer_dequeuing.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.0.0 / test / src / test_lfds700_queue_bounded_singleconsumer_singleproducer_dequeuing.c
1 /***** includes *****/
2 #include "internal.h"
3
4
5
6
7
8 /****************************************************************************/
9 void test_lfds700_queue_bss_dequeuing()
10 {
11   enum lfds700_misc_validity
12     dvs = LFDS700_MISC_VALIDITY_VALID;
13
14   lfds700_pal_uint_t
15     loop;
16
17   struct lfds700_queue_bss_element
18     element_array[128];
19
20   struct lfds700_queue_bss_state
21     qs;
22
23   struct lfds700_misc_validation_info
24     vi;
25
26   void
27     *value;
28
29   /* TRD : create an empty queue
30            enqueue 128 elements
31            then dequeue the elements, in the same thread - we're API testing
32            it's a single producer queue, so we just do this in our current thread
33            since we're enqueuing and dequeuing in the same thread,
34            
35   */
36
37   internal_display_test_name( "Dequeuing" );
38
39   lfds700_queue_bss_init_valid_on_current_logical_core( &qs, element_array, 128, NULL );
40
41   for( loop = 0 ; loop < 127 ; loop++ )
42     lfds700_queue_bss_enqueue( &qs, NULL, (void *) loop );
43
44   for( loop = 0 ; loop < 127 ; loop++ )
45   {
46     lfds700_queue_bss_dequeue( &qs, NULL, &value );
47     if( (lfds700_pal_uint_t) value != 127 - loop )
48       dvs = LFDS700_MISC_VALIDITY_INVALID_TEST_DATA;
49   }
50
51   vi.min_elements = vi.max_elements = 0;
52
53   lfds700_queue_bss_query( &qs, LFDS700_QUEUE_BSS_QUERY_VALIDATE, &vi, &dvs );
54
55   lfds700_queue_bss_cleanup( &qs, NULL );
56
57   internal_display_test_result( 1, "queue_bss", dvs );
58
59   return;
60 }
61