diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d219896b42..643077fe87 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -12,24 +12,24 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Cache arduino dep downloads
- uses: actions/cache@v2
+ uses: actions/cache@v4
with:
path: ${{ github.workspace}}/.arduino/downloads
key: ${{ runner.os }}-arduino-downloads
- run: make setup
- run: KALEIDOSCOPE_TEMP_PATH=${{ github.workspace}}/.kaleidoscope-temp make -j $(nproc) smoke-sketches
- run-google-tests:
+ run-simulator-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache arduino dep downloads
- uses: actions/cache@v2
+ uses: actions/cache@v4
with:
path: ${{ github.workspace}}/.arduino/downloads
key: ${{ runner.os }}-arduino-downloads
- - run: sudo apt update
+ - run: sudo apt update
- name: ccache
- uses: hendrikmuhs/ccache-action@v1.2
+ uses: hendrikmuhs/ccache-action@v1.2.11
- run: make setup
- run: KALEIDOSCOPE_CCACHE=1 make -j $(nproc) --output-sync=recurse simulator-tests
check-code-style:
diff --git a/etc/makefiles/arduino-cli.mk b/etc/makefiles/arduino-cli.mk
index 0826bbacdb..b29a678a2d 100644
--- a/etc/makefiles/arduino-cli.mk
+++ b/etc/makefiles/arduino-cli.mk
@@ -100,7 +100,7 @@ endif
# emoji, since it accurately represents our feelings on this
# state of affairs. Later, when finding props, we need to reverse
# this process, turning fire into space.
-_arduino_props := $(shell ${ARDUINO_CLI} compile $(fqbn_arg) --show-properties "$(_arduino_props_sketch_arg)"|perl -p -e"s/ /🔥/g")
+_arduino_props := $(shell ${ARDUINO_CLI} compile $(fqbn_arg) --show-properties=expanded "$(_arduino_props_sketch_arg)"|perl -p -e"s/ /🔥/g")
_arduino_prop = $(subst $1=,,$(subst 🔥, ,$(filter $1=%,$(_arduino_props))))
diff --git a/plugins/Kaleidoscope-Hardware-Keyboardio-Atreus/src/kaleidoscope/device/keyboardio/Atreus2.cpp b/plugins/Kaleidoscope-Hardware-Keyboardio-Atreus/src/kaleidoscope/device/keyboardio/Atreus2.cpp
index 03a70249b8..066bfff251 100644
--- a/plugins/Kaleidoscope-Hardware-Keyboardio-Atreus/src/kaleidoscope/device/keyboardio/Atreus2.cpp
+++ b/plugins/Kaleidoscope-Hardware-Keyboardio-Atreus/src/kaleidoscope/device/keyboardio/Atreus2.cpp
@@ -16,7 +16,6 @@
* along with this program. If not, see .
*/
-#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
#ifdef ARDUINO_AVR_KEYBOARDIO_ATREUS
#include "kaleidoscope/Runtime.h"
@@ -40,6 +39,8 @@ namespace keyboardio {
// resolved as `KeyScannerProps::matrix_rows`.
const uint8_t KeyScannerProps::matrix_rows;
const uint8_t KeyScannerProps::matrix_columns;
+
+#ifndef KALEIDOSCOPE_VIRTUAL_BUILD
constexpr uint8_t KeyScannerProps::matrix_row_pins[matrix_rows];
constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
@@ -59,10 +60,9 @@ KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows]
ISR(TIMER1_OVF_vect) {
Runtime.device().keyScanner().do_scan_ = true;
}
-
+#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
} // namespace keyboardio
} // namespace device
} // namespace kaleidoscope
#endif
-#endif // ifndef KALEIDOSCOPE_VIRTUAL_BUILD
diff --git a/testing/makefiles/libcommon.mk b/testing/makefiles/libcommon.mk
index c002a3e78f..e128fcf705 100644
--- a/testing/makefiles/libcommon.mk
+++ b/testing/makefiles/libcommon.mk
@@ -1,10 +1,11 @@
mkfile_dir := $(dir $(lastword ${MAKEFILE_LIST}))
top_dir := $(abspath $(mkfile_dir)../..)
+shared_mk := $(mkfile_dir)/shared.mk
-include $(mkfile_dir)/shared.mk
+pathsafe_fqbn := $(subst :,_,${FQBN})
-build_dir := ${top_dir}/_build
+build_dir := ${top_dir}/_build/$(pathsafe_fqbn)
LIB_DIR := ${build_dir}/lib
OBJ_DIR := ${build_dir}/obj
@@ -39,3 +40,4 @@ clean:
$(QUIET) rm -rf -- "${build_dir}"
include $(top_dir)/etc/makefiles/arduino-cli.mk
+include $(shared_mk)
diff --git a/testing/makefiles/shared.mk b/testing/makefiles/shared.mk
index b31ea3a0ec..ba9f5f782a 100644
--- a/testing/makefiles/shared.mk
+++ b/testing/makefiles/shared.mk
@@ -7,14 +7,20 @@ shared_defines := \
-DKEYBOARDIOHID_BUILD_WITHOUT_HID=1 \
-DUSBCON=dummy \
-DARDUINO_ARCH_AVR=1 \
- -DARDUINO_AVR_MODEL01 \
- '-DKALEIDOSCOPE_HARDWARE_H="Kaleidoscope-Hardware-Keyboardio-Model01.h"' \
- '-DUSB_PRODUCT="Model 01"'
+ $(call _arduino_prop,build.extra_flags) \
+ -DARDUINO_$(call _arduino_prop,build.board) \
+ -DUSB_PRODUCT='$(call _arduino_prop,build.usb_product)'
+
+# Extract the kaleidoscope_hardware_h from shared defines
+_hardware_h := $(shell echo $(shared_defines) | sed -n 's/.*-DKALEIDOSCOPE_HARDWARE_H="\([^"]*\)".*/\1/p')
+
+# Find the directory containing the file
+_hardware_plugin_path := $(shell find $(top_dir)/plugins/ -type f -name "$(_hardware_h)" -exec dirname {} \;)
shared_includes := \
-I${top_dir} \
-I${top_dir}/src \
- -I${top_dir}/plugins/Kaleidoscope-Hardware-Keyboardio-Model01/src \
+ -I${_hardware_plugin_path} \
-I${arduino_platform_path}/cores/keyboardio \
-I${top_dir}/plugins/KeyboardioHID/src \
-I${top_dir}/testing/googletest/googlemock/include \
diff --git a/testing/makefiles/testcase.mk b/testing/makefiles/testcase.mk
index 3a905dc25e..5f53c00fba 100644
--- a/testing/makefiles/testcase.mk
+++ b/testing/makefiles/testcase.mk
@@ -22,19 +22,32 @@ MAKEFLAGS += --no-builtin-rules
mkfile_dir := $(dir $(lastword ${MAKEFILE_LIST}))
top_dir := $(abspath $(mkfile_dir)../..)
-include $(mkfile_dir)/shared.mk
+
+# need to set this before we get the FQBN
+SKETCH_FILE := $(wildcard *.ino)
+FQBN = $(shell cat sketch.yaml|grep default_fqbn | cut -d " " -f 2)
+
+pathsafe_fqbn := $(subst :,_,${FQBN})
+
+build_root := ${top_dir}/_build/$(pathsafe_fqbn)
+
+
+export KALEIDOSCOPE_TEMP_PATH := ${build_root}/kaleidoscope
include_plugins_dir := -I${top_dir}/plugins \
-build_dir := ${top_dir}/_build/${testcase}
+build_dir := ${build_root}/${testcase}
LIB_DIR := ${build_dir}/lib
OBJ_DIR := ${build_dir}/obj
BIN_DIR := ${build_dir}/bin
-COMMON_LIB_DIR := ${top_dir}/_build/lib
+COMMON_LIB_DIR := ${build_root}/lib
+libcommon_a := ${COMMON_LIB_DIR}/libcommon.a
+shared_mk := $(mkfile_dir)/shared.mk
include $(top_dir)/etc/makefiles/arduino-cli.mk
+include $(shared_mk)
ifneq ($(KALEIDOSCOPE_CCACHE),)
COMPILER_WRAPPER := ccache
@@ -43,7 +56,6 @@ endif
SRC_DIR := test
-SKETCH_FILE=$(wildcard *.ino)
BIN_FILE=$(subst .ino,,$(SKETCH_FILE))
LIB_FILE=${BIN_FILE}-latest.a
@@ -78,7 +90,7 @@ ${BIN_DIR}/${BIN_FILE}: compile-sketch
# We force sketch recompiliation because otherwise, make won't pick up changes to...anything on the arduino side
.PHONY: compile-sketch
-compile-sketch: ${TEST_OBJS}
+compile-sketch: ${libcommon_a} ${TEST_OBJS}
-@install -d "${BIN_DIR}" "${LIB_DIR}"
$(QUIET) env LIBONLY=yes VERBOSE=${VERBOSE} \
OUTPUT_PATH="${LIB_DIR}" \
@@ -91,6 +103,9 @@ compile-sketch: ${TEST_OBJS}
-L"${top_dir}/testing/googletest/build/lib" \
-lgtest -lgmock -lpthread -lm
+${libcommon_a}:
+ $(QUIET) ${MAKE} -f ${top_dir}/testing/makefiles/libcommon.mk -C ${top_dir}/testing
+
# If we have a test.ktest file, it should be processed into a c++ testcase
.PHONY: generate-testcase
diff --git a/tests/Makefile b/tests/Makefile
index cb6ad0c0b0..f23c859f2b 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -22,16 +22,15 @@ tests_dir := $(abspath $(dir $(lastword ${MAKEFILE_LIST})))
top_dir := $(abspath $(tests_dir)/..)
-build_dir := ${top_dir}/_build
+# Hardocde an FQBN that gets the virtual core here so that when arduino_prop
+# gets called, it picks up the virtual platform compiler settings
-LIB_DIR := ${build_dir}/lib
+export FQBN := keyboardio:virtual:model01
-libcommon_a := ${top_dir}/_build/lib/libcommon.a
+build_dir := ${top_dir}/_build
TEST_PATH ?= .
-export FQBN ?= keyboardio:virtual:model01
-
TESTS := $(shell cd $(tests_dir); find ${TEST_PATH} -name '*.ino' -exec dirname {} \;)
# The clutter up the test output on Make 4.0 and newer
@@ -39,6 +38,12 @@ MAKEFLAGS += --no-print-directory
include $(top_dir)/etc/makefiles/arduino-cli.mk
+
+
+ifneq ($(KALEIDOSCOPE_CCACHE),)
+_compiler_wrappers := -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
+endif
+
.DEFAULT_GOAL := all
# If we start off in tests to run make all, the sketch makefiles guess the wrong location for
@@ -46,7 +51,7 @@ include $(top_dir)/etc/makefiles/arduino-cli.mk
KALEIDOSCOPE_ETC_DIR ?= $(top_dir)/etc
.PHONY: all
-all: ${libcommon_a} googletest run-all
+all: googletest run-all
@:
.PHONY: cmake-clean
@@ -64,7 +69,7 @@ run-other-tests: run-cache-warmer
@$(MAKE) $(filter-out ./_cache-warmer/%,${TESTS})
-${TESTS}: ${libcommon_a} googletest
+${TESTS}: googletest
$(QUIET) { \
$(MAKE) -s -f ${top_dir}/testing/makefiles/testcase.mk -C $@ testcase=$@ build run; \
if [ $$? -ne 0 ]; then \
@@ -119,11 +124,7 @@ ${top_dir}/testing/googletest/build/Makefile:
-B ${top_dir}/testing/googletest/build \
-DCMAKE_C_COMPILER=$(call _arduino_prop,compiler.path)$(call _arduino_prop,compiler.c.cmd) \
-DCMAKE_CXX_COMPILER=$(call _arduino_prop,compiler.path)$(call _arduino_prop,compiler.cpp.cmd) \
- -DCMAKE_C_COMPILER_LAUNCHER=ccache \
- -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-
-${libcommon_a}:
- $(QUIET) ${MAKE} -f ${top_dir}/testing/makefiles/libcommon.mk -C ${top_dir}/testing
+ $(_compiler_wrappers)
Makefile:
@:
diff --git a/tests/examples/basic-keypress-atreus/basic-keypress-atreus.ino b/tests/examples/basic-keypress-atreus/basic-keypress-atreus.ino
new file mode 100644
index 0000000000..4f0f0f4376
--- /dev/null
+++ b/tests/examples/basic-keypress-atreus/basic-keypress-atreus.ino
@@ -0,0 +1,42 @@
+/* -*- mode: c++ -*-
+ * Copyright (C) 2020 Keyboard.io, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#include
+
+// *INDENT-OFF*
+KEYMAPS(
+ [0] = KEYMAP_STACKED(
+ Key_Q ,Key_W ,Key_E ,Key_R ,Key_T
+ ,Key_A ,Key_S ,Key_D ,Key_F ,Key_G
+ ,Key_Z ,Key_X ,Key_C ,Key_V ,Key_B, Key_Backtick
+ ,Key_Esc ,Key_Tab ,Key_LeftGui ,Key_LeftShift ,Key_Backspace ,Key_LeftControl
+
+ ,Key_Y ,Key_U ,Key_I ,Key_O ,Key_P
+ ,Key_H ,Key_J ,Key_K ,Key_L ,Key_Semicolon
+ ,Key_Backslash,Key_N ,Key_M ,Key_Comma ,Key_Period ,Key_Slash
+ ,Key_LeftAlt ,Key_Space ,___ ,Key_Minus ,Key_Quote ,Key_Enter
+
+ )
+)
+// *INDENT-ON*
+
+void setup() {
+ Kaleidoscope.setup();
+}
+
+void loop() {
+ Kaleidoscope.loop();
+}
diff --git a/tests/examples/basic-keypress-atreus/sketch.json b/tests/examples/basic-keypress-atreus/sketch.json
new file mode 100644
index 0000000000..3f645adb8d
--- /dev/null
+++ b/tests/examples/basic-keypress-atreus/sketch.json
@@ -0,0 +1,6 @@
+{
+ "cpu": {
+ "fqbn": "keyboardio:virtual:keyboardio_atreus",
+ "port": ""
+ }
+}
diff --git a/tests/examples/basic-keypress-atreus/sketch.yaml b/tests/examples/basic-keypress-atreus/sketch.yaml
new file mode 100644
index 0000000000..2f7f849321
--- /dev/null
+++ b/tests/examples/basic-keypress-atreus/sketch.yaml
@@ -0,0 +1 @@
+default_fqbn: keyboardio:virtual:keyboardio_atreus
diff --git a/tests/examples/basic-keypress-atreus/test.ktest b/tests/examples/basic-keypress-atreus/test.ktest
new file mode 100644
index 0000000000..a87985c95a
--- /dev/null
+++ b/tests/examples/basic-keypress-atreus/test.ktest
@@ -0,0 +1,34 @@
+VERSION 1
+
+KEYSWITCH A 1 0
+KEYSWITCH S 1 1
+
+# ==============================================================================
+NAME Keys active when pressed
+
+RUN 4 ms
+PRESS A
+RUN 1 cycle
+EXPECT keyboard-report Key_A # Key A should be pressed
+
+RUN 4 ms
+RELEASE A
+RUN 1 cycle
+EXPECT keyboard-report empty # No keys should be pressed
+
+RUN 4 ms
+PRESS A
+PRESS S
+RUN 1 ms
+EXPECT keyboard-report Key_A # Key A should be pressed
+EXPECT keyboard-report Key_A, Key_S # A and S should be pressed
+
+RUN 4 ms
+RELEASE A
+RELEASE S
+RUN 1 cycle
+# A is released first because of scan order
+EXPECT keyboard-report Key_S # Key S should be pressed
+EXPECT keyboard-report empty # No keys should be pressed
+
+RUN 5 ms
diff --git a/tests/features/layers/mod-layer/sketch.yaml b/tests/features/layers/mod-layer/sketch.yaml
index 9902e2986c..4d94810065 100644
--- a/tests/features/layers/mod-layer/sketch.yaml
+++ b/tests/features/layers/mod-layer/sketch.yaml
@@ -1 +1 @@
-default_fqbn: keyboardio:avr:model01
+default_fqbn: keyboardio:virtual:model01
diff --git a/tests/issues/1042/sketch.yaml b/tests/issues/1042/sketch.yaml
index 9902e2986c..4d94810065 100644
--- a/tests/issues/1042/sketch.yaml
+++ b/tests/issues/1042/sketch.yaml
@@ -1 +1 @@
-default_fqbn: keyboardio:avr:model01
+default_fqbn: keyboardio:virtual:model01
diff --git a/tests/issues/980/sketch.yaml b/tests/issues/980/sketch.yaml
new file mode 100644
index 0000000000..4d94810065
--- /dev/null
+++ b/tests/issues/980/sketch.yaml
@@ -0,0 +1 @@
+default_fqbn: keyboardio:virtual:model01