aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py60
1 files changed, 54 insertions, 6 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 15f449c6..f96f2f7c 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6337,6 +6337,35 @@ f.close()
Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-L' + os.path.join(self.get_dir(), 'libdir'), '-lfile'], stdout=PIPE, stderr=STDOUT).communicate()
self.assertContained('hello from lib', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+ def test_local_link(self):
+ # Linking a local library directly, like /usr/lib/libsomething.so, cannot work of course since it
+ # doesn't contain bitcode. However, when we see that we should look for a bitcode file for that
+ # library in the -L paths and system/lib
+ open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write('''
+ extern void printey();
+ int main() {
+ printey();
+ return 0;
+ }
+ ''')
+
+ try:
+ os.makedirs(os.path.join(self.get_dir(), 'subdir'));
+ except:
+ pass
+ open(os.path.join(self.get_dir(), 'subdir', 'libfile.so'), 'w').write('this is not llvm bitcode!')
+
+ open(os.path.join(self.get_dir(), 'libfile.cpp'), 'w').write('''
+ #include <stdio.h>
+ void printey() {
+ printf("hello from lib\\n");
+ }
+ ''')
+
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'libfile.cpp'), '-o', 'libfile.so']).communicate()
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), os.path.join(self.get_dir(), 'subdir', 'libfile.so'), '-L.']).communicate()
+ self.assertContained('hello from lib', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
def test_embed_file(self):
open(os.path.join(self.get_dir(), 'somefile.txt'), 'w').write('''hello from a file with lots of data and stuff in it thank you very much''')
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r'''
@@ -6572,8 +6601,8 @@ elif 'browser' in str(sys.argv):
doReftest.done = true;
var img = new Image();
img.onload = function() {
- assert(img.width == Module.canvas.width);
- assert(img.height == Module.canvas.height);
+ assert(img.width == Module.canvas.width, 'Invalid width: ' + Module.canvas.width + ', should be ' + img.width);
+ assert(img.height == Module.canvas.height, 'Invalid height: ' + Module.canvas.height + ', should be ' + img.height);
var canvas = document.createElement('canvas');
canvas.width = img.width;
@@ -6610,8 +6639,10 @@ elif 'browser' in str(sys.argv):
}
img.src = '%s';
};
- Module.postRun = doReftest();
- setTimeout(doReftest, 0); // if run() throws an exception, this will kick in
+ Module.postRun = doReftest;
+ Module.preRun = function() {
+ setTimeout(doReftest, 0); // if run() throws an exception and postRun is not called, this will kick in
+ };
''' % basename)
def test_compression(self):
@@ -6880,17 +6911,34 @@ elif 'browser' in str(sys.argv):
assert os.path.exists('something.html'), output
self.run_browser('something.html', 'You should not see animating gears.', '/report_gl_result?false')
+ def test_glgears_deriv(self):
+ self.reftest(path_from_root('tests', 'gears.png'))
+ output = Popen(['python', EMCC, path_from_root('tests', 'hello_world_gles_deriv.c'), '-o', 'something.html',
+ '-DHAVE_BUILTIN_SINCOS', '--pre-js', 'reftest.js'],
+ stdout=PIPE, stderr=PIPE).communicate()
+ assert len(output[0]) == 0, output[0]
+ assert os.path.exists('something.html'), output
+ self.run_browser('something.html', 'You should see animating gears.', '/report_result?0')
+
def test_glbook(self):
programs = self.get_library('glbook', [
os.path.join('Chapter_2', 'Hello_Triangle', 'CH02_HelloTriangle.bc'),
os.path.join('Chapter_8', 'Simple_VertexShader', 'CH08_SimpleVertexShader.bc'),
os.path.join('Chapter_9', 'Simple_Texture2D', 'CH09_SimpleTexture2D.bc'),
os.path.join('Chapter_9', 'Simple_TextureCubemap', 'CH09_TextureCubemap.bc'),
+ os.path.join('Chapter_9', 'TextureWrap', 'CH09_TextureWrap.bc'),
+ os.path.join('Chapter_10', 'MultiTexture', 'CH10_MultiTexture.bc'),
], configure=None)
for program in programs:
print program
- self.reftest(path_from_root('tests', 'glbook', os.path.basename(program).replace('.bc', '.png')))
- Popen(['python', EMCC, program, '-o', 'program.html', '--pre-js', 'reftest.js']).communicate()
+ basename = os.path.basename(program)
+ args = []
+ if basename == 'CH10_MultiTexture.bc':
+ shutil.copyfile(path_from_root('tests', 'glbook', 'Chapter_10', 'MultiTexture', 'basemap.tga'), os.path.join(self.get_dir(), 'basemap.tga'))
+ shutil.copyfile(path_from_root('tests', 'glbook', 'Chapter_10', 'MultiTexture', 'lightmap.tga'), os.path.join(self.get_dir(), 'lightmap.tga'))
+ args = ['--preload-file', 'basemap.tga', '--preload-file', 'lightmap.tga']
+ self.reftest(path_from_root('tests', 'glbook', basename.replace('.bc', '.png')))
+ Popen(['python', EMCC, program, '-o', 'program.html', '--pre-js', 'reftest.js'] + args).communicate()
self.run_browser('program.html', '', '/report_result?0')
elif 'benchmark' in str(sys.argv):