run-c-unit-tests

Build and run C/C++ unit tests with Google Test filters and sanitizer options.

6.2k|596|Updated May 5, 2016
One-click install
npx skills add https://github.com/RediSearch/RediSearch --skill run-c-unit-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: run-c-unit-tests
Source: https://github.com/RediSearch/RediSearch/tree/main/.skills/run-c-unit-tests
Command: npx skills add https://github.com/RediSearch/RediSearch --skill run-c-unit-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

After modifying C or C++ code in the RediSearch codebase, developers need a fast, consistent way to verify nothing is broken without memorizing build flags, binary paths, and test filter syntax.

Core Features & Use Cases

  • Full Test Suite Execution: Build the project and run all C and C++ unit tests with a single command via build.sh.
  • Targeted Test Runs: Execute specific Google Test suites or individual tests using gtest filters, or run individual C test binaries directly.
  • Memory Error Detection: Run tests under AddressSanitizer to catch use-after-free, buffer overflows, and leaks, with debug builds for detailed assertion traces.
  • Use Case: After refactoring the inverted index implementation, run only the InvertedIndexTest suite with a gtest filter to confirm the change before committing.

Quick Start

Run all C and C++ unit tests to verify my recent code changes did not break anything.

Frequently Asked Questions about run-c-unit-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How to run all C and C++ unit tests in RediSearch?

Execute ./build.sh RUN_UNIT_TESTS ENABLE_ASSERT=1 from the repository root. This builds the project if needed and runs all C and C++ unit test binaries in one step.

How do I detect memory leaks in C unit tests?

Build and run the tests with AddressSanitizer enabled using ./build.sh RUN_UNIT_TESTS SAN=address. This detects use-after-free, buffer overflows, and memory leaks, printing a leak summary and error details.

How do I list available Google Test cases without running them?

Run the rstest binary with the --gtest_list_tests flag. This prints all registered test suites and test names without executing any of them, which helps when constructing filter patterns.

How do I debug a failing C++ test with gdb?

First build test binaries with ./build.sh TESTS DEBUG=1, then launch gdb on the rstest binary and run it with --gtest_filter set to the failing test. For C tests, run gdb directly on the individual test binary under tests/ctests/.