Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitlint
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ ignore-merge-commits=false
ignore-fixup-commits=false
ignore-fixup-amend-commits=false
ignore-squash-commits=false
regex-style-search=true

[title-match-regex]
regex=[a-z0-9/]+: .*
# Format: "area: description" where area is either:
# - A path with at least one / (e.g., fw/drivers/hrm, third_party/nonfree)
# - One of the known short areas: ci, treewide, platform, sdk, tools, resources,
# docs, waftools, settings, libc, tests, notifications, build, wscript, fw,
# third_party, ancs, compositor, console, kernel, health
# Conventional commit types like feat:, fix:, chore: are NOT allowed.
regex=^([a-z0-9_]+/[a-z0-9_/]*|ci|treewide|platform|sdk|tools|resources|docs|waftools|settings|libc|tests|notifications|build|wscript|fw|third_party|ancs|compositor|console|kernel|health|gitlint|readme|requirements|python_libs|pbl-tool|pbl|moddable|libutil|iconography|gitignore|capabilities|asterix|activity|accel): .*

[title-max-length]
line-length=100
106 changes: 106 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Running Tests

## Cross-Platform Test Fixtures

Graphics test fixtures are platform-specific due to differences in:
- Font rendering libraries (FreeType, HarfBuzz)
- Standard library implementations
- ARM toolchain behavior

Test fixtures are named with the format: `test_name~platform-os.pbi`
- `~spalding-linux.pbi` - Generated on Linux (CI environment)
- `~spalding-darwin.pbi` - Generated on macOS (local development)

## Local Development

### macOS Developers

**Option 1: Use Docker (Recommended)**

Run tests in Docker to match the CI environment exactly:

```bash
# Run all tests
./tests/run-tests-docker.sh

# Run specific tests
./tests/run-tests-docker.sh -M "test_kickstart"

# Use specific board
TEST_BOARD=snowy_bb2 ./tests/run-tests-docker.sh
```

This ensures your test results match CI exactly.

**Option 2: Generate macOS Fixtures**

If you prefer to run tests natively on macOS:

```bash
# Configure and build
./waf configure --board=snowy_bb2
./waf test

# This will generate macOS-specific fixtures (~spalding-darwin.pbi)
# which will be used instead of the Linux fixtures
```

Note: macOS-generated fixtures will differ from Linux fixtures. This is expected
and doesn't indicate a problem with your changes. Use Docker to verify against CI.

### Linux Developers

Run tests normally - your environment matches CI:

```bash
./waf configure --board=snowy_bb2
./waf test
```

## Updating Fixtures

When you intentionally change rendering behavior:

1. **Run tests in Docker** to generate new Linux fixtures:
```bash
./tests/run-tests-docker.sh
```

2. **Copy the generated fixtures** from the failed test directory:
```bash
cp build/test/tests/failed/*-expected.pbi tests/fixtures/graphics/
```

3. **Update filenames** to include the `-linux` suffix if needed:
```bash
# Rename from ~spalding.pbi to ~spalding-linux.pbi
```

4. **Commit and push** the updated fixtures

## CI Environment

- Container: `ghcr.io/coredevices/pebbleos-docker:v3`
- OS: Ubuntu 24.04 (Linux)
- Board: snowy_bb2
- Compiler: arm-none-eabi-gcc 14.2.Rel1

## Troubleshooting

### Tests pass locally but fail on CI

Run tests in Docker to reproduce CI results:
```bash
./tests/run-tests-docker.sh
```

### Tests fail locally but pass on CI

Generate macOS-specific fixtures or use Docker for local development.

### Fixture naming confusion

The test framework automatically selects the correct fixture based on your OS:
- On Linux: Uses `~spalding-linux.pbi`
- On macOS: Uses `~spalding-darwin.pbi`
- Falls back to `~spalding.pbi` if OS-specific doesn't exist
34 changes: 18 additions & 16 deletions tests/fakes/fake_HCIAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
#include "util/list.h"

#include <stdlib.h>
#include <string.h>

// BD_ADDR_t is typically a pointer to uint8_t or uint8_t array
// This helper converts BTDeviceAddress to the expected format
static const uint8_t *BTDeviceAddressToBDADDR(BTDeviceAddress addr) {
return addr.octets;
}

