Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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-reference for gcov / llvm-cov instrumentation.
  • qemu-system-test-runner for 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

  1. Confirm the unit-under-test is C++17+ (for C, use unity-test-framework-c).
  2. Fetch GoogleTest and build the suite on the host for the fast inner loop (gtest_main supplies main()); author TEST() / TEST_F() cases - see Authoring.
  3. 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.
  4. Emit --gtest_output=xml:results.xml; gate the host job on the JUnit XML and the QEMU job on the semihosting exit code.
  5. 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.

  1. Put those cases in test/ringbuffer_test.cpp.

  2. 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.
  1. 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
Полный SKILL.md на GitHub

Установить googletest-embedded-arm в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.tessl-plugin/plugin.jsonreferences/authoring-variants.mdreferences/cross-compile-and-ci.md

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), без исполняемых скриптов.

Похожие скиллы

Сравнить googletest-embedded-arm с