OpenParable
Skip to content
← Back to skills

Run C Unit Tests

Testing & Quality
run-c-unit-tests

Run C Unit Tests is an Agent Skill for testing & quality published in the RediSearch/RediSearch repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Run C/C++ unit tests to verify correctness. Use this after making changes to C code to verify nothing is broken.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/RediSearch/RediSearch/blob/HEAD/.skills/run-c-unit-tests/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/run-c-unit-tests, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Run C/C++ Unit Tests

Build and run the C/C++ unit test suite.

Arguments

  • No arguments: Run all C/C++ unit tests
  • <test_name>: Run a specific unit test (matched by name or gtest filter)

Arguments provided: $ARGUMENTS

Instructions

All Unit Tests

./build.sh RUN_UNIT_TESTS ENABLE_ASSERT=1

This builds the project (if needed) and runs all C and C++ unit test binaries.

Specific C++ Tests (Google Test)

C++ tests use Google Test and compile into a single binary:

bin/<target>/search-community/tests/cpptests/rstest --gtest_filter=<pattern>

The <target> is your architecture (e.g., linux-x64). Use ls bin/ to find it.

Filter examples:

# Run all tests in a test suite
rstest --gtest_filter='InvertedIndexTest.*'

# Run a specific test
rstest --gtest_filter='InvertedIndexTest.TestBasic'

# Run tests matching a pattern
rstest --gtest_filter='*NumericRange*'

To list available tests without running them:

rstest --gtest_list_tests

Specific C Tests

C test binaries are individual executables under:

bin/<target>/search-community/tests/ctests/

Run a specific C test by executing the binary directly:

bin/<target>/search-community/tests/ctests/test_<name>

With AddressSanitizer

To detect memory errors (use-after-free, buffer overflow, leaks):

./build.sh RUN_UNIT_TESTS SAN=address

Debug Build

For more detailed assertion failures and stack traces:

./build.sh RUN_UNIT_TESTS DEBUG=1 ENABLE_ASSERT=1

Debugging Failed Tests

To debug a failing test under gdb/lldb:

# Build test binaries
./build.sh TESTS DEBUG=1

# Run under debugger
gdb bin/<target>/search-community/tests/cpptests/rstest
(gdb) run --gtest_filter='<failing_test>'

For C tests:

gdb bin/<target>/search-community/tests/ctests/test_<name>
(gdb) run

Interpreting Output

Google Test output shows:

  • [ PASSED ] — test succeeded
  • [ FAILED ] — test failed, with assertion details (file, line, expected vs. actual)
  • [ DISABLED ] — test is explicitly disabled

C test binaries typically print assertions to stderr and exit with non-zero on failure.

Report

After running the tests, provide:

  • Number of tests passed / failed / skipped
  • For each failing test:
    • Test name and suite
    • The assertion that failed (file:line, expected vs. actual values)
    • Relevant context from the test output
  • If AddressSanitizer was used, include any sanitizer findings (leak summary, error details)