Skip to content

Comments

fix: accept both EINVAL and ENOENT for readlink(undef)#205

Open
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/fix-175-readlink-errno
Open

fix: accept both EINVAL and ENOENT for readlink(undef)#205
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/fix-175-readlink-errno

Conversation

@Koan-Bot
Copy link
Contributor

Summary

  • Accept both EINVAL and ENOENT for readlink(undef) and readlink() in tests
  • Removes fragile $^O eq 'freebsd' check that didn't account for FreeBSD version differences

Problem

The test assumed readlink(undef) returns EINVAL on FreeBSD and ENOENT on everything else. But the errno depends on the OS version, not just the OS:

  • FreeBSD 14+: EINVAL (22)
  • FreeBSD 12: ENOENT (2)
  • Linux: ENOENT (2)

This caused test failures on FreeBSD 12 smokers (as reported by @eserte in #63).

Fix

Replace the $^O-based branching with a simple ok($! == EINVAL || $! == ENOENT, ...) check. Applied to all 4 occurrences (REAL MODE and MOCK MODE, both readlink(undef) and readlink()).

Test plan

  • All 4 readlink(undef/empty) errno checks now accept both values
  • Diagnostic output shows the actual errno value for debugging

Fixes #175


🤖 Generated with Claude Code

@atoomic atoomic marked this pull request as ready for review February 22, 2026 16:50
The errno set by readlink(undef) varies by OS and version:
- FreeBSD 14+ returns EINVAL
- FreeBSD 12 and Linux return ENOENT

The test was using $^O eq 'freebsd' to decide which errno to expect,
but this fails on older FreeBSD versions. Accept both values instead.

Fixes cpanel#175

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Koan-Bot Koan-Bot force-pushed the koan.atoomic/fix-175-readlink-errno branch from 6338454 to 2dbc08f Compare February 24, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Failed test '$! is EINVAL for a readlink(undef)'

1 participant