From 5c9286af850f9a3335d294c7c2e100104741b296 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 31 Jan 2026 18:15:01 +0100 Subject: add testing for sequence --- HOWTO.md | 6 ++++-- src/generated/timeline.cc | 30 +++++++++++++++++++++--------- src/gpu/gpu.h | 32 ++++++++++++++++++++++++++++---- tools/spectool.cc | 10 ++++++---- 4 files changed, 59 insertions(+), 19 deletions(-) diff --git a/HOWTO.md b/HOWTO.md index afb8459..df41829 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -83,16 +83,18 @@ If you are on macOS and want to test the Windows build: Note: WebGPU support in Wine requires a Vulkan-capable backend (like MoltenVK on macOS). Note2: make sure you run the script `./scripts/fetch_win_deps.sh` before, to install Win64 dependencies. -## Testing +### Testing **Commit Policy**: Always run tests before committing. Refer to `CONTRIBUTING.md` for details. -To build and run the tests, you need to enable the `DEMO_BUILD_TESTS` option in CMake. +To build and run the tests, you need to enable the `DEMO_BUILD_TESTS` option in CMake. Refer to the "Developer Build (All Options)" section for the easiest way to enable this. Available test suites: * `HammingWindowTest`: Verifies the properties of the Hamming window function. +* `MathUtilsTest`: Verifies basic math utilities. * `SynthEngineTest`: Verifies the core functionality of the audio synthesizer. * `SpectoolEndToEndTest`: Performs an end-to-end test of the `spectool` by generating a WAV file, analyzing it, and verifying the output. +* `SequenceSystemTest`: Tests the logic of the sequence and effect system (activation, timing, priority), but **not** actual GPU rendering output, as this requires extensive mocking. ```bash cmake -S . -B build -DDEMO_BUILD_TESTS=ON diff --git a/src/generated/timeline.cc b/src/generated/timeline.cc index c7aad2f..2e060fb 100644 --- a/src/generated/timeline.cc +++ b/src/generated/timeline.cc @@ -2,21 +2,33 @@ #include "gpu/demo_effects.h" #include "gpu/effect.h" -void LoadTimeline(MainSequence& main_seq, WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format) { +void LoadTimeline(MainSequence &main_seq, WGPUDevice device, WGPUQueue queue, + WGPUTextureFormat format) { { auto seq = std::make_shared(); - seq->add_effect(std::make_shared(device, queue, format), 0.0f, 1000.0f, 0); - seq->add_effect(std::make_shared(device, queue, format), 0.0f, 1000.0f, 1); - seq->add_effect(std::make_shared(device, queue, format), 0.0f, 1000.0f, 2); - seq->add_effect(std::make_shared(device, queue, format), 0.0f, 1000.0f, 3); + seq->add_effect(std::make_shared(device, queue, format), + 0.0f, 1000.0f, 0); + seq->add_effect( + std::make_shared(device, queue, format), 0.0f, + 1000.0f, 1); + seq->add_effect(std::make_shared(device, queue, format), + 0.0f, 1000.0f, 2); + seq->add_effect( + std::make_shared(device, queue, format), 0.0f, + 1000.0f, 3); main_seq.add_sequence(seq, 0.0f, 0); } { auto seq = std::make_shared(); - seq->add_effect(std::make_shared(device, queue, format), 5.0f, 10.0f, 0); - seq->add_effect(std::make_shared(device, queue, format), 10.0f, 15.0f, 0); - seq->add_effect(std::make_shared(device, queue, format), 15.0f, 20.0f, 0); - seq->add_effect(std::make_shared(device, queue, format), 20.0f, 25.0f, 0); + seq->add_effect(std::make_shared(device, queue, format), + 5.0f, 10.0f, 0); + seq->add_effect(std::make_shared(device, queue, format), + 10.0f, 15.0f, 0); + seq->add_effect(std::make_shared(device, queue, format), + 15.0f, 20.0f, 0); + seq->add_effect( + std::make_shared(device, queue, format), 20.0f, + 25.0f, 0); main_seq.add_sequence(seq, 0.0f, 1); } } diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h index 8aa290a..ce233fa 100644 --- a/src/gpu/gpu.h +++ b/src/gpu/gpu.h @@ -9,37 +9,61 @@ #include // For strlen #if defined(DEMO_CROSS_COMPILE_WIN32) + // Windows (MinGW) using wgpu-native v0.19.4.1 -#include -#include + +#include // Reverted to angle brackets + +#include // Reverted to angle brackets + using WGPUStringView = const char *; + static inline const char *str_view(const char *str) { return str; } + static inline const char *label_view(const char *str) { return str; } + #define WGPUSType_ShaderSourceWGSL WGPUSType_ShaderModuleWGSLDescriptor + using WGPUShaderSourceWGSL = WGPUShaderModuleWGSLDescriptor; + #else + // Native (macOS/Linux) using newer wgpu-native -#include -#include + +#include // Reverted to angle brackets + +#include // Reverted to angle brackets + static inline WGPUStringView str_view(const char *str) { + if (!str) return {nullptr, 0}; + return {str, strlen(str)}; } + static inline WGPUStringView label_view(const char *str) { + #ifndef STRIP_ALL + if (!str) return {nullptr, 0}; + return {str, strlen(str)}; + #else + (void)str; + return {nullptr, 0}; + #endif } + #endif struct GLFWwindow; diff --git a/tools/spectool.cc b/tools/spectool.cc index 663056d..97c5997 100644 --- a/tools/spectool.cc +++ b/tools/spectool.cc @@ -214,12 +214,14 @@ int test_gen(const char *out_path) { void print_usage() { printf("Usage: spectool [output]\n"); printf("Commands:\n"); - printf(" analyze Analyze an audio file and " - "save as a spectrogram.\n"); + printf( + " analyze Analyze an audio file and " + "save as a spectrogram.\n"); printf( " play Play a spectrogram file.\n"); - printf(" test_gen Generate a test " - "spectrogram.\n"); + printf( + " test_gen Generate a test " + "spectrogram.\n"); } int main(int argc, char **argv) { -- cgit v1.2.3