This PR addresses #12367 (cc @vadimkantorov @junjihashimoto @sbc100):

*    Use vadimkantorov's patch to library_proxyfs.js (thanks!)
*    To prevent this from happening in the future, I added an additional test to make
     sure we can get the correct file size of a file mounted on a PROXYFS filesystem

Tests

The additional tests calculates the file size of the file /working2/hoge.txt, which is 6 bytes, but currently returns 0. Note: working2/ is the folder that mounts the filesystem of module 2.

Before the patch:

$ tests/runner --verbose other.test_proxyfs
[...]
parent m0 writes and reads children's files.:m0 read m0:test0_0
test seek.:file size:0

After the patch:

$ tests/runner --verbose other.test_proxyfs
[...]
parent m0 writes and reads children's files.:m0 read m0:test0_0
test seek.:file size:6
This commit is contained in:
Robert Aboukhalil 2021-07-21 15:01:49 -07:00 коммит произвёл GitHub
Родитель b5c978ce47
Коммит 6519ea5845
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -199,7 +199,7 @@ mergeInto(LibraryManager.library, {
} else if (whence === {{{ cDefine('SEEK_END') }}}) {
if (FS.isFile(stream.node.mode)) {
try {
var stat = stream.node.mount.opts.fs.fstat(stream.nfd);
var stat = stream.node.node_ops.getattr(stream.node);
position += stat.size;
} catch (e) {
throw new FS.ErrnoError(ERRNO_CODES[e.code]);

18
tests/test_other.py поставляемый
Просмотреть файл

@ -2871,6 +2871,10 @@ print("m2 read");
m2.ccall('myread0','number',[],[]);
print("m0 read m0");
m0.ccall('myread0','number',[],[]);
section = "test seek.";
print("file size");
m0.ccall('myreadSeekEnd', 'number', [], []);
''')
create_file('proxyfs_pre.js', r'''
@ -2969,6 +2973,18 @@ EMSCRIPTEN_KEEPALIVE int myreade() {
fclose(in);
return 0;
}
EMSCRIPTEN_KEEPALIVE int myreadSeekEnd() {
FILE* in = fopen("/working2/hoge.txt","r");
fseek(in, 0L, SEEK_END);
int fileSize = ftell(in);
fseek(in, 0L, SEEK_SET);
printf("%d\n", fileSize);
fclose(in);
return 0;
}
''')
self.run_process([EMCC,
@ -3012,6 +3028,8 @@ EMSCRIPTEN_KEEPALIVE int myreade() {
self.assertContained(section + ":m1 read:test1", out)
self.assertContained(section + ":m2 read:test2", out)
self.assertContained(section + ":m0 read m0:test0_0", out)
section = "test seek."
self.assertContained(section + ":file size:6", out)
def test_dependency_file(self):
# Issue 1732: -MMD (and friends) create dependency files that need to be