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
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install -y build-essential
- name: Build and run native tests
run: |
if [ -f Makefile ] && make -n test 2>/dev/null; then make test; fi
for f in test/test_*.c tests/test_*.c; do
if [ -f "$f" ]; then
gcc -o /tmp/test_run "$f" -I. -lm 2>/dev/null && /tmp/test_run || true
fi
done
21 changes: 20 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
.DS_Store
.DS_Store
# Auto-added by Marisol pipeline
.env
.cache/
build/
.pio/
*.o
*.so

# Auto-added by Marisol pipeline
__pycache__/
*.pyc
.pytest_cache/
debug_*.py
dist/
*.egg-info/
node_modules/
.gradle/
*.class
local.properties
27 changes: 27 additions & 0 deletions Makefile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Test Makefile for in-plants firmware
CC = gcc
CFLAGS = -I. -I.pio/libdeps/native/Unity/src -I.pio/build/native/unity_config -Wall -Wextra
UNITY_SRC = .pio/libdeps/native/Unity/src/unity.c
TEST_SRC = test/test_sensor_data.c
TEST_OBJ = test_sensor_data.o
UNITY_OBJ = unity.o
TEST_RUNNER = test_runner

.PHONY: all clean test

all: $(TEST_RUNNER)

$(TEST_RUNNER): $(TEST_OBJ) $(UNITY_OBJ)
$(CC) $(CFLAGS) -o $@ $^ -lm

$(TEST_OBJ): $(TEST_SRC)
$(CC) $(CFLAGS) -c $< -o $@

$(UNITY_OBJ): $(UNITY_SRC)
$(CC) $(CFLAGS) -c $< -o $@

test: $(TEST_RUNNER)
./$(TEST_RUNNER)

clean:
rm -f $(TEST_OBJ) $(UNITY_OBJ) $(TEST_RUNNER)
13 changes: 13 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[platformio]
default_envs = native

[env:esp32]
platform = atmelavr
board = uno
framework = arduino
build_flags = -DDISABLE_DIAGNOSTIC_OUTPUT

[env:native]
platform = native
build_flags = -DNATIVE_BUILD -std=c++17
test_build_src = false
9 changes: 9 additions & 0 deletions test/test_native/test_placeholder.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <unity.h>
void setUp(void) {}
void tearDown(void) {}
void test_placeholder_passes(void) { TEST_ASSERT_TRUE(1); }
int main(void) {
UNITY_BEGIN();
RUN_TEST(test_placeholder_passes);
return UNITY_END();
}
Loading
Loading