Skip to content

Commit ae33626

Browse files
authored
Cleanup IDB store test code. NFC (emscripten-core#19223)
Add ability to give btests a name other than "test". Use that to create a N different test executables for the N different stages of test_idbstore. This means that after the test runs all the different stages are present in `out/test`: idbstore_0.html idbstore_0.js idbstore_0.wasm* idbstore_1.html idbstore_1.js idbstore_1.wasm* idbstore_2.html idbstore_2.js idbstore_2.wasm* idbstore_3.html idbstore_3.js idbstore_3.wasm* idbstore_4.html idbstore_4.js idbstore_4.wasm* idbstore_5.html idbstore_5.js idbstore_5.wasm* As opposed to only the last one to run.
1 parent bffb81b commit ae33626

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,8 @@ def btest(self, filename, expected=None, reference=None,
19061906
args=None, also_proxied=False,
19071907
url_suffix='', timeout=None, also_wasm2js=False,
19081908
manually_trigger_reftest=False, extra_tries=1,
1909-
reporting=Reporting.FULL):
1909+
reporting=Reporting.FULL,
1910+
output_basename='test'):
19101911
assert expected or reference, 'a btest must either expect an output, or have a reference image'
19111912
if args is None:
19121913
args = []
@@ -1923,7 +1924,7 @@ def btest(self, filename, expected=None, reference=None,
19231924
else:
19241925
# manual_reference only makes sense for reference tests
19251926
assert manual_reference is None
1926-
outfile = 'test.html'
1927+
outfile = output_basename + '.html'
19271928
args += [filename, '-o', outfile]
19281929
# print('all args:', args)
19291930
utils.delete_file(outfile)

test/test_browser.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,6 @@ def test_sdl_stb_image(self):
791791

792792
def test_sdl_stb_image_bpp(self):
793793
# load grayscale image without alpha
794-
self.clear()
795794
shutil.copyfile(test_file('browser/test_sdl-stb-bpp1.png'), 'screenshot.not')
796795
self.btest('browser/test_sdl_stb_image.c', reference='browser/test_sdl-stb-bpp1.png', args=['-sSTB_IMAGE', '--preload-file', 'screenshot.not', '-lSDL', '-lGL'])
797796

@@ -820,7 +819,6 @@ def test_sdl_stb_image_cleanup(self):
820819
self.btest_exit('browser/test_sdl_stb_image_cleanup.c', args=['-sSTB_IMAGE', '--preload-file', 'screenshot.not', '-lSDL', '-lGL', '--memoryprofiler'])
821820

822821
def test_sdl_canvas(self):
823-
self.clear()
824822
self.btest_exit('browser/test_sdl_canvas.c', args=['-sLEGACY_GL_EMULATION', '-lSDL', '-lGL'])
825823
# some extra coverage
826824
self.clear()
@@ -1350,14 +1348,14 @@ def test_fs_idbfs_sync(self):
13501348
self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', '$ccall')
13511349
for extra in [[], ['-DEXTRA_WORK']]:
13521350
secret = str(time.time())
1353-
self.btest(test_file('fs/test_idbfs_sync.c'), '1', args=['-lidbfs.js', '-DFIRST', '-DSECRET=\"' + secret + '\"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-lidbfs.js'])
1354-
self.btest(test_file('fs/test_idbfs_sync.c'), '1', args=['-lidbfs.js', '-DSECRET=\"' + secret + '\"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-lidbfs.js'] + extra)
1351+
self.btest(test_file('fs/test_idbfs_sync.c'), '1', args=['-lidbfs.js', '-DFIRST', f'-DSECRET="{secret}"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-lidbfs.js'])
1352+
self.btest(test_file('fs/test_idbfs_sync.c'), '1', args=['-lidbfs.js', f'-DSECRET="{secret }"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-lidbfs.js'] + extra)
13551353

13561354
def test_fs_idbfs_sync_force_exit(self):
13571355
self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', '$ccall')
13581356
secret = str(time.time())
1359-
self.btest(test_file('fs/test_idbfs_sync.c'), '1', args=['-lidbfs.js', '-DFIRST', '-DSECRET=\"' + secret + '\"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-sEXIT_RUNTIME', '-DFORCE_EXIT', '-lidbfs.js'])
1360-
self.btest(test_file('fs/test_idbfs_sync.c'), '1', args=['-lidbfs.js', '-DSECRET=\"' + secret + '\"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-sEXIT_RUNTIME', '-DFORCE_EXIT', '-lidbfs.js'])
1357+
self.btest(test_file('fs/test_idbfs_sync.c'), '1', args=['-lidbfs.js', '-DFIRST', f'-DSECRET="{secret}"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-sEXIT_RUNTIME', '-DFORCE_EXIT', '-lidbfs.js'])
1358+
self.btest(test_file('fs/test_idbfs_sync.c'), '1', args=['-lidbfs.js', f'-DSECRET="{secret }"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-sEXIT_RUNTIME', '-DFORCE_EXIT', '-lidbfs.js'])
13611359

13621360
def test_fs_idbfs_fsync(self):
13631361
# sync from persisted state into memory before main()
@@ -1377,13 +1375,13 @@ def test_fs_idbfs_fsync(self):
13771375

13781376
args = ['--pre-js', 'pre.js', '-lidbfs.js', '-sEXIT_RUNTIME', '-sASYNCIFY']
13791377
secret = str(time.time())
1380-
self.btest(test_file('fs/test_idbfs_fsync.c'), '1', args=args + ['-DFIRST', '-DSECRET=\"' + secret + '\"', '-sEXPORTED_FUNCTIONS=_main,_success', '-lidbfs.js'])
1381-
self.btest(test_file('fs/test_idbfs_fsync.c'), '1', args=args + ['-DSECRET=\"' + secret + '\"', '-sEXPORTED_FUNCTIONS=_main,_success', '-lidbfs.js'])
1378+
self.btest(test_file('fs/test_idbfs_fsync.c'), '1', args=args + ['-DFIRST', f'-DSECRET="{secret }"', '-sEXPORTED_FUNCTIONS=_main,_success', '-lidbfs.js'])
1379+
self.btest(test_file('fs/test_idbfs_fsync.c'), '1', args=args + [f'-DSECRET="{secret}"', '-sEXPORTED_FUNCTIONS=_main,_success', '-lidbfs.js'])
13821380

13831381
def test_fs_memfs_fsync(self):
13841382
args = ['-sASYNCIFY', '-sEXIT_RUNTIME']
13851383
secret = str(time.time())
1386-
self.btest_exit(test_file('fs/test_memfs_fsync.c'), args=args + ['-DSECRET=\"' + secret + '\"'])
1384+
self.btest_exit(test_file('fs/test_memfs_fsync.c'), args=args + [f'-DSECRET="{secret}"'])
13871385

13881386
def test_fs_workerfs_read(self):
13891387
secret = 'a' * 10
@@ -1400,7 +1398,7 @@ def test_fs_workerfs_read(self):
14001398
}, '/work');
14011399
};
14021400
''' % (secret, secret2))
1403-
self.btest_exit(test_file('fs/test_workerfs_read.c'), args=['-lworkerfs.js', '--pre-js', 'pre.js', '-DSECRET=\"' + secret + '\"', '-DSECRET2=\"' + secret2 + '\"', '--proxy-to-worker', '-lworkerfs.js'])
1401+
self.btest_exit(test_file('fs/test_workerfs_read.c'), args=['-lworkerfs.js', '--pre-js', 'pre.js', f'-DSECRET="{secret }"', f'-DSECRET2="{secret2}"', '--proxy-to-worker', '-lworkerfs.js'])
14041402

14051403
def test_fs_workerfs_package(self):
14061404
self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', '$ccall')
@@ -1479,18 +1477,18 @@ def test_separate_metadata_later(self):
14791477
def test_idbstore(self):
14801478
secret = str(time.time())
14811479
for stage in [0, 1, 2, 3, 0, 1, 2, 0, 0, 1, 4, 2, 5]:
1482-
self.clear()
14831480
print(stage)
1484-
self.btest_exit(test_file('idbstore.c'), args=['-lidbstore.js', '-DSTAGE=' + str(stage), '-DSECRET=\"' + secret + '\"'])
1481+
self.btest_exit(test_file('browser/test_idbstore.c'),
1482+
args=['-lidbstore.js', f'-DSTAGE={stage}', f'-DSECRET="{secret}"'],
1483+
output_basename=f'idbstore_{stage}')
14851484

14861485
def test_idbstore_sync(self):
14871486
secret = str(time.time())
1488-
self.clear()
1489-
self.btest(test_file('idbstore_sync.c'), '6', args=['-lidbstore.js', '-DSECRET=\"' + secret + '\"', '-O3', '-g2', '-sASYNCIFY'])
1487+
self.btest(test_file('browser/test_idbstore_sync.c'), '6', args=['-lidbstore.js', f'-DSECRET="{secret}"', '-O3', '-g2', '-sASYNCIFY'])
14901488

14911489
def test_idbstore_sync_worker(self):
14921490
secret = str(time.time())
1493-
self.btest(test_file('idbstore_sync_worker.c'), expected='0', args=['-lidbstore.js', '-DSECRET=\"' + secret + '\"', '-O3', '-g2', '--proxy-to-worker', '-sINITIAL_MEMORY=80MB', '-sASYNCIFY'])
1491+
self.btest(test_file('browser/test_idbstore_sync_worker.c'), expected='0', args=['-lidbstore.js', f'-DSECRET="{secret}"', '-O3', '-g2', '--proxy-to-worker', '-sINITIAL_MEMORY=80MB', '-sASYNCIFY'])
14941492

14951493
def test_force_exit(self):
14961494
self.btest_exit('force_exit.c', assert_returncode=10)

0 commit comments

Comments
 (0)