Skip to content

Revert "Handle failure of lseek in fflush" #23644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions system/lib/libc/musl/src/stdio/fflush.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,11 @@ int fflush(FILE *f)
}

/* If reading, sync position, per POSIX */
#if __EMSCRIPTEN__
/* Handle failues of lseek, which can happen in emscripten, e.g. for stdin etc */
if (f->rpos != f->rend) {
if (f->seek(f, f->rpos-f->rend, SEEK_CUR) == 0) {
/* Clear read and write modes */
f->wpos = f->wbase = f->wend = 0;
f->rpos = f->rend = 0;
}
}
#else
if (f->rpos != f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR);

/* Clear read and write modes */
f->wpos = f->wbase = f->wend = 0;
f->rpos = f->rend = 0;
#endif

FUNLOCK(f);
return 0;
Expand Down
14 changes: 7 additions & 7 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,8 +1493,7 @@ def cleanup(line):

def run_js(self, filename, engine=None, args=None,
assert_returncode=0,
interleaved_output=True,
**kwargs):
interleaved_output=True):
# use files, as PIPE can get too full and hang us
stdout_file = self.in_dir('stdout')
stderr_file = None
Expand All @@ -1516,8 +1515,7 @@ def run_js(self, filename, engine=None, args=None,
jsrun.run_js(filename, engine, args,
stdout=stdout,
stderr=stderr,
assert_returncode=assert_returncode,
**kwargs)
assert_returncode=assert_returncode)
except subprocess.TimeoutExpired as e:
timeout_error = e
except subprocess.CalledProcessError as e:
Expand Down Expand Up @@ -1940,9 +1938,9 @@ def _build_and_run(self, filename, expected_output, args=None,
includes=None,
assert_returncode=0, assert_identical=False, assert_all=False,
check_for_error=True, force_c=False, emcc_args=None,
interleaved_output=True,
regex=False,
output_basename=None,
**kwargs):
output_basename=None):
logger.debug(f'_build_and_run: {filename}')

if no_build:
Expand All @@ -1966,7 +1964,9 @@ def _build_and_run(self, filename, expected_output, args=None,
if len(engines) == 0:
self.fail('No JS engine present to run this test with. Check %s and the paths therein.' % config.EM_CONFIG)
for engine in engines:
js_output = self.run_js(js_file, engine, args, assert_returncode=assert_returncode, **kwargs)
js_output = self.run_js(js_file, engine, args,
assert_returncode=assert_returncode,
interleaved_output=interleaved_output)
js_output = js_output.replace('\r\n', '\n')
if expected_output:
if type(expected_output) not in [list, tuple]:
Expand Down
5 changes: 2 additions & 3 deletions test/jsrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def require_engine(engine):
def run_js(filename, engine, args=None,
stdin=None, stdout=PIPE, stderr=None, cwd=None,
full_output=False, assert_returncode=0, skip_check=False,
timeout=DEFAULT_TIMEOUT, **kwargs):
timeout=DEFAULT_TIMEOUT):
"""Execute javascript code generated by tests, with possible timeout."""

# We used to support True here but we no longer do. Assert here just in case.
Expand All @@ -96,7 +96,6 @@ def run_js(filename, engine, args=None,
raise Exception('output file not found: ' + filename)

command = make_command(os.path.abspath(filename), engine, args)
kwargs.setdefault('text', True)
if common.EMTEST_VERBOSE:
print(f"Running: '{shared.shlex_join(command)}'")
try:
Expand All @@ -107,7 +106,7 @@ def run_js(filename, engine, args=None,
stderr=stderr,
cwd=cwd,
timeout=timeout,
**kwargs)
universal_newlines=True)
except Exception:
# the failure may be because the engine is not present. show the proper
# error in that case
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
129147
129141
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
128559
128553
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
170815
170809
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
144523
144517
Original file line number Diff line number Diff line change
@@ -1 +1 @@
142098
142092
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_lto.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
122099
122093
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_mangle.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
232625
232619
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_noexcept.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
131710
131704
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_wasmfs.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
169117
169111
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_wasmfs.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
50055
50049
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O0.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15105
15101
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_O0.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1160
1156
17 changes: 0 additions & 17 deletions test/other/test_stdin_fflush.c

This file was deleted.

6 changes: 0 additions & 6 deletions test/other/test_stdin_fflush.out

This file was deleted.

2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size.wasm.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15105
15101
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_strict.wasm.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15105
15101
5 changes: 0 additions & 5 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,11 +1730,6 @@ def test_module_stdin(self):
self.emcc_args += ['--pre-js', 'pre.js']
self.do_runf('module/test_stdin.c', 'hello, world!')

@crossplatform
def test_stdin_fflush(self):
# Force text=False here so that newlines are not treated differently on windows.
self.do_other_test('test_stdin_fflush.c', input=b'foo\nbar\n', text=False)

@crossplatform
def test_module_stdout_stderr(self):
self.set_setting('FORCE_FILESYSTEM')
Expand Down