()
| 8 | |
| 9 | |
| 10 | def test_detect_change(): |
| 11 | parser = PatchParser() |
| 12 | |
| 13 | # view parsing ground truth here |
| 14 | # https://github.com/basicthinker/Sexain-MemController/commit/f050c6f6dd4b1d3626574b0d23bb41125f7b75ca |
| 15 | parsing_truth = ( |
| 16 | [[7, 31], [27, 3], [44, 1], [50, 2], [70, 1], [77, 2], [99, 2]], |
| 17 | [[32, 44], [56, 70]] |
| 18 | ) |
| 19 | |
| 20 | # view function ranges ground truth here |
| 21 | # https://github.com/basicthinker/Sexain-MemController/blob/5b8886d9da3bb07140bfb1ff2d2b215b2dff584b/migration_controller.cc |
| 22 | func_ranges_truth = ( |
| 23 | ['MigrationController::InputBlocks', |
| 24 | 'MigrationController::ExtractNVMPage', |
| 25 | 'MigrationController::ExtractDRAMPage', |
| 26 | 'MigrationController::Clear'], |
| 27 | [[8, 28], [30, 52], [54, 79], [81, 100]] |
| 28 | ) |
| 29 | |
| 30 | changed_result = { |
| 31 | 'MigrationController::Clear': 2, |
| 32 | 'MigrationController::ExtractDRAMPage': 18, |
| 33 | 'MigrationController::ExtractNVMPage': 16, |
| 34 | 'MigrationController::InputBlocks': 3 |
| 35 | } |
| 36 | |
| 37 | with open(os.path.join(dir_path, 'example.patch'), 'r') as f: |
| 38 | example_patch = f.read() |
| 39 | parsing_result = parser.parse(example_patch) |
| 40 | assert(parsing_result == parsing_truth) |
| 41 | |
| 42 | with open(os.path.join(dir_path, 'example.cc'), 'r') as f: |
| 43 | root = transform_src_to_tree(f.read(), ext='.cc') |
| 44 | func_ranges_result = get_func_ranges_cpp(root) |
| 45 | assert(func_ranges_result == func_ranges_truth) |
| 46 | |
| 47 | assert(changed_result == get_changed_functions( |
| 48 | *func_ranges_result, *parsing_result)) |
| 49 | |
| 50 | |
| 51 | def test_patch_parser(): |
nothing calls this directly
no test coverage detected