Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wrapped_facade_headers): Expand sys/types.h facade to cover all Linux Glibc typedefs that are also present in macOS. #53

Merged
merged 23 commits into from
Apr 9, 2025

Conversation

Bill-hbrhbr
Copy link
Collaborator

@Bill-hbrhbr Bill-hbrhbr commented Apr 8, 2025

Description

Reference points (newest releases of each platform):

Referenced files/directories:

We only include types that are directly type-defed in sys/types.h and have their MacOS XNU typedef versions directly found in either sys/types.h or sys/_types/*.h. The following types are excluded because their typedefs cannot be found in the XNU version, perhaps due to their 64-bit nature:

  • loff_t
  • off64_t (defined in sys/dtrace.h)
  • blkcnt64_t
  • fsblkcnt64_t
  • fsfilcnt64_t

Because <ystdlib/wrapped_facade_headers/sys/types.h> is supposed to align with Linux Glibc, we don't include types that are present in XNU's two referenced locations but not found in Glibc sys/types.h.

This PR will fix y-scope/clp#800 and hopefully eliminate many facade header iterations for sys/types.h in the future.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • Updated test cases for all wrapped types in sys/types.h.

Summary by CodeRabbit

  • Tests

    • Replaced outdated unit tests with a comprehensive suite that validates the proper initialization of various system data types, including u_char, u_short, and fsid_t.
  • Chores

    • Enhanced header files with robust inclusion safeguards and introduced platform-specific improvements for Apple environments.

Copy link

coderabbitai bot commented Apr 8, 2025

Walkthrough

This pull request updates the test configuration by replacing the test_off_t.cpp file with a new test_sys_types.cpp file, reflecting a change in testing focus. The header file for system types (sys/types.h) is updated with a header guard and additional Apple-specific include directives to support various type definitions. The removed test file and the new comprehensive test file ensure that a wider range of system types are verified using the Catch2 testing framework.

Changes

File(s) Change Summary
src/ystdlib/wrapped_facade_headers/CMakeLists.txt Updated test source entry from test/test_off_t.cpp to test/test_sys_types.cpp.
src/ystdlib/wrapped_facade_headers/sys/types.h Added a header guard and Apple-specific include directives for various type definitions.
src/ystdlib/wrapped_facade_headers/test/test_off_t.cpp
src/ystdlib/wrapped_facade_headers/test/test_sys_types.cpp
Removed the test_off_t.cpp unit test and added test_sys_types.cpp to comprehensively test multiple system types.

Possibly related PRs

Suggested reviewers

  • davidlion

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9ea397 and 2cca40c.

📒 Files selected for processing (1)
  • src/ystdlib/wrapped_facade_headers/test/test_sys_types.cpp (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • src/ystdlib/wrapped_facade_headers/test/test_sys_types.cpp
🪛 Cppcheck (2.10-2)
src/ystdlib/wrapped_facade_headers/test/test_sys_types.cpp

[error] 11-11: syntax error

(syntaxError)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-check (ubuntu-24.04)
  • GitHub Check: lint-check (macos-15)
🔇 Additional comments (6)
src/ystdlib/wrapped_facade_headers/test/test_sys_types.cpp (6)

1-4: Includes look appropriate.

The file correctly includes the necessary headers: the wrapped facade header being tested and the Catch2 test framework header.


5-5: Namespace declaration is correct.

The code properly uses the ystdlib::wrapped_facade_headers::test namespace, which aligns with the file location and purpose.


6-9: Test case for u_char follows best practices.

The test correctly verifies that a u_char can be initialized to zero. Good job following the coding guidelines by using 0 == i rather than i == 0.


36-45: Platform-specific test implementation for fsid_t is appropriate.

The test correctly handles the platform differences between Linux and Apple for the fsid_t structure:

  • On Linux, it accesses the member as __val[i]
  • On Apple, it accesses the member as val[i]

This conditional compilation ensures the test runs correctly on both platforms.


107-110: Pointer type test case is implemented correctly.

Unlike the numeric types that use 0, this test correctly uses nullptr for the pointer type caddr_t, which is the appropriate initialization value for pointer types.


11-166: Comprehensive test coverage for system types.

The test file provides thorough coverage of all the system types mentioned in the PR objectives. Each test follows a consistent pattern:

  1. Initialize a constant variable of the specific type to zero
  2. Verify the initialization with a REQUIRE assertion

The tests are well-organized, properly tagged for Catch2 test filtering, and follow the project's coding guidelines by using 0 == i rather than i == 0 format for comparisons.

One consideration: You could potentially reduce duplication by using a template function for types that share the same testing pattern, but the current approach has the advantage of clarity and explicit test names.

🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 11-11: syntax error

(syntaxError)

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Bill-hbrhbr Bill-hbrhbr changed the title feat(wrapped_facade_headers): Redo sys/types.h feat(wrapped_facade_headers): Expand sys/types.h facade to cover all Linux Glibc typedefs that are also present in MacOS XNU. Apr 8, 2025
@Bill-hbrhbr Bill-hbrhbr marked this pull request as ready for review April 8, 2025 08:07
@Bill-hbrhbr Bill-hbrhbr requested a review from a team as a code owner April 8, 2025 08:07
@davidlion davidlion changed the title feat(wrapped_facade_headers): Expand sys/types.h facade to cover all Linux Glibc typedefs that are also present in MacOS XNU. feat(wrapped_facade_headers): Expand sys/types.h facade to cover all Linux Glibc typedefs that are also present in macOS. Apr 9, 2025
@Bill-hbrhbr Bill-hbrhbr merged commit d3fc980 into y-scope:main Apr 9, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants