Exemplo n.º 1
0
def test_long_value():
    value_min = FFI.new('volatile long *', MIN)
    value_max = FFI.new('volatile long *', MAX)
    #     print(f"value_min={value_min} value_max={value_max}")
    #     print(f"value_min={value_min[0]} value_max={value_max[0]}")
    assert value_min[0] == MIN
    assert value_max[0] == MAX
Exemplo n.º 2
0
def test_store_default():
    print()
    store = FFI.new('sequence_store *')
    assert store.entry_count == 0
    assert store.producer_sequence == 0
    assert store.consumer_count == 0
    assert list(store.consumer_sequence_list) == [0 for _ in range(CONSUMER_LIMIT)]
Exemplo n.º 3
0
 def __init__(self, entry_count:int=16):
     sequence_store = FFI.new('sequence_store *',
         init=dict(
             entry_count=entry_count,
         ),
     )
     object.__setattr__(self, 'sequence_store', sequence_store)
Exemplo n.º 4
0
def test_long_value_incr_and_mask():
    print()
    store = FFI.new('volatile long *', MAX - 2)
    for _ in range(8):
        point = LIB.long_value_incr_and_mask(store, 1, 0x3)
        value = hex(store[0])
        print(f"point={point} value={value}")
Exemplo n.º 5
0
def test_consumer_sequence_gate(cons_seq_list):
    store = FFI.new('sequence_store *')
    size = len(cons_seq_list)
    if size:
        store.consumer_count = size
        store.consumer_sequence_list = cons_seq_list
        source = LIB.consumer_sequence_gate(store)
        target = min(cons_seq_list)
        assert source == target
Exemplo n.º 6
0
def test_producer_sequence_claim():
    print()
    store = FFI.new('sequence_store *')
    store.entry_count = 8
    store.producer_sequence = 0
    store.consumer_count = 1
    store.consumer_sequence_list = [0]
    for index in range(10):
        sequence = LIB.producer_sequence_claim(store)
        error_num = FFI.errno
        print(f"index={index} sequence={sequence} error_num={error_num}")
Exemplo n.º 7
0
def test_long_value_compare_and_swap():
    store = FFI.new('volatile long *', 0)
    assert LIB.long_value_compare_and_swap(store, 0, 10) == 0
    assert LIB.long_value_compare_and_swap(store, 10, 20) == 10
Exemplo n.º 8
0
def test_long_bool_compare_and_swap():
    store = FFI.new('volatile long *', 0)
    assert LIB.long_bool_compare_and_swap(store, 0, 10) == True
    assert LIB.long_bool_compare_and_swap(store, 1, 20) == False
Exemplo n.º 9
0
def test_long_sub_and_fetch():
    store = FFI.new('volatile long *', 0)
    assert LIB.long_sub_and_fetch(store, 1) == -1
    assert LIB.long_sub_and_fetch(store, 10) == -11
Exemplo n.º 10
0
def long_add_and_fetch():
    store = FFI.new('volatile long *', 0)
    assert LIB.long_add_and_fetch(store, 1) == 1
    assert LIB.long_add_and_fetch(store, 10) == 11