test_otherops.py 1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Copyright 2017 The Australian National University
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

15
from util import fncptr_from_c_script, mu_instance_via_ctyeps, may_spawn_proc
John Zhang's avatar
John Zhang committed
16 17
import ctypes

18
@may_spawn_proc
John Zhang's avatar
John Zhang committed
19
def test_select():
Kunshan Wang's avatar
Kunshan Wang committed
20
    fnp, _ = fncptr_from_c_script('test_select.c', 'test_fnc', [ctypes.c_byte])
John Zhang's avatar
John Zhang committed
21 22
    assert fnp(0) == 20
    assert fnp(1) == 10
John Zhang's avatar
John Zhang committed
23

24
@may_spawn_proc
John Zhang's avatar
John Zhang committed
25
def test_commoninst_pin():
26
    mu = mu_instance_via_ctyeps()
John Zhang's avatar
John Zhang committed
27 28
    fnp, _ = fncptr_from_c_script("test_commoninst_pin.c", 'test_pin')
    assert fnp() == 6