Testing: file.c has only 21% coverage — many critical functions untested #132

Closed
opened 2026-07-21 16:26:50 +02:00 by TapTap · 0 comments
Owner

src/shared/file.c is one of the most critical files (373 lines) but only 21% covered. Key untested functions:

Function Lines Status
old_data_from_path() 140-157 0 hits
receive_delta_file() 158-309 0 hits
receive_incremental_check() 311-433 0 hits
file_send_sendfile() 436-467 0 hits
file_receive() 470-519 0 hits
receive_manifest() 521-560 0 hits
to_disk() 562-596 partially covered
file_save_to_disk() 209-246 partially covered

These are the core I/O functions for the sync operation. Bugs here cause data corruption.

Suggested tests

  1. old_data_from_path() — test with existing file, missing file, empty file, large file
  2. receive_delta_file() — test with valid delta, empty delta, corner case deltas
  3. receive_incremental_check() — test with matching file, different mtime, different size, missing target
  4. file_send_sendfile() — test with regular file, pipe, zero-length file
  5. file_receive() — full receive cycle with various file types
  6. receive_manifest() — test manifest processing for delete
  7. to_disk() — test directory creation, partial paths, edge cases
  8. file_save_to_disk() — test overwrite, temp file, path traversal blocking

Labels: testing, coverage, data-integrity

`src/shared/file.c` is one of the most critical files (373 lines) but only **21% covered**. Key untested functions: | Function | Lines | Status | |----------|-------|--------| | `old_data_from_path()` | 140-157 | 0 hits | | `receive_delta_file()` | 158-309 | 0 hits | | `receive_incremental_check()` | 311-433 | 0 hits | | `file_send_sendfile()` | 436-467 | 0 hits | | `file_receive()` | 470-519 | 0 hits | | `receive_manifest()` | 521-560 | 0 hits | | `to_disk()` | 562-596 | partially covered | | `file_save_to_disk()` | 209-246 | partially covered | These are the core I/O functions for the sync operation. Bugs here cause data corruption. ## Suggested tests 1. `old_data_from_path()` — test with existing file, missing file, empty file, large file 2. `receive_delta_file()` — test with valid delta, empty delta, corner case deltas 3. `receive_incremental_check()` — test with matching file, different mtime, different size, missing target 4. `file_send_sendfile()` — test with regular file, pipe, zero-length file 5. `file_receive()` — full receive cycle with various file types 6. `receive_manifest()` — test manifest processing for delete 7. `to_disk()` — test directory creation, partial paths, edge cases 8. `file_save_to_disk()` — test overwrite, temp file, path traversal blocking **Labels**: testing, coverage, data-integrity
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#132