Skip to content

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Jan 6, 2026

syscalls: beef up write(2) and pwrite(2) tests

Fixes #2370

Add comprehensive tests for write(2), pwrite(2), and writev(2) syscalls
to improve coverage as requested in the issue.

New tests include:

  • Bad buffer states (EFAULT): nullptr buffer, bad iov_base address
  • Bad file descriptors (EBADF): closed fd, negative fd, read-only fd, O_PATH fd
  • Offset behavior: verify offset increments, pwrite doesn't change offset
  • EOF handling: write extends past EOF, pwrite creates holes
  • Pipes: write to pipe, pwrite returns ESPIPE, write to read end fails
  • Symlinks: write through symlink, O_NOFOLLOW returns ELOOP
  • Special files: /dev/null and /dev/zero
  • writev edge cases: empty iovec, zero-length entries

Also adds similar tests to pwrite64.cc for consistency.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#12426 from 0xzre:write-syscall-tests 4f4666f

@copybara-service copybara-service bot added the exported Issue was exported automatically label Jan 6, 2026
@copybara-service copybara-service bot force-pushed the test/cl852782177 branch 5 times, most recently from 9078452 to 1bd22af Compare January 8, 2026 16:40
Fixes #2370

Add comprehensive tests for write(2), pwrite(2), and writev(2) syscalls
to improve coverage as requested in the issue.

New tests include:
- Bad buffer states (EFAULT): nullptr buffer, bad iov_base address
- Bad file descriptors (EBADF): closed fd, negative fd, read-only fd, O_PATH fd
- Offset behavior: verify offset increments, pwrite doesn't change offset
- EOF handling: write extends past EOF, pwrite creates holes
- Pipes: write to pipe, pwrite returns ESPIPE, write to read end fails
- Symlinks: write through symlink, O_NOFOLLOW returns ELOOP
- Special files: /dev/null and /dev/zero
- writev edge cases: empty iovec, zero-length entries

Also adds similar tests to `pwrite64.cc` for consistency.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#12426 from 0xzre:write-syscall-tests 4f4666f
PiperOrigin-RevId: 852782177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Beef up write syscall tests

1 participant