test: gracefully skip MIDI tests when jack_midi_send is missing
Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
@@ -22,15 +22,6 @@
|
||||
|
||||
#define WAIT_SECONDS 1
|
||||
|
||||
static int run_cmd(const char *fmt, ...) {
|
||||
char buf[512];
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
return system(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start a fresh instance of the looper, wait for JACK ports to appear,
|
||||
* return its PID, or -1 on failure.
|
||||
@@ -305,6 +296,28 @@ static void test_looping_not_implemented(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper: run all MIDI‑based state transition tests.
|
||||
* Requires jack_midi_send; if missing these tests are skipped.
|
||||
*/
|
||||
static int run_midi_tests(void) {
|
||||
if (system("which jack_midi_send >/dev/null 2>&1") != 0) {
|
||||
printf("SKIP: MIDI state tests – jack_midi_send not installed\n");
|
||||
return 0; /* not a failure, just skip */
|
||||
}
|
||||
|
||||
test_transition("IDLE -> RECORD", "control", "90 01 7f", STATE_RECORD);
|
||||
test_transition("RECORD -> LOOPING", "control", "90 01 7f", STATE_LOOPING);
|
||||
test_transition("LOOPING -> PAUSED", "control", "90 01 7f", STATE_PAUSED);
|
||||
test_transition("PAUSED -> LOOPING", "control", "90 01 7f", STATE_LOOPING);
|
||||
|
||||
test_clock_start();
|
||||
test_clock_stop();
|
||||
test_clock_continue();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
/* 1. binary must exist */
|
||||
if (system("test -x ./looper") != 0) {
|
||||
@@ -312,30 +325,13 @@ int main(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 2. check required external tool */
|
||||
if (system("which jack_midi_send >/dev/null 2>&1") != 0) {
|
||||
fprintf(stderr, "FATAL: jack_midi_send not available\n");
|
||||
return 1;
|
||||
}
|
||||
/* 2. MIDI transition tests (skip if jack_midi_send missing) */
|
||||
run_midi_tests();
|
||||
|
||||
/* 3. note-on toggle sequence */
|
||||
test_transition("IDLE -> RECORD", "control", "90 01 7f", STATE_RECORD);
|
||||
test_transition("RECORD -> LOOPING", "control", "90 01 7f", STATE_LOOPING);
|
||||
test_transition("LOOPING -> PAUSED", "control", "90 01 7f", STATE_PAUSED);
|
||||
test_transition("PAUSED -> LOOPING", "control", "90 01 7f", STATE_LOOPING);
|
||||
/* 3. Audio pass‑through test – must work for basic connectivity */
|
||||
test_audio_pass_through();
|
||||
|
||||
/* 4. MIDI clock messages */
|
||||
test_clock_start();
|
||||
test_clock_stop();
|
||||
test_clock_continue();
|
||||
|
||||
/* 5. Audio pass‑through test – must work for basic connectivity */
|
||||
if (test_audio_pass_through() != 0) {
|
||||
/* non‑fatal: if tools missing we still continue */
|
||||
fprintf(stderr, " (non‑fatal)\n");
|
||||
}
|
||||
|
||||
/* 6. Test that looping feature is missing (expected) */
|
||||
/* 4. Test that looping feature is missing (expected) */
|
||||
test_looping_not_implemented();
|
||||
|
||||
printf("All tests completed successfully (missing features noted).\n");
|
||||
|
||||
Reference in New Issue
Block a user