summaryrefslogtreecommitdiff
path: root/tmk_core/common/test
diff options
context:
space:
mode:
authorDrashna Jael're <drashna@live.com>2021-12-07 09:27:44 -0800
committerDrashna Jael're <drashna@live.com>2021-12-07 09:27:44 -0800
commit7c18b1c9d3d968ded45e072af3483547c3ec7859 (patch)
treeed7c8a4176033046eacff21228364290b44fcfdb /tmk_core/common/test
parent43002bdf77ab0f48af6b04e87edcc37f7cb7b905 (diff)
parent6d0a62920410f50d7f6707960ca1ca0c8fd1d1fa (diff)
Merge commit '6d0a62920410f50d7f6707960ca1ca0c8fd1d1fa' into firmware21
Diffstat (limited to 'tmk_core/common/test')
-rw-r--r--tmk_core/common/test/_wait.h22
-rw-r--r--tmk_core/common/test/bootloader.c19
-rw-r--r--tmk_core/common/test/eeprom.c95
-rw-r--r--tmk_core/common/test/eeprom_stm32_tests.cpp438
-rw-r--r--tmk_core/common/test/flash_stm32_mock.c49
-rw-r--r--tmk_core/common/test/hal.h18
-rw-r--r--tmk_core/common/test/platform.c21
-rw-r--r--tmk_core/common/test/platform.h18
-rw-r--r--tmk_core/common/test/platform_deps.h18
-rw-r--r--tmk_core/common/test/rules.mk23
-rw-r--r--tmk_core/common/test/suspend.c15
-rw-r--r--tmk_core/common/test/testlist.mk1
-rw-r--r--tmk_core/common/test/timer.c33
13 files changed, 0 insertions, 770 deletions
diff --git a/tmk_core/common/test/_wait.h b/tmk_core/common/test/_wait.h
deleted file mode 100644
index 4e22f593b7..0000000000
--- a/tmk_core/common/test/_wait.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2021 QMK
- *
- * 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, either version 3 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-#pragma once
-
-#include <inttypes.h>
-
-void wait_ms(uint32_t ms);
-#define wait_us(us) wait_ms(us / 1000)
-#define waitInputPinDelay()
diff --git a/tmk_core/common/test/bootloader.c b/tmk_core/common/test/bootloader.c
deleted file mode 100644
index 5155d9ff04..0000000000
--- a/tmk_core/common/test/bootloader.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2017 Fred Sundvik
- *
- * 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, either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "bootloader.h"
-
-void bootloader_jump(void) {}
diff --git a/tmk_core/common/test/eeprom.c b/tmk_core/common/test/eeprom.c
deleted file mode 100644
index 5c8e69dae3..0000000000
--- a/tmk_core/common/test/eeprom.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright 2017 Fred Sundvik
- *
- * 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, either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "eeprom.h"
-
-#define EEPROM_SIZE 32
-
-static uint8_t buffer[EEPROM_SIZE];
-
-uint8_t eeprom_read_byte(const uint8_t *addr) {
- uintptr_t offset = (uintptr_t)addr;
- return buffer[offset];
-}
-
-void eeprom_write_byte(uint8_t *addr, uint8_t value) {
- uintptr_t offset = (uintptr_t)addr;
- buffer[offset] = value;
-}
-
-uint16_t eeprom_read_word(const uint16_t *addr) {
- const uint8_t *p = (const uint8_t *)addr;
- return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8);
-}
-
-uint32_t eeprom_read_dword(const uint32_t *addr) {
- const uint8_t *p = (const uint8_t *)addr;
- return eeprom_read_byte(p) | (eeprom_read_byte(p + 1) << 8) | (eeprom_read_byte(p + 2) << 16) | (eeprom_read_byte(p + 3) << 24);
-}
-
-void eeprom_read_block(void *buf, const void *addr, size_t len) {
- const uint8_t *p = (const uint8_t *)addr;
- uint8_t * dest = (uint8_t *)buf;
- while (len--) {
- *dest++ = eeprom_read_byte(p++);
- }
-}
-
-void eeprom_write_word(uint16_t *addr, uint16_t value) {
- uint8_t *p = (uint8_t *)addr;
- eeprom_write_byte(p++, value);
- eeprom_write_byte(p, value >> 8);
-}
-
-void eeprom_write_dword(uint32_t *addr, uint32_t value) {
- uint8_t *p = (uint8_t *)addr;
- eeprom_write_byte(p++, value);
- eeprom_write_byte(p++, value >> 8);
- eeprom_write_byte(p++, value >> 16);
- eeprom_write_byte(p, value >> 24);
-}
-
-void eeprom_write_block(const void *buf, void *addr, size_t len) {
- uint8_t * p = (uint8_t *)addr;
- const uint8_t *src = (const uint8_t *)buf;
- while (len--) {
- eeprom_write_byte(p++, *src++);
- }
-}
-
-void eeprom_update_byte(uint8_t *addr, uint8_t value) { eeprom_write_byte(addr, value); }
-
-void eeprom_update_word(uint16_t *addr, uint16_t value) {
- uint8_t *p = (uint8_t *)addr;
- eeprom_write_byte(p++, value);
- eeprom_write_byte(p, value >> 8);
-}
-
-void eeprom_update_dword(uint32_t *addr, uint32_t value) {
- uint8_t *p = (uint8_t *)addr;
- eeprom_write_byte(p++, value);
- eeprom_write_byte(p++, value >> 8);
- eeprom_write_byte(p++, value >> 16);
- eeprom_write_byte(p, value >> 24);
-}
-
-void eeprom_update_block(const void *buf, void *addr, size_t len) {
- uint8_t * p = (uint8_t *)addr;
- const uint8_t *src = (const uint8_t *)buf;
- while (len--) {
- eeprom_write_byte(p++, *src++);
- }
-}
diff --git a/tmk_core/common/test/eeprom_stm32_tests.cpp b/tmk_core/common/test/eeprom_stm32_tests.cpp
deleted file mode 100644
index 5bc8d87900..0000000000
--- a/tmk_core/common/test/eeprom_stm32_tests.cpp
+++ /dev/null
@@ -1,438 +0,0 @@
-/* Copyright 2021 by Don Kjer
- *
- * 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, either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "gtest/gtest.h"
-
-extern "C" {
-#include "flash_stm32.h"
-#include "eeprom_stm32.h"
-#include "eeprom.h"
-}
-
-/* Mock Flash Parameters:
- *
- * === Large Layout ===
- * flash size: 65536
- * page size: 2048
- * density pages: 16
- * Simulated EEPROM size: 16384
- *
- * FlashBuf Layout:
- * [Unused | Compact | Write Log ]
- * [0......|32768......|49152......65535]
- *
- * === Tiny Layout ===
- * flash size: 1024
- * page size: 512
- * density pages: 1
- * Simulated EEPROM size: 256
- *
- * FlashBuf Layout:
- * [Unused | Compact | Write Log ]
- * [0......|512......|768......1023]
- *
- */
-
-#define EEPROM_SIZE (FEE_PAGE_SIZE * FEE_PAGE_COUNT / 2)
-#define LOG_SIZE EEPROM_SIZE
-#define LOG_BASE (MOCK_FLASH_SIZE - LOG_SIZE)
-#define EEPROM_BASE (LOG_BASE - EEPROM_SIZE)
-
-/* Log encoding helpers */
-#define BYTE_VALUE(addr, value) (((addr) << 8) | (value))
-#define WORD_ZERO(addr) (0x8000 | ((addr) >> 1))
-#define WORD_ONE(addr) (0xA000 | ((addr) >> 1))
-#define WORD_NEXT(addr) (0xE000 | (((addr)-0x80) >> 1))
-
-class EepromStm32Test : public testing::Test {
- public:
- EepromStm32Test() {}
- ~EepromStm32Test() {}
-
- protected:
- void SetUp() override { EEPROM_Erase(); }
-
- void TearDown() override {
-#ifdef EEPROM_DEBUG
- dumpEepromDataBuf();
-#endif
- }
-};
-
-TEST_F(EepromStm32Test, TestErase) {
- EEPROM_WriteDataByte(0, 0x42);
- EEPROM_Erase();
- EXPECT_EQ(EEPROM_ReadDataByte(0), 0);
- EXPECT_EQ(EEPROM_ReadDataByte(1), 0);
-}
-
-TEST_F(EepromStm32Test, TestReadGarbage) {
- uint8_t garbage = 0x3c;
- for (int i = 0; i < MOCK_FLASH_SIZE; ++i) {
- garbage ^= 0xa3;
- garbage += i;
- FlashBuf[i] = garbage;
- }
- EEPROM_Init(); // Just verify we don't crash
-}
-
-TEST_F(EepromStm32Test, TestWriteBadAddress) {
- EXPECT_EQ(EEPROM_WriteDataByte(EEPROM_SIZE, 0x42), FLASH_BAD_ADDRESS);
- EXPECT_EQ(EEPROM_WriteDataWord(EEPROM_SIZE - 1, 0xbeef), FLASH_BAD_ADDRESS);
- EXPECT_EQ(EEPROM_WriteDataWord(EEPROM_SIZE, 0xbeef), FLASH_BAD_ADDRESS);
-}
-
-TEST_F(EepromStm32Test, TestReadBadAddress) {
- EXPECT_EQ(EEPROM_ReadDataByte(EEPROM_SIZE), 0xFF);
- EXPECT_EQ(EEPROM_ReadDataWord(EEPROM_SIZE - 1), 0xFFFF);
- EXPECT_EQ(EEPROM_ReadDataWord(EEPROM_SIZE), 0xFFFF);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 4)), 0);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 3)), 0xFF000000);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)EEPROM_SIZE), 0xFFFFFFFF);
-}
-
-TEST_F(EepromStm32Test, TestReadByte) {
- /* Direct compacted-area baseline: Address < 0x80 */
- FlashBuf[EEPROM_BASE + 2] = ~0xef;
- FlashBuf[EEPROM_BASE + 3] = ~0xbe;
- /* Direct compacted-area baseline: Address >= 0x80 */
- FlashBuf[EEPROM_BASE + EEPROM_SIZE - 2] = ~0x78;
- FlashBuf[EEPROM_BASE + EEPROM_SIZE - 1] = ~0x56;
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataByte(2), 0xef);
- EXPECT_EQ(EEPROM_ReadDataByte(3), 0xbe);
- EXPECT_EQ(EEPROM_ReadDataByte(EEPROM_SIZE - 2), 0x78);
- EXPECT_EQ(EEPROM_ReadDataByte(EEPROM_SIZE - 1), 0x56);
- /* Write Log byte value */
- FlashBuf[LOG_BASE] = 0x65;
- FlashBuf[LOG_BASE + 1] = 3;
- /* Write Log word value */
- *(uint16_t*)&FlashBuf[LOG_BASE + 2] = WORD_NEXT(EEPROM_SIZE - 2);
- *(uint16_t*)&FlashBuf[LOG_BASE + 4] = ~0x9abc;
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataByte(2), 0xef);
- EXPECT_EQ(EEPROM_ReadDataByte(3), 0x65);
- EXPECT_EQ(EEPROM_ReadDataByte(EEPROM_SIZE - 2), 0xbc);
- EXPECT_EQ(EEPROM_ReadDataByte(EEPROM_SIZE - 1), 0x9a);
-}
-
-TEST_F(EepromStm32Test, TestWriteByte) {
- /* Direct compacted-area baseline: Address < 0x80 */
- EEPROM_WriteDataByte(2, 0xef);
- EEPROM_WriteDataByte(3, 0xbe);
- /* Direct compacted-area baseline: Address >= 0x80 */
- EEPROM_WriteDataByte(EEPROM_SIZE - 2, 0x78);
- EEPROM_WriteDataByte(EEPROM_SIZE - 1, 0x56);
- /* Check values */
- /* First write in each aligned word should have been direct */
- EXPECT_EQ(FlashBuf[EEPROM_BASE + 2], (uint8_t)~0xef);
- EXPECT_EQ(FlashBuf[EEPROM_BASE + EEPROM_SIZE - 2], (uint8_t)~0x78);
-
- /* Second write per aligned word requires a log entry */
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE], BYTE_VALUE(3, 0xbe));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 2], WORD_NEXT(EEPROM_SIZE - 1));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 4], (uint16_t)~0x5678);
-}
-
-TEST_F(EepromStm32Test, TestByteRoundTrip) {
- /* Direct compacted-area: Address < 0x80 */
- EEPROM_WriteDataWord(0, 0xdead);
- EEPROM_WriteDataByte(2, 0xef);
- EEPROM_WriteDataByte(3, 0xbe);
- /* Direct compacted-area: Address >= 0x80 */
- EEPROM_WriteDataByte(EEPROM_SIZE - 2, 0x78);
- EEPROM_WriteDataByte(EEPROM_SIZE - 1, 0x56);
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataByte(0), 0xad);
- EXPECT_EQ(EEPROM_ReadDataByte(1), 0xde);
- EXPECT_EQ(EEPROM_ReadDataByte(2), 0xef);
- EXPECT_EQ(EEPROM_ReadDataByte(3), 0xbe);
- EXPECT_EQ(EEPROM_ReadDataByte(EEPROM_SIZE - 2), 0x78);
- EXPECT_EQ(EEPROM_ReadDataByte(EEPROM_SIZE - 1), 0x56);
- /* Write log entries */
- EEPROM_WriteDataByte(2, 0x80);
- EEPROM_WriteDataByte(EEPROM_SIZE - 2, 0x3c);
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataByte(2), 0x80);
- EXPECT_EQ(EEPROM_ReadDataByte(3), 0xbe);
- EXPECT_EQ(EEPROM_ReadDataByte(EEPROM_SIZE - 2), 0x3c);
- EXPECT_EQ(EEPROM_ReadDataByte(EEPROM_SIZE - 1), 0x56);
-}
-
-TEST_F(EepromStm32Test, TestReadWord) {
- /* Direct compacted-area baseline: Address < 0x80 */
- FlashBuf[EEPROM_BASE + 0] = ~0xad;
- FlashBuf[EEPROM_BASE + 1] = ~0xde;
- /* Direct compacted-area baseline: Address >= 0x80 */
- FlashBuf[EEPROM_BASE + 200] = ~0xcd;
- FlashBuf[EEPROM_BASE + 201] = ~0xab;
- FlashBuf[EEPROM_BASE + EEPROM_SIZE - 4] = ~0x34;
- FlashBuf[EEPROM_BASE + EEPROM_SIZE - 3] = ~0x12;
- FlashBuf[EEPROM_BASE + EEPROM_SIZE - 2] = ~0x78;
- FlashBuf[EEPROM_BASE + EEPROM_SIZE - 1] = ~0x56;
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataWord(0), 0xdead);
- EXPECT_EQ(EEPROM_ReadDataWord(200), 0xabcd);
- EXPECT_EQ(EEPROM_ReadDataWord(EEPROM_SIZE - 4), 0x1234);
- EXPECT_EQ(EEPROM_ReadDataWord(EEPROM_SIZE - 2), 0x5678);
- /* Write Log word zero-encoded */
- *(uint16_t*)&FlashBuf[LOG_BASE] = WORD_ZERO(200);
- /* Write Log word one-encoded */
- *(uint16_t*)&FlashBuf[LOG_BASE + 2] = WORD_ONE(EEPROM_SIZE - 4);
- /* Write Log word value */
- *(uint16_t*)&FlashBuf[LOG_BASE + 4] = WORD_NEXT(EEPROM_SIZE - 2);
- *(uint16_t*)&FlashBuf[LOG_BASE + 6] = ~0x9abc;
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataWord(200), 0);
- EXPECT_EQ(EEPROM_ReadDataWord(EEPROM_SIZE - 4), 1);
- EXPECT_EQ(EEPROM_ReadDataWord(EEPROM_SIZE - 2), 0x9abc);
-}
-
-TEST_F(EepromStm32Test, TestWriteWord) {
- /* Direct compacted-area: Address < 0x80 */
- EEPROM_WriteDataWord(0, 0xdead); // Aligned
- EEPROM_WriteDataWord(3, 0xbeef); // Unaligned
- /* Direct compacted-area: Address >= 0x80 */
- EEPROM_WriteDataWord(200, 0xabcd); // Aligned
- EEPROM_WriteDataWord(203, 0x9876); // Unaligned
- EEPROM_WriteDataWord(EEPROM_SIZE - 4, 0x1234);
- EEPROM_WriteDataWord(EEPROM_SIZE - 2, 0x5678);
- /* Write Log word zero-encoded */
- EEPROM_WriteDataWord(EEPROM_SIZE - 4, 0);
- /* Write Log word one-encoded */
- EEPROM_WriteDataWord(EEPROM_SIZE - 2, 1);
- /* Write Log word value aligned */
- EEPROM_WriteDataWord(200, 0x4321); // Aligned
- /* Write Log word value unaligned */
- EEPROM_WriteDataByte(202, 0x3c); // Set neighboring byte
- EEPROM_WriteDataWord(203, 0xcdef); // Unaligned
- /* Check values */
- /* Direct compacted-area */
- EXPECT_EQ(*(uint16_t*)&FlashBuf[EEPROM_BASE], (uint16_t)~0xdead);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[EEPROM_BASE + 3], (uint16_t)~0xbeef);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[EEPROM_BASE + 200], (uint16_t)~0xabcd);
- EXPECT_EQ(FlashBuf[EEPROM_BASE + 203], (uint8_t)~0x76);
- EXPECT_EQ(FlashBuf[EEPROM_BASE + 204], (uint8_t)~0x98);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[EEPROM_BASE + EEPROM_SIZE - 4], (uint16_t)~0x1234);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[EEPROM_BASE + EEPROM_SIZE - 2], (uint16_t)~0x5678);
- /* Write Log word zero-encoded */
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE], WORD_ZERO(EEPROM_SIZE - 4));
- /* Write Log word one-encoded */
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 2], WORD_ONE(EEPROM_SIZE - 2));
- /* Write Log word value aligned */
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 4], WORD_NEXT(200));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 6], (uint16_t)~0x4321);
- /* Write Log word value unaligned */
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 8], WORD_NEXT(202));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 10], (uint16_t)~0x763c);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 12], WORD_NEXT(202));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 14], (uint16_t)~0xef3c);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 16], WORD_NEXT(204));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 18], (uint16_t)~0x00cd);
-}
-
-TEST_F(EepromStm32Test, TestWordRoundTrip) {
- /* Direct compacted-area: Address < 0x80 */
- EEPROM_WriteDataWord(0, 0xdead); // Aligned
- EEPROM_WriteDataWord(3, 0xbeef); // Unaligned
- /* Direct compacted-area: Address >= 0x80 */
- EEPROM_WriteDataWord(200, 0xabcd); // Aligned
- EEPROM_WriteDataWord(203, 0x9876); // Unaligned
- EEPROM_WriteDataWord(EEPROM_SIZE - 4, 0x1234);
- EEPROM_WriteDataWord(EEPROM_SIZE - 2, 0x5678);
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataWord(0), 0xdead);
- EXPECT_EQ(EEPROM_ReadDataWord(3), 0xbeef);
- EXPECT_EQ(EEPROM_ReadDataWord(200), 0xabcd);
- EXPECT_EQ(EEPROM_ReadDataWord(203), 0x9876);
- EXPECT_EQ(EEPROM_ReadDataWord(EEPROM_SIZE - 4), 0x1234);
- EXPECT_EQ(EEPROM_ReadDataWord(EEPROM_SIZE - 2), 0x5678);
-
- /* Write Log word zero-encoded */
- EEPROM_WriteDataWord(EEPROM_SIZE - 4, 0);
- /* Write Log word one-encoded */
- EEPROM_WriteDataWord(EEPROM_SIZE - 2, 1);
- /* Write Log word value aligned */
- EEPROM_WriteDataWord(200, 0x4321); // Aligned
- /* Write Log word value unaligned */
- EEPROM_WriteDataByte(202, 0x3c); // Set neighboring byte
- EEPROM_WriteDataWord(203, 0xcdef); // Unaligned
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataWord(200), 0x4321);
- EXPECT_EQ(EEPROM_ReadDataByte(202), 0x3c);
- EXPECT_EQ(EEPROM_ReadDataWord(203), 0xcdef);
- EXPECT_EQ(EEPROM_ReadDataWord(EEPROM_SIZE - 4), 0);
- EXPECT_EQ(EEPROM_ReadDataWord(EEPROM_SIZE - 2), 1);
-}
-
-TEST_F(EepromStm32Test, TestByteWordBoundary) {
- /* Direct compacted-area write */
- EEPROM_WriteDataWord(0x7e, 0xdead);
- EEPROM_WriteDataWord(0x80, 0xbeef);
- /* Byte log entry */
- EEPROM_WriteDataByte(0x7f, 0x3c);
- /* Word log entry */
- EEPROM_WriteDataByte(0x80, 0x18);
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataWord(0x7e), 0x3cad);
- EXPECT_EQ(EEPROM_ReadDataWord(0x80), 0xbe18);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE], BYTE_VALUE(0x7f, 0x3c));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 2], WORD_NEXT(0x80));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 4], (uint16_t)~0xbe18);
- /* Byte log entries */
- EEPROM_WriteDataWord(0x7e, 0xcafe);
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataWord(0x7e), 0xcafe);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 6], BYTE_VALUE(0x7e, 0xfe));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 8], BYTE_VALUE(0x7f, 0xca));
- /* Byte and Word log entries */
- EEPROM_WriteDataWord(0x7f, 0xba5e);
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataWord(0x7f), 0xba5e);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 10], BYTE_VALUE(0x7f, 0x5e));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 12], WORD_NEXT(0x80));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 14], (uint16_t)~0xbeba);
- /* Word log entry */
- EEPROM_WriteDataWord(0x80, 0xf00d);
- /* Check values */
- EEPROM_Init();
- EXPECT_EQ(EEPROM_ReadDataWord(0x80), 0xf00d);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 16], WORD_NEXT(0x80));
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + 18], (uint16_t)~0xf00d);
-}
-
-TEST_F(EepromStm32Test, TestDWordRoundTrip) {
- /* Direct compacted-area: Address < 0x80 */
- eeprom_write_dword((uint32_t*)0, 0xdeadbeef); // Aligned
- eeprom_write_dword((uint32_t*)9, 0x12345678); // Unaligned
- /* Direct compacted-area: Address >= 0x80 */
- eeprom_write_dword((uint32_t*)200, 0xfacef00d);
- eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 4), 0xba5eba11); // Aligned
- eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 9), 0xcafed00d); // Unaligned
- /* Check direct values */
- EEPROM_Init();
- EXPECT_EQ(eeprom_read_dword((uint32_t*)0), 0xdeadbeef);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)9), 0x12345678);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)200), 0xfacef00d);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 4)), 0xba5eba11); // Aligned
- EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 9)), 0xcafed00d); // Unaligned
- /* Write Log byte encoded */
- eeprom_write_dword((uint32_t*)0, 0xdecafbad);
- eeprom_write_dword((uint32_t*)9, 0x87654321);
- /* Write Log word encoded */
- eeprom_write_dword((uint32_t*)200, 1);
- /* Write Log word value aligned */
- eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 4), 0xdeadc0de); // Aligned
- eeprom_write_dword((uint32_t*)(EEPROM_SIZE - 9), 0x6789abcd); // Unaligned
- /* Check log values */
- EEPROM_Init();
- EXPECT_EQ(eeprom_read_dword((uint32_t*)0), 0xdecafbad);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)9), 0x87654321);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)200), 1);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 4)), 0xdeadc0de); // Aligned
- EXPECT_EQ(eeprom_read_dword((uint32_t*)(EEPROM_SIZE - 9)), 0x6789abcd); // Unaligned
-}
-
-TEST_F(EepromStm32Test, TestBlockRoundTrip) {
- char src0[] = "0123456789abcdef";
- void* src1 = (void*)&src0[1];
- /* Various alignments of src & dst, Address < 0x80 */
- eeprom_write_block(src0, (void*)0, sizeof(src0));
- eeprom_write_block(src0, (void*)21, sizeof(src0));
- eeprom_write_block(src1, (void*)40, sizeof(src0) - 1);
- eeprom_write_block(src1, (void*)61, sizeof(src0) - 1);
- /* Various alignments of src & dst, Address >= 0x80 */
- eeprom_write_block(src0, (void*)140, sizeof(src0));
- eeprom_write_block(src0, (void*)161, sizeof(src0));
- eeprom_write_block(src1, (void*)180, sizeof(src0) - 1);
- eeprom_write_block(src1, (void*)201, sizeof(src0) - 1);
-
- /* Check values */
- EEPROM_Init();
-
- char dstBuf[256] = {0};
- char* dst0a = (char*)dstBuf;
- char* dst0b = (char*)&dstBuf[20];
- char* dst1a = (char*)&dstBuf[41];
- char* dst1b = (char*)&dstBuf[61];
- char* dst0c = (char*)&dstBuf[80];
- char* dst0d = (char*)&dstBuf[100];
- char* dst1c = (char*)&dstBuf[121];
- char* dst1d = (char*)&dstBuf[141];
- eeprom_read_block((void*)dst0a, (void*)0, sizeof(src0));
- eeprom_read_block((void*)dst0b, (void*)21, sizeof(src0));
- eeprom_read_block((void*)dst1a, (void*)40, sizeof(src0) - 1);
- eeprom_read_block((void*)dst1b, (void*)61, sizeof(src0) - 1);
- eeprom_read_block((void*)dst0c, (void*)140, sizeof(src0));
- eeprom_read_block((void*)dst0d, (void*)161, sizeof(src0));
- eeprom_read_block((void*)dst1c, (void*)180, sizeof(src0) - 1);
- eeprom_read_block((void*)dst1d, (void*)201, sizeof(src0) - 1);
- EXPECT_EQ(strcmp((char*)src0, dst0a), 0);
- EXPECT_EQ(strcmp((char*)src0, dst0b), 0);
- EXPECT_EQ(strcmp((char*)src0, dst0c), 0);
- EXPECT_EQ(strcmp((char*)src0, dst0d), 0);
- EXPECT_EQ(strcmp((char*)src1, dst1a), 0);
- EXPECT_EQ(strcmp((char*)src1, dst1b), 0);
- EXPECT_EQ(strcmp((char*)src1, dst1c), 0);
- EXPECT_EQ(strcmp((char*)src1, dst1d), 0);
-}
-
-TEST_F(EepromStm32Test, TestCompaction) {
- /* Direct writes */
- eeprom_write_dword((uint32_t*)0, 0xdeadbeef);
- eeprom_write_byte((uint8_t*)4, 0x3c);
- eeprom_write_word((uint16_t*)6, 0xd00d);
- eeprom_write_dword((uint32_t*)150, 0xcafef00d);
- eeprom_write_dword((uint32_t*)200, 0x12345678);
- /* Fill write log entries */
- uint32_t i;
- uint32_t val = 0xd8453c6b;
- for (i = 0; i < (LOG_SIZE / (sizeof(uint32_t) * 2)); i++) {
- val ^= 0x593ca5b3;
- val += i;
- eeprom_write_dword((uint32_t*)200, val);
- }
- /* Check values pre-compaction */
- EEPROM_Init();
- EXPECT_EQ(eeprom_read_dword((uint32_t*)0), 0xdeadbeef);
- EXPECT_EQ(eeprom_read_byte((uint8_t*)4), 0x3c);
- EXPECT_EQ(eeprom_read_word((uint16_t*)6), 0xd00d);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)150), 0xcafef00d);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)200), val);
- EXPECT_NE(*(uint16_t*)&FlashBuf[LOG_BASE], 0xFFFF);
- EXPECT_NE(*(uint16_t*)&FlashBuf[LOG_BASE + LOG_SIZE - 2], 0xFFFF);
- /* Run compaction */
- eeprom_write_byte((uint8_t*)4, 0x1f);
- EEPROM_Init();
- EXPECT_EQ(eeprom_read_dword((uint32_t*)0), 0xdeadbeef);
- EXPECT_EQ(eeprom_read_byte((uint8_t*)4), 0x1f);
- EXPECT_EQ(eeprom_read_word((uint16_t*)6), 0xd00d);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)150), 0xcafef00d);
- EXPECT_EQ(eeprom_read_dword((uint32_t*)200), val);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE], 0xFFFF);
- EXPECT_EQ(*(uint16_t*)&FlashBuf[LOG_BASE + LOG_SIZE - 2], 0xFFFF);
-}
diff --git a/tmk_core/common/test/flash_stm32_mock.c b/tmk_core/common/test/flash_stm32_mock.c
deleted file mode 100644
index 222a004bc7..0000000000
--- a/tmk_core/common/test/flash_stm32_mock.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright 2021 by Don Kjer
- *
- * 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, either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-#include <string.h>
-#include <stdbool.h>
-#include "flash_stm32.h"
-
-uint8_t FlashBuf[MOCK_FLASH_SIZE] = {0};
-
-static bool flash_locked = true;
-
-FLASH_Status FLASH_ErasePage(uint32_t Page_Address) {
- if (flash_locked) return FLASH_ERROR_WRP;
- Page_Address -= (uintptr_t)FlashBuf;
- Page_Address -= (Page_Address % FEE_PAGE_SIZE);
- if (Page_Address >= MOCK_FLASH_SIZE) return FLASH_BAD_ADDRESS;
- memset(&FlashBuf[Page_Address], '\xff', FEE_PAGE_SIZE);
- return FLASH_COMPLETE;
-}
-
-FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) {
- if (flash_locked) return FLASH_ERROR_WRP;
- Address -= (uintptr_t)FlashBuf;
- if (Address >= MOCK_FLASH_SIZE) return FLASH_BAD_ADDRESS;
- uint16_t oldData = *(uint16_t*)&FlashBuf[Address];
- if (oldData == 0xFFFF || Data == 0) {
- *(uint16_t*)&FlashBuf[Address] = Data;
- return FLASH_COMPLETE;
- } else {
- return FLASH_ERROR_PG;
- }
-}
-
-FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout) { return FLASH_COMPLETE; }
-void FLASH_Unlock(void) { flash_locked = false; }
-void FLASH_Lock(void) { flash_locked = true; }
diff --git a/tmk_core/common/test/hal.h b/tmk_core/common/test/hal.h
deleted file mode 100644
index 2d268ad54c..0000000000
--- a/tmk_core/common/test/hal.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2021 QMK
- *
- * 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, either version 3 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-#pragma once
-
-// Just here to please eeprom tests
diff --git a/tmk_core/common/test/platform.c b/tmk_core/common/test/platform.c
deleted file mode 100644
index 8ddceeda8f..0000000000
--- a/tmk_core/common/test/platform.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2021 QMK
- *
- * 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, either version 3 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "platform_deps.h"
-
-void platform_setup(void) {
- // do nothing
-} \ No newline at end of file
diff --git a/tmk_core/common/test/platform.h b/tmk_core/common/test/platform.h
deleted file mode 100644
index f296d1d535..0000000000
--- a/tmk_core/common/test/platform.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2021 QMK
- *
- * 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, either version 3 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-#pragma once
-
-// here just to please the build
diff --git a/tmk_core/common/test/platform_deps.h b/tmk_core/common/test/platform_deps.h
deleted file mode 100644
index f296d1d535..0000000000
--- a/tmk_core/common/test/platform_deps.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2021 QMK
- *
- * 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, either version 3 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-#pragma once
-
-// here just to please the build
diff --git a/tmk_core/common/test/rules.mk b/tmk_core/common/test/rules.mk
deleted file mode 100644
index 48632a095b..0000000000
--- a/tmk_core/common/test/rules.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-eeprom_stm32_DEFS := -DFLASH_STM32_MOCKED -DNO_PRINT -DFEE_FLASH_BASE=FlashBuf
-eeprom_stm32_tiny_DEFS := $(eeprom_stm32_DEFS) \
- -DFEE_MCU_FLASH_SIZE=1 \
- -DMOCK_FLASH_SIZE=1024 \
- -DFEE_PAGE_SIZE=512 \
- -DFEE_PAGE_COUNT=1
-eeprom_stm32_large_DEFS := $(eeprom_stm32_DEFS) \
- -DFEE_MCU_FLASH_SIZE=64 \
- -DMOCK_FLASH_SIZE=65536 \
- -DFEE_PAGE_SIZE=2048 \
- -DFEE_PAGE_COUNT=16
-
-eeprom_stm32_INC := \
- $(TMK_PATH)/common/chibios/
-eeprom_stm32_tiny_INC := $(eeprom_stm32_INC)
-eeprom_stm32_large_INC := $(eeprom_stm32_INC)
-
-eeprom_stm32_SRC := \
- $(TMK_PATH)/common/test/eeprom_stm32_tests.cpp \
- $(TMK_PATH)/common/test/flash_stm32_mock.c \
- $(TMK_PATH)/common/chibios/eeprom_stm32.c
-eeprom_stm32_tiny_SRC := $(eeprom_stm32_SRC)
-eeprom_stm32_large_SRC := $(eeprom_stm32_SRC)
diff --git a/tmk_core/common/test/suspend.c b/tmk_core/common/test/suspend.c
deleted file mode 100644
index 76b705967b..0000000000
--- a/tmk_core/common/test/suspend.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Copyright 2017 Fred Sundvik
- *
- * 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, either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
diff --git a/tmk_core/common/test/testlist.mk b/tmk_core/common/test/testlist.mk
deleted file mode 100644
index 51a9638bb9..0000000000
--- a/tmk_core/common/test/testlist.mk
+++ /dev/null
@@ -1 +0,0 @@
-TEST_LIST += eeprom_stm32_tiny eeprom_stm32_large
diff --git a/tmk_core/common/test/timer.c b/tmk_core/common/test/timer.c
deleted file mode 100644
index 61c3a00201..0000000000
--- a/tmk_core/common/test/timer.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2017 Fred Sundvik
- *
- * 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, either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-#include "timer.h"
-
-static uint32_t current_time = 0;
-
-void timer_init(void) { current_time = 0; }
-
-void timer_clear(void) { current_time = 0; }
-
-uint16_t timer_read(void) { return current_time & 0xFFFF; }
-uint32_t timer_read32(void) { return current_time; }
-uint16_t timer_elapsed(uint16_t last) { return TIMER_DIFF_16(timer_read(), last); }
-uint32_t timer_elapsed32(uint32_t last) { return TIMER_DIFF_32(timer_read32(), last); }
-
-void set_time(uint32_t t) { current_time = t; }
-void advance_time(uint32_t ms) { current_time += ms; }
-
-void wait_ms(uint32_t ms) { advance_time(ms); }