From e824f6df73aabf7c1ada38a44ababa6d0674bb0b Mon Sep 17 00:00:00 2001 From: Loic Coenen Date: Fri, 8 May 2026 20:03:49 +0000 Subject: [PATCH] feat: add test for dynamic channel creation via MIDI command Co-authored-by: aider (deepseek/deepseek-reasoner) --- tests/integration.c | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/integration.c b/tests/integration.c index 73a4b50..aebece8 100644 --- a/tests/integration.c +++ b/tests/integration.c @@ -366,6 +366,52 @@ static int test_looper_looping(void) { return 0; } +/* test multiple channels */ +static int test_multiple_channels(void) { + printf("Test: dynamic channel creation via MIDI command\n"); + pid_t pid = start_looper(); + if (pid < 0) return 1; + + jack_client_t *client; + jack_status_t status; + client = jack_client_open("test_multi", JackNoStartServer, &status); + if (!client) { + kill(pid, SIGTERM); waitpid(pid, NULL, 0); + fprintf(stderr, " SKIP: no JACK\n"); + return 1; + } + + if (send_jack_note_on("looper:control", 60, 127) != 0) { + jack_client_close(client); + kill(pid, SIGTERM); waitpid(pid, NULL, 0); + fprintf(stderr, " FAIL: send note 60 failed\n"); + return 1; + } + usleep(500000); + + int found = 0; + const char **ports = jack_get_ports(client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0); + if (ports) { + for (int i = 0; ports[i]; i++) { + if (strstr(ports[i], "looper:channel1_input")) { + found = 1; + break; + } + } + jack_free(ports); + } + jack_client_close(client); + kill(pid, SIGTERM); + waitpid(pid, NULL, 0); + + if (!found) { + fprintf(stderr, " FAIL: channel1_input port not created after add command\n"); + return 1; + } + printf(" PASS (channel created)\n"); + return 0; +} + int main(void) { /* 1. binary must exist */ @@ -385,6 +431,12 @@ int main(void) { return 1; } + /* 5. Test multiple dynamic channels */ + if (test_multiple_channels() != 0) { + fprintf(stderr, " FAILED\n"); + return 1; + } + printf("All tests completed successfully.\n"); return 0; }