feat: add test for dynamic channel creation via MIDI command
Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user