Skip to content

Extract sbuf library and integrate unit testing#3

Merged
Zaid-maker merged 4 commits intomainfrom
migrate-heap-backed-allocation
Mar 29, 2026
Merged

Extract sbuf library and integrate unit testing#3
Zaid-maker merged 4 commits intomainfrom
migrate-heap-backed-allocation

Conversation

@Zaid-maker
Copy link
Copy Markdown
Owner

@Zaid-maker Zaid-maker commented Mar 29, 2026

Summary by CodeRabbit

  • New Features
    • Automated unit tests now execute in CI/CD pipelines before kernel builds
    • Host-side testing infrastructure provided for developers
  • Documentation
    • Added unit test execution instructions and updated regression testing checklist

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

Warning

Rate limit exceeded

@Zaid-maker has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 37 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 37 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a7a8f8fe-63f9-4938-ab6c-6a8c759d7229

📥 Commits

Reviewing files that changed from the base of the PR and between 9af0081 and 8821d61.

📒 Files selected for processing (8)
  • .github/skills/kernel-from-start/SKILL.md
  • README.md
  • kernel/Makefile
  • kernel/VERSION
  • kernel/src/sbuf.c
  • kernel/tests/sbuf_integration_test.c
  • kernel/tests/sbuf_test.c
  • site/index.html
📝 Walkthrough

Walkthrough

The PR extracts string buffer formatting utilities from kernel.c into a reusable sbuf library (header, implementation, tests), refactors kernel.c to use the new functions, and integrates host-side unit testing into the build system and CI workflows.

Changes

Cohort / File(s) Summary
String Buffer Library
kernel/src/sbuf.h, kernel/src/sbuf.c
New string buffer API with functions for resetting buffers, appending characters/strings, and formatting unsigned integers in decimal and hexadecimal forms with capacity/bounds checking.
Test Suite
kernel/tests/sbuf_test.c
New host-side unit tests validating sbuf functionality including character/string/integer appends, hexadecimal formatting, and capacity overflow guards with pass/fail assertions.
Kernel Refactoring
kernel/src/kernel.c
Removed 6 local string-building helper functions and replaced with include of sbuf.h to use externally provided implementations.
Build System
kernel/Makefile
Added host compiler support (HOST_CC, HOST_CFLAGS), included src/sbuf.c in kernel sources, and introduced test phony target to build and run sbuf_test.
CI Workflows
.github/workflows/build-kernel.yml, .github/workflows/release-kernel.yml
Added conditional and unconditional make test steps (with CROSS_COMPILE=) executing before kernel binary/ISO builds.
Documentation
README.md
Added "Run Unit Tests" section documenting make -C kernel test invocation and updated regression checklist to confirm sbuf.c unit test coverage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit hops through kernel code with glee,
Extracted buffers, now reusable and free!
Tests verify each character appends right,
Hex formatting shines with bounds-check delight,
Hop-hop, the CI pipeline tests with care! 🐰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed Title check skipped as CodeRabbit has written the PR title.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate-heap-backed-allocation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot changed the title @coderabbitai Extract sbuf library and integrate unit testing Mar 29, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@kernel/src/sbuf.c`:
- Around line 17-30: sbuf_append_str currently returns early when *len + 1u >=
cap without null-terminating the buffer; update the function so that before any
early return (inside the if checking capacity) you write buffer[*len] = '\0'
(using the current *len value) to ensure the buffer is always NUL-terminated on
partial writes, leaving the rest of logic in sbuf_append_str unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1bbb4641-f282-4134-a091-f601804e5d4f

📥 Commits

Reviewing files that changed from the base of the PR and between 0bec007 and 9af0081.

📒 Files selected for processing (8)
  • .github/workflows/build-kernel.yml
  • .github/workflows/release-kernel.yml
  • README.md
  • kernel/Makefile
  • kernel/src/kernel.c
  • kernel/src/sbuf.c
  • kernel/src/sbuf.h
  • kernel/tests/sbuf_test.c

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.

1 participant