@@ -7037,43 +7037,40 @@ def test_no_filesystem_libcxx(self):
70377037 self.set_setting('FILESYSTEM', 0)
70387038 self.do_runf('hello_libcxx.cpp', 'hello, world!')
70397039
7040- @is_slow_test
7041- def test_no_nuthin(self):
7042- # check FILESYSTEM is automatically set, and effective
7043-
7044- def test(opts, absolute):
7045- print('opts, absolute:', opts, absolute)
7046- sizes = {}
7040+ # Verifies that filesystem is automatically omitted, and can be
7041+ # manually disabled too, and both improve code size.
7042+ @parameterized({
7043+ 'no_assertions': (['-sASSERTIONS=0'], 120000),
7044+ 'o1': (['-O1'], 91000),
7045+ 'o2': (['-O2'], 46000),
7046+ 'o3_closure': (['-O3', '--closure=1'], 17000),
7047+ # -Wno-closure is needed due to https://github.com/google/closure-compiler/issues/4108
7048+ 'o3_closure_js': (['-O3', '--closure=1', '-Wno-closure', '-sWASM=0'], 36000),
7049+ 'o3_closure2_js': (['-O3', '--closure=2', '-Wno-closure', '-sWASM=0'], 33000), # might change now and then
7050+ })
7051+ def test_no_filesystem_code_size(self, opts, absolute):
7052+ print('opts, absolute:', opts, absolute)
7053+ sizes = {}
70477054
7048- def do(name, source, moar_opts):
7049- self.clear()
7050- # pad the name to a common length so that doesn't effect the size of the
7051- # output
7052- padded_name = name + '_' * (20 - len(name))
7053- self.run_process([EMCC, test_file(source), '-o', padded_name + '.js'] + self.get_cflags() + opts + moar_opts)
7054- sizes[name] = os.path.getsize(padded_name + '.js')
7055- if os.path.exists(padded_name + '.wasm'):
7056- sizes[name] += os.path.getsize(padded_name + '.wasm')
7057- self.assertContained('hello, world!', self.run_js(padded_name + '.js'))
7058-
7059- do('normal', 'hello_world_fopen.c', [])
7060- do('no_fs', 'hello_world.c', []) # without fopen, we should auto-detect we do not need full fs support and can do FILESYSTEM=0
7061- do('no_fs_manual', 'hello_world.c', ['-sFILESYSTEM=0'])
7062- print(' ', sizes)
7063- self.assertLess(sizes['no_fs'], sizes['normal'])
7064- self.assertLess(sizes['no_fs'], absolute)
7065- # manual can usually remove a tiny bit more
7066- self.assertLess(sizes['no_fs_manual'], sizes['no_fs'] + 30)
7067-
7068- test(['-sASSERTIONS=0'], 120000) # we don't care about code size with assertions
7069- test(['-O1'], 91000)
7070- test(['-O2'], 46000)
7071- test(['-O3', '--closure=1'], 17000)
7072- # js too
7073- # -Wclosure is needed due to
7074- # https://github.com/google/closure-compiler/issues/4108
7075- test(['-O3', '--closure=1', '-Wno-closure', '-sWASM=0'], 36000)
7076- test(['-O3', '--closure=2', '-Wno-closure', '-sWASM=0'], 33000) # might change now and then
7055+ def do(name, source, moar_opts):
7056+ self.clear()
7057+ # pad the name to a common length so that doesn't effect the size of the
7058+ # output
7059+ padded_name = name + '_' * (20 - len(name))
7060+ self.run_process([EMCC, test_file(source), '-o', padded_name + '.js'] + self.get_cflags() + opts + moar_opts)
7061+ sizes[name] = os.path.getsize(padded_name + '.js')
7062+ if os.path.exists(padded_name + '.wasm'):
7063+ sizes[name] += os.path.getsize(padded_name + '.wasm')
7064+ self.assertContained('hello, world!', self.run_js(padded_name + '.js'))
7065+
7066+ do('normal', 'hello_world_fopen.c', [])
7067+ do('no_fs', 'hello_world.c', []) # without fopen, we should auto-detect we do not need full fs support and can do FILESYSTEM=0
7068+ do('no_fs_manual', 'hello_world.c', ['-sFILESYSTEM=0'])
7069+ print(' ', sizes)
7070+ self.assertLess(sizes['no_fs'], sizes['normal'])
7071+ self.assertLess(sizes['no_fs'], absolute)
7072+ # manual can usually remove a tiny bit more
7073+ self.assertLess(sizes['no_fs_manual'], sizes['no_fs'] + 30)
70777074
70787075 def test_no_main_loop(self):
70797076 MAINLOOP = 'var MainLoop'
0 commit comments