source_directory = "/home/ubuntu/src/test_sort_rewrite/kernel/"
source_file_name = "test_sort_backup.c"
target_file_name = "test_sort_rewrite.c"
full_source_path = source_directory + source_file_name
full_target_path = source_directory + target_file_name

print("Converting " + source_file_name)
print("Input file path: " + full_source_path)
print("Output path: " + full_target_path)

# |----------------------------------------------|
# | Conversion rules for "test_sort_rewrite.c" |
# |----------------------------------------------|

test_sort_rules_2 = {
    "test_functions": ["test_sort_init"],
    "test_suite_name": "test_sort_rewrite",
    "blacklist": ["cmpint"],
    "replacements": [("return err;", "ASSERT_INT_EQ(err, 0);")],
    "should_add_new_main": True
}

state = Converter(full_source_path, full_target_path, test_sort_rules_2, True)
state.add_include_code() \
    .add_init_code_to_main() \
    .add_exit_code() \
    .convert_to_test_common_args() \
    .use_replacements() \
    .result()
Ejemplo n.º 2
0
    "test_suite_name":
    "test_xarray_rewrite",
    "context_args":
    "struct xarray [*]xa|void",
    "common_call_args":
    "&array",
    "extra_dummy_args_call":
    "xa",
    "blacklist":
    ["test_update_node", "xa_load", "xa_alloc", "xas_retry", "xa_err"],
    "replacements": [(r"(^\s*)(XA_BUG_ON[(]xa, *)", "\g<1>EXPECT_FALSE("),
                     (r"(^\s*)(XA_BUG_ON[(]&xa0, *)", "\g<1>EXPECT_FALSE("),
                     (r"(^\s*)(XA_BUG_ON[(]NULL, *)", "\g<1>EXPECT_FALSE(")],
    "should_add_new_main":
    False
}

state = Converter(full_source_path, full_target_path, test_xarray_rules, True)
state.add_include_code() \
    .add_init_code_to_main() \
    .add_exit_code() \
    .add_type_definitions() \
    .convert_to_test_common_args() \
    .convert_to_test_extra_args() \
    .convert_calls_to_add_test() \
    .add_boilerplate_code() \
    .add_extra_parameters_to_helpers_and_multi_arg_defs() \
    .add_self_argument_to_helper_calls() \
    .use_replacements() \
    .result()