Skip to content

Commit 4179cca

Browse files
test,android: set stdout and stderr line buffered
Sets stdout and stderr as line buffered in the android test application. This reduces flakyness of tests caused by adb logcat output adding additional newlines.
1 parent e4ac4b6 commit 4179cca

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/mobile-test/android/testnode/app/src/main/cpp/native-lib.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@ void* thread_stdout_func(void*) {
136136
}
137137

138138
int start_redirecting_stdout_stderr() {
139-
// Set stdout as unbuffered.
140-
setvbuf(stdout, 0, _IONBF, 0);
139+
// Set stdout as line buffered.
140+
// Avoids additional line breaks caused by adb logcat splitting the output.
141+
setvbuf(stdout, 0, _IOLBF, 0);
141142
pipe(pipe_stdout);
142143
dup2(pipe_stdout[1], STDOUT_FILENO);
143144

144-
// Set stderr as unbuffered.
145-
setvbuf(stderr, 0, _IONBF, 0);
145+
// Set stderr as line buffered.
146+
// Avoids additional line breaks caused by adb logcat splitting the output.
147+
setvbuf(stderr, 0, _IOLBF, 0);
146148
pipe(pipe_stderr);
147149
dup2(pipe_stderr[1], STDERR_FILENO);
148150

0 commit comments

Comments
 (0)