示例#1
0
def compare_one_register(global_var):
    global_var_name = global_var.gen_name
    global_var_name_to_function = "&" + global_var_name

    # define temporary array to pass as parameters to GenUtils.gen_function_call_with_arg()
    temp_global_var = [global_var_name_to_function]

    GenUtils.gen_comment_line(gen_source_file, "Compare " + global_var_name + " with expected value")
    
    # Contents of global_var_n.actual
    actual_content = global_var_name + ".actual = "
    actual_content += global_var.actual_mem
    actual_content += ";"
    # Contents of global_var_n.expected
    expected_content = global_var_name + ".expected = "
    expected_content += global_var.expected
    expected_content += ";"
    # Contents of global_var_n.mask
    mask_content = global_var_name + ".mask = "
    mask_content += global_var.mask
    mask_content += ";"
    
    GenUtils.source_file(actual_content)
    GenUtils.source_file(expected_content)
    GenUtils.source_file(mask_content)
    
    GenUtils.gen_function_call_with_arg(gen_source_file, "compareBitsOnUint8", "", "", temp_global_var)  
示例#2
0
def call_test_method(test_case):
    # Create an array with null items ("None" is similar to null")
    param_list = [None] * len(test_case.params)
    
    # Get list of parameters from "testcase" class
    i = 0
    for param in test_case.params:
        param_list[i] = param.param_name
        i += 1

    result_var = ""
    type_cast = ""
    if len(test_case.return_objs) > 0:
        result_var = "result_ptr"
        if "True" == test_case.return_objs[0].is_pointer:
            type_cast = "(uint8_t*)"
    


    GenUtils.gen_comment_line(gen_source_file, "Call the tested function")
    params_count = len(param_list)
    if params_count > 0:
        GenUtils.gen_function_call_with_arg(gen_source_file, test_case.function_name, result_var, type_cast, param_list)
    else:
        GenUtils.gen_function_call_no_arg(gen_source_file, test_case.function_name, result_var, type_cast)
    GenUtils.gen_break_line(gen_source_file)    
示例#3
0
def compare_returning_value(return_obj):
    return_obj_name = return_obj.gen_name
    return_obj_name_to_function = "&" + return_obj_name                   

    # define temporary array to pass as parameters to GenUtils.GenUtils.gen_function_call_with_arg()
    temp_return_obj = [return_obj_name_to_function]

    GenUtils.gen_comment_line(gen_source_file, "Compare " + return_obj_name + " with expected value")
    
    # Contents of actual result after function calling
    actual_content = return_obj_name + ".actual = "
    actual_content += "result_ptr;" #fixed name
    # Contents of return_obj.expected_value
    expected_content = return_obj_name + ".expected = (uint8_t*)" # perform a pointer casting
    expected_content += return_obj.expected_value
    expected_content += ";"
        
    GenUtils.source_file(actual_content)
    GenUtils.source_file(expected_content)
    
    GenUtils.gen_function_call_with_arg(gen_source_file, "compareOnUint8Ptr", "", "", temp_return_obj)