Skip to content

Commit 03e7b25

Browse files
committed
Rolled back tests to use tmpnam(), in order to pass CI tests.
1 parent c05b996 commit 03e7b25

File tree

3 files changed

+51
-75
lines changed

3 files changed

+51
-75
lines changed

.github/workflows/ccpp.yml

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ jobs:
2323
run: make
2424
- name: make check
2525
run: make check
26-
- name: cat test log
27-
run: cat ./test-suite.log
2826
- name: make distcheck
2927
run: make distcheck
3028
- name: configure no fftw

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ addons:
1717
- libcunit1-dev
1818

1919
script:
20-
./bootstrap && ./configure && make clean all check dist distcheck; cat ./test-suite.log
20+
./bootstrap && ./configure && make clean all check dist distcheck

test/src/lingot-test-io-config.c

+50-72
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232

3333
#include <memory.h>
3434
#include <locale.h>
35-
#include <stdlib.h>
36-
#include <unistd.h>
3735

3836
#ifndef LINGOT_TEST_RESOURCES_PATH
3937
#define LINGOT_TEST_RESOURCES_PATH "test/"
@@ -75,13 +73,6 @@ static void check_last_configs(const lingot_config_t* config) {
7573

7674
void lingot_test_io_config(void) {
7775

78-
lingot_io_config_create_parameter_specs();
79-
lingot_config_t _config;
80-
lingot_config_t* config = &_config;
81-
lingot_config_new(config);
82-
83-
CU_ASSERT_PTR_NOT_NULL_FATAL(config);
84-
8576
// check if the files are there
8677
const char* filename = LINGOT_TEST_RESOURCES_PATH "resources/lingot-001.conf";
8778

@@ -93,88 +84,79 @@ void lingot_test_io_config(void) {
9384
return; // we allow the test resources to be not present for the distcheck.
9485
}
9586

87+
lingot_io_config_create_parameter_specs();
88+
lingot_config_t _config;
89+
lingot_config_t* config = &_config;
90+
lingot_config_new(config);
91+
92+
CU_ASSERT_PTR_NOT_NULL_FATAL(config);
93+
9694
// old file with obsolete options
9795
// ------------------------------
9896

9997
int ok;
10098
ok = lingot_io_config_load(config, LINGOT_TEST_RESOURCES_PATH "resources/lingot-001.conf");
99+
CU_ASSERT(ok);
101100

102-
if (ok) { // TODO: assert
103-
104-
CU_ASSERT_EQUAL(config->audio_system_index, lingot_audio_system_find_by_name("PulseAudio"));
105-
CU_ASSERT(!strcmp(config->audio_dev[config->audio_system_index],
106-
"alsa_input.pci-0000_00_1b.0.analog-stereo"));
107-
CU_ASSERT_EQUAL(config->sample_rate, 44100);
108-
CU_ASSERT_EQUAL(config->root_frequency_error, 0.0);
109-
CU_ASSERT_EQUAL(config->sample_rate, 44100);
110-
CU_ASSERT_EQUAL(config->fft_size, 512);
111-
CU_ASSERT_EQUAL(config->min_overall_SNR, 20.0);
112-
CU_ASSERT_EQUAL(config->calculation_rate, 20.0);
113-
} else {
114-
fprintf(stderr, "warning: cannot find unit test resources\n");
115-
}
101+
CU_ASSERT_EQUAL(config->audio_system_index, lingot_audio_system_find_by_name("PulseAudio"));
102+
CU_ASSERT(!strcmp(config->audio_dev[config->audio_system_index],
103+
"alsa_input.pci-0000_00_1b.0.analog-stereo"));
104+
CU_ASSERT_EQUAL(config->sample_rate, 44100);
105+
CU_ASSERT_EQUAL(config->root_frequency_error, 0.0);
106+
CU_ASSERT_EQUAL(config->sample_rate, 44100);
107+
CU_ASSERT_EQUAL(config->fft_size, 512);
108+
CU_ASSERT_EQUAL(config->min_overall_SNR, 20.0);
109+
CU_ASSERT_EQUAL(config->calculation_rate, 20.0);
116110

117111
// recent file
118112
// -----------
119113

120114
ok = lingot_io_config_load(config, LINGOT_TEST_RESOURCES_PATH "resources/lingot-0_9_2b8.conf");
121-
if (ok) { // TODO: assert
115+
CU_ASSERT(ok);
122116

123117
#ifdef PULSEAUDIO
124-
CU_ASSERT_EQUAL(config->audio_system_index, lingot_audio_system_find_by_name("PulseAudio"));
125-
CU_ASSERT(!strcmp(config->audio_dev[config->audio_system_index], "default"));
118+
CU_ASSERT_EQUAL(config->audio_system_index, lingot_audio_system_find_by_name("PulseAudio"));
119+
CU_ASSERT(!strcmp(config->audio_dev[config->audio_system_index], "default"));
126120
#endif
127-
CU_ASSERT_EQUAL(config->sample_rate, 44100);
128-
CU_ASSERT_EQUAL(config->root_frequency_error, 0.0);
129-
CU_ASSERT_EQUAL(config->fft_size, 512);
130-
CU_ASSERT_EQUAL(config->sample_rate, 44100);
131-
CU_ASSERT_EQUAL(config->temporal_window, 0.3);
132-
CU_ASSERT_EQUAL(config->min_overall_SNR, 20.0);
133-
CU_ASSERT_EQUAL(config->calculation_rate, 15.0);
134-
CU_ASSERT_EQUAL(config->min_frequency, 82.41);
135-
CU_ASSERT_EQUAL(config->max_frequency, 329.63);
136-
137-
CU_ASSERT(!strcmp(config->scale.name, "Default equal-tempered scale"));
138-
CU_ASSERT_EQUAL(config->scale.notes, 12);
139-
CU_ASSERT_EQUAL(config->scale.base_frequency, 261.625565);
140-
CU_ASSERT(!strcmp(config->scale.note_name[1], "C#"));
141-
CU_ASSERT(!strcmp(config->scale.note_name[11], "B"));
142-
143-
CU_ASSERT_EQUAL(config->scale.offset_ratios[0][0], 1);
144-
CU_ASSERT_EQUAL(config->scale.offset_ratios[1][0], 1); // defined as ratio
145-
CU_ASSERT_EQUAL(config->scale.offset_cents[0], 0.0);
146-
147-
CU_ASSERT_EQUAL(config->scale.offset_ratios[0][1], -1);
148-
CU_ASSERT_EQUAL(config->scale.offset_ratios[1][1], -1); // not defined as ratio
149-
CU_ASSERT_EQUAL(config->scale.offset_cents[1], 100.0); // defined as shift in cents
150-
151-
CU_ASSERT_EQUAL(config->scale.offset_ratios[0][11], -1);
152-
CU_ASSERT_EQUAL(config->scale.offset_ratios[1][11], -1); // not defined as ratio
153-
CU_ASSERT_EQUAL(config->scale.offset_cents[11], 1100.0); // defined as shift in cents
154-
} else {
155-
fprintf(stderr, "warning: cannot find unit test resources\n");
156-
}
121+
CU_ASSERT_EQUAL(config->sample_rate, 44100);
122+
CU_ASSERT_EQUAL(config->root_frequency_error, 0.0);
123+
CU_ASSERT_EQUAL(config->fft_size, 512);
124+
CU_ASSERT_EQUAL(config->sample_rate, 44100);
125+
CU_ASSERT_EQUAL(config->temporal_window, 0.3);
126+
CU_ASSERT_EQUAL(config->min_overall_SNR, 20.0);
127+
CU_ASSERT_EQUAL(config->calculation_rate, 15.0);
128+
CU_ASSERT_EQUAL(config->min_frequency, 82.41);
129+
CU_ASSERT_EQUAL(config->max_frequency, 329.63);
130+
131+
CU_ASSERT(!strcmp(config->scale.name, "Default equal-tempered scale"));
132+
CU_ASSERT_EQUAL(config->scale.notes, 12);
133+
CU_ASSERT_EQUAL(config->scale.base_frequency, 261.625565);
134+
CU_ASSERT(!strcmp(config->scale.note_name[1], "C#"));
135+
CU_ASSERT(!strcmp(config->scale.note_name[11], "B"));
136+
137+
CU_ASSERT_EQUAL(config->scale.offset_ratios[0][0], 1);
138+
CU_ASSERT_EQUAL(config->scale.offset_ratios[1][0], 1); // defined as ratio
139+
CU_ASSERT_EQUAL(config->scale.offset_cents[0], 0.0);
140+
141+
CU_ASSERT_EQUAL(config->scale.offset_ratios[0][1], -1);
142+
CU_ASSERT_EQUAL(config->scale.offset_ratios[1][1], -1); // not defined as ratio
143+
CU_ASSERT_EQUAL(config->scale.offset_cents[1], 100.0); // defined as shift in cents
144+
145+
CU_ASSERT_EQUAL(config->scale.offset_ratios[0][11], -1);
146+
CU_ASSERT_EQUAL(config->scale.offset_ratios[1][11], -1); // not defined as ratio
147+
CU_ASSERT_EQUAL(config->scale.offset_cents[11], 1100.0); // defined as shift in cents
157148

158149
// -----------
159150

160151
ok = lingot_io_config_load(config, LINGOT_TEST_RESOURCES_PATH "resources/lingot-1_0_2b.conf");
161-
162152
CU_ASSERT(ok);
163153

164154
check_last_configs(config);
165155

166156
// we check that we can save and load it again
167-
char temp_filename[32];
168-
strncpy(temp_filename,"/tmp/lingot-XXXXXX", sizeof(temp_filename));
169-
170-
int temp_file_id = mkstemps(temp_filename, 6);
171-
CU_ASSERT(temp_file_id >= 0);
172-
ok = close(temp_file_id);
173-
174-
CU_ASSERT(!ok);
175-
ok = lingot_io_config_save(config, filename);
176-
CU_ASSERT(ok != -1);
177157

158+
filename = tmpnam(NULL);
159+
lingot_io_config_save(config, filename);
178160
ok = lingot_io_config_load(config, filename);
179161
CU_ASSERT(ok);
180162
check_last_configs(config);
@@ -192,11 +174,7 @@ void lingot_test_io_config(void) {
192174

193175
// we check that we can save and load it again
194176

195-
temp_file_id = mkstemps(temp_filename, 6);
196-
CU_ASSERT(temp_file_id >= 0);
197-
ok = close(temp_file_id);
198-
199-
CU_ASSERT(!ok);
177+
filename = tmpnam(NULL);
200178
lingot_io_config_save(config, filename);
201179
ok = lingot_io_config_load(config, filename);
202180
CU_ASSERT(ok);

0 commit comments

Comments
 (0)