typedef struct {
ListNode node;
Expand Down Expand Up @@ -63,10 +70,9 @@ int HCI_LE_Add_Device_To_White_List(unsigned int BluetoothStackID,
return -1;
}

const WhitelistEntry model = {
.Address_Type = Address_Type,
.Address = Address,
};
WhitelistEntry model;
model.Address_Type = Address_Type;
memcpy(model.Address, Address, sizeof(BD_ADDR_t));

{
WhitelistEntry *e = prv_find_whitelist_entry(&model);
Expand All @@ -78,10 +84,8 @@ int HCI_LE_Add_Device_To_White_List(unsigned int BluetoothStackID,
}

WhitelistEntry *e = (WhitelistEntry *) malloc(sizeof(WhitelistEntry));
*e = (const WhitelistEntry) {
.Address_Type = Address_Type,
.Address = Address,
};
e->Address_Type = Address_Type;
memcpy(e->Address, Address, sizeof(BD_ADDR_t));
s_head = (WhitelistEntry *) list_prepend(&s_head->node, &e->node);
return 0;
}
Expand All @@ -90,10 +94,9 @@ int HCI_LE_Remove_Device_From_White_List(unsigned int BluetoothStackID,
Byte_t Address_Type,
BD_ADDR_t Address,
Byte_t *StatusResult) {
const WhitelistEntry model = {
.Address_Type = Address_Type,
.Address = Address,
};
WhitelistEntry model;
model.Address_Type = Address_Type;
memcpy(model.Address, Address, sizeof(BD_ADDR_t));
WhitelistEntry *e = prv_find_whitelist_entry(&model);
if (e) {
list_remove(&e->node, (ListNode **) &s_head, NULL);
Expand All @@ -107,10 +110,9 @@ int HCI_LE_Remove_Device_From_White_List(unsigned int BluetoothStackID,
}

bool fake_HCIAPI_whitelist_contains(const BTDeviceInternal *device) {
const WhitelistEntry model = {
.Address_Type = device->is_random_address ? 0x01 : 0x00,
.Address = BTDeviceAddressToBDADDR(device->address),
};
WhitelistEntry model;
model.Address_Type = device->is_random_address ? 0x01 : 0x00;
memcpy(model.Address, device->address.octets, sizeof(BD_ADDR_t));
return (prv_find_whitelist_entry(&model) != NULL);
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 5 additions & 1 deletion tests/fw/graphics/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ static const char *namecat(const char* str1, const char* str2){
printf("filename and filename_xbit %s : %s\n", filename, filename_xbit);
} else {
#if !PLATFORM_DEFAULT
// Add ~platform to files with unit-tests built for a specific platform
// Append platform suffix for non-default platforms
strcat(filename, "~");
strcat(filename, PLATFORM_NAME);
#if defined(__APPLE__)
// On macOS, also append -darwin to differentiate local dev fixtures from CI
strcat(filename, "-darwin");
#endif
#endif
}

Expand Down
42 changes: 42 additions & 0 deletions tests/generate-linux-fixtures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2026 Core Devices LLC
# SPDX-License-Identifier: Apache-2.0
# Generate Linux fixtures using Docker
# This script runs tests in Docker to generate Linux-specific test fixtures

set -e

DOCKER_IMAGE="ghcr.io/coredevices/pebbleos-docker:v3"
BOARD="${TEST_BOARD:-snowy_bb2}"
TEST_MATCH="${1:-}"

echo "Generating Linux fixtures for board: $BOARD"
if [ -n "$TEST_MATCH" ]; then
echo "Running tests matching: $TEST_MATCH"
fi

docker run --rm --platform linux/amd64 \
-v "$(pwd):/work:cached" \
-w /work \
"$DOCKER_IMAGE" \
bash -c "
set -e
echo 'Installing dependencies...'
pip install -U pip > /dev/null 2>&1
pip install -r requirements.txt > /dev/null 2>&1

echo 'Configuring...'
rm -f .wafpickle* .lock-waf* 2>/dev/null
./waf configure --board=$BOARD

echo 'Running tests...'
if [ -n '$TEST_MATCH' ]; then
./waf test -M '$TEST_MATCH' || true
else
./waf test || true
fi

echo ''
echo 'Generated fixtures are in: build/test/tests/failed/'
echo 'Copy them with: cp build/test/tests/failed/*-expected.pbi tests/fixtures/graphics/'
"
24 changes: 24 additions & 0 deletions tests/run-tests-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2026 Core Devices LLC
# SPDX-License-Identifier: Apache-2.0
# Run tests in Docker to match CI environment
# This ensures consistent test results across different development platforms

set -e

DOCKER_IMAGE="ghcr.io/coredevices/pebbleos-docker:v3"
BOARD="${TEST_BOARD:-snowy_bb2}"

echo "Running tests in Docker for board: $BOARD"
echo "This matches the CI environment for consistent test results"

docker run --rm --platform linux/amd64 \
-v "$(pwd):/work:cached" \
-w /work \
"$DOCKER_IMAGE" \
./waf configure --board="$BOARD" \
&& docker run --rm --platform linux/amd64 \
-v "$(pwd):/work:cached" \
-w /work \
"$DOCKER_IMAGE" \
./waf test "$@"
Binary file modified tests/test_images/test_kickstart__render_PBL_43717~spalding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion tests/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ def build(bld):
'test_graphics_gtransform_8bit.c',
'test_hrm_manager.c',
'test_js.c',
'test_kickstart.c',
'test_launcher_menu_layer.c',
'test_pfs.c',
'test_selection_windows.c',
Expand Down
Loading