googletest-embedded-arm
БесплатноБез исполняемых скриптовНе проверенUse for any task that writes or runs GoogleTest tests for embedded C++ (C++17 or later) on ARM, even one test with a mock, including firmware tests that pass…
от testland★ 18 звёзд на GitHubОб этом скилле
googletest-embedded-arm
Overview
GoogleTest is, per the README at
github.com/google/googletest,
"Google's C++ test framework" - an xUnit-style framework merged
with GoogleMock so the two ship together. The 1.17.x branch
"requires at least C++17". For embedded ARM use, the framework
runs anywhere a hosted C++ standard library is available - on
the host, under QEMU, and on Cortex-A Linux targets; for
Cortex-M without an OS, a minimal _write / _exit semihosting
stub is the bridge.
This skill wraps GoogleTest for embedded C++ work. Composes with:
embedded-coverage-strategy-referencefor gcov / llvm-cov instrumentation.qemu-system-test-runnerfor running the binary on a virtual Cortex-M / Cortex-A.- For pure-C suites, prefer
unity-test-framework-c; for mock-heavy suites prefer the Ceedling stack -ceedling-build-runner(CMock semantics in its references/cmock.md).
When to use
- Unit-under-test is C++ (not C). For C, use
unity-test-framework-c. - Target is Cortex-A running Linux or Cortex-M with semihosting - anything with enough RAM for the gtest binary (~300 KB stripped).
- Team wants the de-facto C++ framework with rich matchers (GoogleMock, value-parameterised tests, typed tests).
- The build pipeline can run a host build for speed and a cross-compile under QEMU for architecture sanity.
How to use
- Confirm the unit-under-test is C++17+ (for C, use
unity-test-framework-c). - Fetch GoogleTest and build the suite on the host for the fast inner loop (
gtest_mainsuppliesmain()); authorTEST()/TEST_F()cases - see Authoring. - Cross-compile the same suite for the ARM target with
arm-none-eabi-g++and run it under QEMU for architecture sanity - full toolchain, CMake, and build invariants in references/cross-compile-and-ci.md. - Emit
--gtest_output=xml:results.xml; gate the host job on the JUnit XML and the QEMU job on the semihosting exit code. - Reach for value-parameterised (
TEST_P), typed (TYPED_TEST), and death tests as coverage grows - see references/authoring-variants.md.
The full single-test path (author to QEMU) is in Worked example below.
Authoring
Minimal test
Per google.github.io/googletest/primer.html:
#include <gtest/gtest.h>
#include "ringbuffer.h"
TEST(RingbufferTest, EmptyOnInit) {
Ringbuffer<int, 8> rb;
EXPECT_TRUE(rb.empty());
EXPECT_EQ(0u, rb.size());
}
TEST(RingbufferTest, PushIncrementsSize) {
Ringbuffer<int, 8> rb;
rb.push(42);
EXPECT_EQ(1u, rb.size());
EXPECT_FALSE(rb.empty());
}
TEST(SuiteName, TestName) registers an independent test; the
first argument is "the name of the test suite, and the second
argument is the test's name within the test suite" (Primer doc).
Fixtures (TEST_F)
When several tests share setup, derive from ::testing::Test:
class RingbufferTest : public ::testing::Test {
protected:
void SetUp() override { rb.clear(); }
void TearDown() override { /* nothing */ }
Ringbuffer<int, 8> rb;
};
TEST_F(RingbufferTest, PopReturnsPushedValue) {
rb.push(7);
int v = 0;
EXPECT_TRUE(rb.pop(&v));
EXPECT_EQ(7, v);
}
Per the Primer: "GoogleTest does not reuse the same test fixture
for multiple tests" - each TEST_F gets a fresh instance.
Fatal vs non-fatal
| Family | On failure | Use when |
|---|---|---|
EXPECT_* (e.g. EXPECT_EQ) |
Records failure; continues | Each assertion is independent; collect all failures |
ASSERT_* (e.g. ASSERT_EQ) |
Records failure; aborts current function | Subsequent assertions would crash (e.g. null pointer deref) |
Per the Primer: "Usually EXPECT_* are preferred, as they allow
more than one failure to be reported in a test." Use ASSERT_*
only when the next line would dereference a possibly-null pointer
returned from the previous check.
Value-parameterised (TEST_P), typed (TYPED_TEST), and death
tests live in references/authoring-variants.md.
Worked example
One test from host to QEMU, end to end. It uses the
RingbufferTest cases from Authoring above.
Put those cases in
test/ringbuffer_test.cpp.Host build + run (fast inner loop) with the CMake config from references/cross-compile-and-ci.md:
cmake -S . -B build-host && cmake --build build-host
./build-host/ringbuffer_test
# [==========] Running 2 tests from 1 test suite.
# [ PASSED ] 2 tests.
- Cross-compile the same source for Cortex-M4 and run it under QEMU:
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -O0 -g -std=c++17 \
-DGTEST_HAS_PTHREAD=0 --specs=rdimon.specs \
-I ext/googletest/googletest/include \
test/ringbuffer_test.cpp ext/googletest/googletest/src/gtest-all.cc \
-o ringbuff
Установить googletest-embedded-arm в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл googletest-embedded-arm?
Use for any task that writes or runs GoogleTest tests for embedded C++ (C++17 or later) on ARM, even one test with a mock, including firmware tests that pass on the host but fail on the target: TEST, TEST_F and parameterized tests, EXPECT vs ASSERT, fixtures, GoogleMock, cross-compiling with arm-none-eabi-g++, running on host or QEMU and XML output for CI. Pure C uses unity-test-framework-c.
Как установить скилл googletest-embedded-arm?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл googletest-embedded-arm запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic