aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cubegeom.c6
-rwxr-xr-xtests/fuzz/creduce_tester.py53
-rwxr-xr-xtests/fuzz/csmith_driver.py36
-rw-r--r--tests/glbook/CH13_ParticleSystem.pngbin5106 -> 4921 bytes
-rwxr-xr-xtests/runner.py87
-rw-r--r--tests/websockets.c5
6 files changed, 160 insertions, 27 deletions
diff --git a/tests/cubegeom.c b/tests/cubegeom.c
index 6158b124..787b8373 100644
--- a/tests/cubegeom.c
+++ b/tests/cubegeom.c
@@ -45,6 +45,8 @@ void verify() {
int main(int argc, char *argv[])
{
+ int temp; // testing
+
SDL_Surface *screen;
if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) {
printf("Unable to initialize SDL: %s\n", SDL_GetError());
@@ -124,7 +126,9 @@ int main(int argc, char *argv[])
glActiveTexture(GL_TEXTURE0);
+ glGetBooleanv(GL_VERTEX_ARRAY, &temp); assert(!temp);
glEnableClientState(GL_VERTEX_ARRAY);
+ glGetBooleanv(GL_VERTEX_ARRAY, &temp); assert(temp);
GLuint arrayBuffer, elementBuffer;
glGenBuffers(1, &arrayBuffer);
@@ -207,7 +211,6 @@ int main(int argc, char *argv[])
glNormalPointer(GL_BYTE, 32, (void*)12);
glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28);
- int temp; // test glGetPointerv, glGetIntegerv
glGetPointerv(GL_VERTEX_ARRAY_POINTER, &temp); assert(temp == 0);
glGetPointerv(GL_COLOR_ARRAY_POINTER, &temp); assert(temp == 28);
glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &temp); assert(temp == 16);
@@ -220,6 +223,7 @@ int main(int argc, char *argv[])
glGetIntegerv(GL_TEXTURE_COORD_ARRAY_SIZE, &temp); assert(temp == 2);
glGetIntegerv(GL_TEXTURE_COORD_ARRAY_TYPE, &temp); assert(temp == GL_FLOAT);
glGetIntegerv(GL_TEXTURE_COORD_ARRAY_STRIDE, &temp); assert(temp == 32);
+ glGetBooleanv(GL_VERTEX_ARRAY, &temp); assert(temp);
glBindTexture(GL_TEXTURE_2D, texture); // diffuse?
glActiveTexture(GL_TEXTURE0);
diff --git a/tests/fuzz/creduce_tester.py b/tests/fuzz/creduce_tester.py
new file mode 100755
index 00000000..c3460e9d
--- /dev/null
+++ b/tests/fuzz/creduce_tester.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+
+'''
+Runs csmith, a C fuzzer, and looks for bugs
+'''
+
+import os, sys, difflib
+from subprocess import Popen, PIPE, STDOUT
+
+sys.path += [os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'tools')]
+import shared
+
+filename = sys.argv[1]
+print 'testing file', filename
+
+print '2) Compile natively'
+shared.try_delete(filename)
+shared.execute([shared.CLANG_CC, '-O2', filename + '.c', '-o', filename] + CSMITH_CFLAGS, stderr=PIPE)
+assert os.path.exists(filename)
+print '3) Run natively'
+try:
+ correct = shared.timeout_run(Popen([filename], stdout=PIPE, stderr=PIPE), 3)
+except Exception, e:
+ print 'Failed or infinite looping in native, skipping', e
+ notes['invalid'] += 1
+ os.exit(0) # boring
+
+print '4) Compile JS-ly and compare'
+
+def try_js(args):
+ shared.try_delete(filename + '.js')
+ shared.execute([shared.EMCC, '-O2', '-s', 'ASM_JS=1', '-s', 'PRECISE_I64_MATH=1', '-s', 'PRECISE_I32_MUL=1', filename + '.c', '-o', filename + '.js'] + CSMITH_CFLAGS + args, stderr=PIPE)
+ assert os.path.exists(filename + '.js')
+ js = shared.run_js(filename + '.js', stderr=PIPE, engine=engine1)
+ assert correct == js, ''.join([a.rstrip()+'\n' for a in difflib.unified_diff(correct.split('\n'), js.split('\n'), fromfile='expected', tofile='actual')])
+
+# Try normally, then try unaligned because csmith does generate nonportable code that requires x86 alignment
+ok = False
+normal = True
+for args, note in [([], None), (['-s', 'UNALIGNED_MEMORY=1'], 'unaligned')]:
+ try:
+ try_js(args)
+ ok = True
+ if note:
+ notes[note] += 1
+ break
+ except Exception, e:
+ print e
+ normal = False
+if not ok: sys.exit(1)
+
+sys.exit(0) # boring
+
diff --git a/tests/fuzz/csmith_driver.py b/tests/fuzz/csmith_driver.py
index b893436a..1cb85451 100755
--- a/tests/fuzz/csmith_driver.py
+++ b/tests/fuzz/csmith_driver.py
@@ -10,22 +10,27 @@ from subprocess import Popen, PIPE, STDOUT
sys.path += [os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'tools')]
import shared
+engine1 = eval('shared.' + sys.argv[1]) if len(sys.argv) > 1 else shared.JS_ENGINES[0]
+engine2 = eval('shared.' + sys.argv[2]) if len(sys.argv) > 2 else None
+
+print 'testing js engines', engine1, engine2
+
CSMITH = os.path.expanduser('~/Dev/csmith/src/csmith')
CSMITH_CFLAGS = ['-I' + os.path.expanduser('~/Dev/csmith/runtime/')]
filename = os.path.join(shared.CANONICAL_TEMP_DIR, 'fuzzcode')
-shared.DEFAULT_TIMEOUT = 3
+shared.DEFAULT_TIMEOUT = 1
tried = 0
-notes = { 'invalid': 0, 'unaligned': 0 }
+notes = { 'invalid': 0, 'unaligned': 0, 'embug': 0 }
while 1:
print 'Tried %d, notes: %s' % (tried, notes)
tried += 1
print '1) Generate C'
- shared.execute([CSMITH, '--no-volatiles', '--no-math64', '--max-block-depth', '2', '--max-block-size', '2', '--max-expr-complexity', '2', '--max-funcs', '2'], stdout=open(filename + '.c', 'w'))
+ shared.execute([CSMITH, '--no-volatiles', '--no-math64'], stdout=open(filename + '.c', 'w'))
print '2) Compile natively'
shared.try_delete(filename)
@@ -45,11 +50,12 @@ while 1:
shared.try_delete(filename + '.js')
shared.execute([shared.EMCC, '-O2', '-s', 'ASM_JS=1', '-s', 'PRECISE_I64_MATH=1', '-s', 'PRECISE_I32_MUL=1', filename + '.c', '-o', filename + '.js'] + CSMITH_CFLAGS + args, stderr=PIPE)
assert os.path.exists(filename + '.js')
- js = shared.run_js(filename + '.js', stderr=PIPE) #, engine=...)
+ js = shared.run_js(filename + '.js', stderr=PIPE, engine=engine1, check_timeout=True)
assert correct == js, ''.join([a.rstrip()+'\n' for a in difflib.unified_diff(correct.split('\n'), js.split('\n'), fromfile='expected', tofile='actual')])
# Try normally, then try unaligned because csmith does generate nonportable code that requires x86 alignment
ok = False
+ normal = True
for args, note in [([], None), (['-s', 'UNALIGNED_MEMORY=1'], 'unaligned')]:
try:
try_js(args)
@@ -59,7 +65,11 @@ while 1:
break
except Exception, e:
print e
- if not ok: break
+ normal = False
+ if not ok:
+ print "EMSCRIPTEN BUG"
+ notes['embug'] += 1
+ continue #break
#if not ok:
# try: # finally, try with safe heap. if that is triggered, this is nonportable code almost certainly
# try_js(['-s', 'SAFE_HEAP=1'])
@@ -72,3 +82,19 @@ while 1:
# else:
# break
+ # This is ok. Try in secondary JS engine too
+ if engine2 and normal:
+ try:
+ js2 = shared.run_js(filename + '.js', stderr=PIPE, engine=engine2, full_output=True, check_timeout=True)
+ except:
+ print 'failed to run in secondary', js2
+ break
+
+ # asm.js testing
+ assert 'warning: Successfully compiled asm.js code' in js2, 'must validate'
+ js2 = js2.replace('\nwarning: Successfully compiled asm.js code\n', '')
+
+ assert js2 == correct, ''.join([a.rstrip()+'\n' for a in difflib.unified_diff(correct.split('\n'), js2.split('\n'), fromfile='expected', tofile='actual')]) + 'ODIN FAIL'
+ print 'odin ok'
+
+
diff --git a/tests/glbook/CH13_ParticleSystem.png b/tests/glbook/CH13_ParticleSystem.png
index ff9c3496..4b69414f 100644
--- a/tests/glbook/CH13_ParticleSystem.png
+++ b/tests/glbook/CH13_ParticleSystem.png
Binary files differ
diff --git a/tests/runner.py b/tests/runner.py
index 8410f888..9cf40543 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -507,6 +507,8 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows
'''
self.do_run(src, 'hello, world!')
+ assert 'EMSCRIPTEN_GENERATED_FUNCTIONS' not in open(self.in_dir('src.cpp.o.js')).read(), 'must not emit this unneeded internal thing'
+
def test_intvars(self):
if self.emcc_args == None: return self.skip('needs ta2')
@@ -1153,6 +1155,8 @@ m_divisor is 1091269979
self.do_run(src, '3217489085')
def test_i32_mul_semiprecise(self):
+ if Settings.ASM_JS: return self.skip('asm is always fully precise')
+
Settings.PRECISE_I32_MUL = 0 # we want semiprecise here
src = r'''
@@ -2802,6 +2806,37 @@ Exiting setjmp function, level: 0, prev_jmp: -1
''' % addr
self.do_run(src, 'segmentation fault' if addr.isdigit() else 'marfoosh')
+ def test_safe_dyncalls(self):
+ if Settings.ASM_JS: return self.skip('asm does not support missing function stack traces')
+ if Settings.SAFE_HEAP: return self.skip('safe heap warning will appear instead')
+ if self.emcc_args is None: return self.skip('need libc')
+
+ Settings.SAFE_DYNCALLS = 1
+
+ for cond, body, work in [(True, True, False), (True, False, False), (False, True, True), (False, False, False)]:
+ print cond, body, work
+ src = r'''
+ #include <stdio.h>
+
+ struct Classey {
+ virtual void doIt() = 0;
+ };
+
+ struct D1 : Classey {
+ virtual void doIt() BODY;
+ };
+
+ int main(int argc, char **argv)
+ {
+ Classey *p = argc COND 100 ? new D1() : NULL;
+ printf("%p\n", p);
+ p->doIt();
+
+ return 0;
+ }
+ '''.replace('COND', '==' if cond else '!=').replace('BODY', r'{ printf("all good\n"); }' if body else '')
+ self.do_run(src, 'dyncall error: vi' if not work else 'all good')
+
def test_dynamic_cast(self):
if self.emcc_args is None: return self.skip('need libcxxabi')
@@ -7130,6 +7165,14 @@ def process(filename):
self.assertIdentical(clean(open('release.js').read()), clean(open('debug%d.js' % debug).read())) # EMCC_DEBUG=1 mode must not generate different code!
print >> sys.stderr, 'debug check %d passed too' % debug
+ try:
+ os.environ['EMCC_FORCE_STDLIBS'] = '1'
+ print 'EMCC_FORCE_STDLIBS'
+ do_test()
+ finally:
+ del os.environ['EMCC_FORCE_STDLIBS']
+ print >> sys.stderr, 'EMCC_FORCE_STDLIBS ok'
+
try_delete(CANONICAL_TEMP_DIR)
else:
print >> sys.stderr, 'not doing debug check'
@@ -9436,8 +9479,8 @@ f.close()
try:
os.environ['EMCC_DEBUG'] = '1'
for asm, linkable, chunks, js_chunks in [
- (0, 0, 3, 2), (0, 1, 7, 4),
- (1, 0, 3, 2), (1, 1, 7, 5)
+ (0, 0, 2, 2), (0, 1, 4, 4),
+ (1, 0, 2, 2), (1, 1, 4, 5)
]:
print asm, linkable, chunks, js_chunks
output, err = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_libcxx.cpp'), '-O1', '-s', 'LINKABLE=%d' % linkable, '-s', 'ASM_JS=%d' % asm], stdout=PIPE, stderr=PIPE).communicate()
@@ -10329,56 +10372,56 @@ elif 'browser' in str(sys.argv):
# SDL, OpenGL, textures, immediate mode. Closure for more coverage
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.reftest(path_from_root('tests', 'screenshot-gray-purple.png'))
- Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_ogl.c'), '-O2', '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
+ Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_ogl.c'), '-O2', '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate()
self.run_browser('something.html', 'You should see an image with gray at the top.', '/report_result?0')
def test_sdl_ogl_defaultmatrixmode(self):
# SDL, OpenGL, textures, immediate mode. Closure for more coverage
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.reftest(path_from_root('tests', 'screenshot-gray-purple.png'))
- Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_ogl_defaultMatrixMode.c'), '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
+ Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_ogl_defaultMatrixMode.c'), '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate()
self.run_browser('something.html', 'You should see an image with gray at the top.', '/report_result?0')
def test_sdl_ogl_p(self):
# Immediate mode with pointers
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.reftest(path_from_root('tests', 'screenshot-gray.png'))
- Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_ogl_p.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
+ Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_ogl_p.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate()
self.run_browser('something.html', 'You should see an image with gray at the top.', '/report_result?0')
def test_sdl_fog_simple(self):
# SDL, OpenGL, textures, fog, immediate mode. Closure for more coverage
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.reftest(path_from_root('tests', 'screenshot-fog-simple.png'))
- Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_simple.c'), '-O2', '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
+ Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_simple.c'), '-O2', '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate()
self.run_browser('something.html', 'You should see an image with fog.', '/report_result?0')
def test_sdl_fog_negative(self):
# SDL, OpenGL, textures, fog, immediate mode. Closure for more coverage
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.reftest(path_from_root('tests', 'screenshot-fog-negative.png'))
- Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_negative.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
+ Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_negative.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate()
self.run_browser('something.html', 'You should see an image with fog.', '/report_result?0')
def test_sdl_fog_density(self):
# SDL, OpenGL, textures, fog, immediate mode. Closure for more coverage
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.reftest(path_from_root('tests', 'screenshot-fog-density.png'))
- Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_density.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
+ Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_density.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate()
self.run_browser('something.html', 'You should see an image with fog.', '/report_result?0')
def test_sdl_fog_exp2(self):
# SDL, OpenGL, textures, fog, immediate mode. Closure for more coverage
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.reftest(path_from_root('tests', 'screenshot-fog-exp2.png'))
- Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_exp2.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
+ Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_exp2.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate()
self.run_browser('something.html', 'You should see an image with fog.', '/report_result?0')
def test_sdl_fog_linear(self):
# SDL, OpenGL, textures, fog, immediate mode. Closure for more coverage
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
self.reftest(path_from_root('tests', 'screenshot-fog-linear.png'))
- Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_linear.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
+ Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_linear.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate()
self.run_browser('something.html', 'You should see an image with fog.', '/report_result?0')
def test_worker(self):
@@ -10477,7 +10520,6 @@ elif 'browser' in str(sys.argv):
def chunked_server(support_byte_ranges):
class ChunkedServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
- @staticmethod
def sendheaders(s, extra=[], length=len(data)):
s.send_response(200)
s.send_header("Content-Length", str(length))
@@ -10491,11 +10533,14 @@ elif 'browser' in str(sys.argv):
s.end_headers()
def do_HEAD(s):
- ChunkedServerHandler.sendheaders(s)
-
+ s.sendheaders()
+
+ def do_OPTIONS(s):
+ s.sendheaders([("Access-Control-Allow-Headers", "Range")], 0)
+
def do_GET(s):
if not support_byte_ranges:
- ChunkedServerHandler.sendheaders(s)
+ s.sendheaders()
s.wfile.write(data)
else:
(start, end) = s.headers.get("range").split("=")[1].split("-")
@@ -10503,7 +10548,7 @@ elif 'browser' in str(sys.argv):
end = int(end)
end = min(len(data)-1, end)
length = end-start+1
- ChunkedServerHandler.sendheaders(s,[],length)
+ s.sendheaders([],length)
s.wfile.write(data[start:end+1])
s.wfile.close()
httpd = BaseHTTPServer.HTTPServer(('localhost', 11111), ChunkedServerHandler)
@@ -10518,26 +10563,26 @@ elif 'browser' in str(sys.argv):
def test_glgears(self):
self.reftest(path_from_root('tests', 'gears.png'))
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles.c'), '-o', 'something.html',
- '-DHAVE_BUILTIN_SINCOS', '--pre-js', 'reftest.js']).communicate()
+ '-DHAVE_BUILTIN_SINCOS', '--pre-js', 'reftest.js', '-s', 'GL_TESTING=1']).communicate()
self.run_browser('something.html', 'You should see animating gears.', '/report_result?0')
def test_glgears_animation(self):
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles.c'), '-o', 'something.html',
- '-DHAVE_BUILTIN_SINCOS',
+ '-DHAVE_BUILTIN_SINCOS', '-s', 'GL_TESTING=1',
'--shell-file', path_from_root('tests', 'hello_world_gles_shell.html')]).communicate()
self.run_browser('something.html', 'You should see animating gears.', '/report_gl_result?true')
def test_glgears_bad(self):
# Make sure that OpenGL ES is not available if typed arrays are not used
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles.c'), '-o', 'something.html',
- '-DHAVE_BUILTIN_SINCOS',
+ '-DHAVE_BUILTIN_SINCOS', '-s', 'GL_TESTING=1',
'-s', 'USE_TYPED_ARRAYS=0',
'--shell-file', path_from_root('tests', 'hello_world_gles_shell.html')]).communicate()
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'))
- Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles_deriv.c'), '-o', 'something.html',
+ Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles_deriv.c'), '-o', 'something.html', '-s', 'GL_TESTING=1',
'-DHAVE_BUILTIN_SINCOS', '--pre-js', 'reftest.js']).communicate()
self.run_browser('something.html', 'You should see animating gears.', '/report_result?0')
src = open('something.html').read()
@@ -10568,7 +10613,7 @@ elif 'browser' in str(sys.argv):
args = ['--preload-file', 'smoke.tga', '-O2'] # test optimizations and closure here as well for more coverage
self.reftest(book_path(basename.replace('.bc', '.png')))
- Popen([PYTHON, EMCC, program, '-o', 'program.html', '--pre-js', 'reftest.js'] + args).communicate()
+ Popen([PYTHON, EMCC, program, '-o', 'program.html', '--pre-js', 'reftest.js', '-s', 'GL_TESTING=1'] + args).communicate()
self.run_browser('program.html', '', '/report_result?0')
def btest(self, filename, expected=None, reference=None, reference_slack=0, args=[]): # TODO: use in all other tests
@@ -10583,7 +10628,7 @@ elif 'browser' in str(sys.argv):
expected = [str(i) for i in range(0, reference_slack+1)]
shutil.copyfile(path_from_root('tests', filename), os.path.join(self.get_dir(), filename))
self.reftest(path_from_root('tests', reference))
- args = args + ['--pre-js', 'reftest.js']
+ args = args + ['--pre-js', 'reftest.js', '-s', 'GL_TESTING=1']
Popen([PYTHON, EMCC, os.path.join(self.get_dir(), filename), '-o', 'test.html'] + args).communicate()
if type(expected) is str: expected = [expected]
self.run_browser('test.html', '.', ['/report_result?' + e for e in expected])
diff --git a/tests/websockets.c b/tests/websockets.c
index 34aa44b4..8e719baa 100644
--- a/tests/websockets.c
+++ b/tests/websockets.c
@@ -27,14 +27,19 @@ unsigned int get_all_buf(int sock, char* output, unsigned int maxsize)
assert(select(64, &sett, NULL, NULL, NULL) == 0); // empty set
FD_SET(sock, &sett);
assert(select(0, &sett, NULL, NULL, NULL) == 0); // max FD to check is 0
+ assert(FD_ISSET(sock, &sett) == 0);
+ FD_SET(sock, &sett);
int select_says_yes = select(64, &sett, NULL, NULL, NULL);
// ioctl check for IO
int bytes;
if (ioctl(sock, FIONREAD, &bytes) || bytes == 0) {
not_always_data = 1;
+ assert(FD_ISSET(sock, &sett) == 0);
return 0;
}
+
+ assert(FD_ISSET(sock, &sett));
assert(select_says_yes); // ioctl must agree with select
char buffer[1024];