Skip to content

Commit a310c8d

Browse files
committed
pbio/platform/sim_hub: Don't modify stdin on CI.
This caused a lot of headaches when the MicroPython test suite runs many instances at the same time.
1 parent 73e6a36 commit a310c8d

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

lib/pbio/drv/bluetooth/bluetooth_simulation.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ pbio_error_t pbdrv_bluetooth_controller_initialize(pbio_os_state_t *state, pbio_
129129
#define STDIN_HEADER_SIZE (1)
130130

131131
static void pbdrv_bluetooth_simulation_tick_handler() {
132+
#ifdef PBDRV_CONFIG_RUN_ON_CI
133+
// CI and MicroPython test suite have lots of problems with stdin. It is
134+
// only needed for the REPL and interactive input, so don't bother on CI.
135+
return;
136+
#endif
137+
132138
uint8_t buf[256 + STDIN_HEADER_SIZE];
133139

134140
// This has been made non-blocking in platform.c.

lib/pbio/platform/sim_hub/platform.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ const pbdrv_motor_driver_virtual_simulation_platform_data_t
139139
},
140140
};
141141

142+
// The 'embedded' main.
143+
extern void _main(void);
144+
142145
int main(int argc, char **argv) {
143146

144147
// Parse given program, else otherwise default to REPL.
@@ -165,6 +168,13 @@ int main(int argc, char **argv) {
165168
}
166169
}
167170

171+
#ifdef PBDRV_CONFIG_RUN_ON_CI
172+
// On the CI modifying settings for stdin causes problems. The REPL isn't
173+
// used on CI anyway.
174+
_main();
175+
return 0;
176+
#endif
177+
168178
// Save the original terminal settings
169179
struct termios term_old, term_new;
170180
if (tcgetattr(STDIN_FILENO, &term_old) != 0) {
@@ -197,8 +207,7 @@ int main(int argc, char **argv) {
197207
return 0;
198208
}
199209

200-
// Runs the 'embedded' main.
201-
extern void _main(void);
210+
// Simulate running embedded main.
202211
_main();
203212

204213
// Restore stdin flags.

test-virtualhub.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ PB_TEST_DIR=$"$SCRIPT_DIR/tests"
1818
BUILD_DIR="$BRICK_DIR/build${COVERAGE:+-coverage}"
1919
PBIO_DIR="$SCRIPT_DIR/lib/pbio"
2020

21-
make -s -j $(nproc --all) -C "$BRICK_DIR"
21+
make -s -j $(nproc --all) -C "$BRICK_DIR" COPT=-DPBDRV_CONFIG_RUN_ON_CI
2222

2323
export MICROPY_MICROPYTHON="$BUILD_DIR/firmware.elf"
2424

0 commit comments

Comments
 (0)