MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / test_deterministic

Method test_deterministic

test/test_other.py:12241–12264  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

12239
12240 @crossplatform
12241 def test_deterministic(self):
12242 # test some things that may not be nondeterministic
12243 create_file('src.c', r'''
12244#include <emscripten.h>
12245#include <stdio.h>
12246#include <stdlib.h>
12247#include <time.h>
12248
12249int main () {
12250 struct timespec now;
12251 clock_gettime(CLOCK_REALTIME, &now);
12252 printf("C now: %lld %ld\n", now.tv_sec, now.tv_nsec);
12253 printf("js now: %f\n", emscripten_get_now());
12254 printf("C randoms: %d %d %d\n", rand(), rand(), rand());
12255 printf("JS random: %d\n", EM_ASM_INT({ return Math.random() }));
12256}
12257''&#x27;)
12258 self.run_process([EMCC, 'src.c', '--pre-js', path_from_root('src/deterministic.js')] + self.get_cflags())
12259 one = self.run_js('a.out.js')
12260 # ensure even if the time resolution is 1 second, that if we see the real
12261 # time we'll see a difference
12262 time.sleep(2)
12263 two = self.run_js('a.out.js')
12264 self.assertIdentical(one, two)
12265
12266 def test_err(self):
12267 self.do_other_test('test_err.c')

Callers

nothing calls this directly

Calls 7

create_fileFunction · 0.90
path_from_rootFunction · 0.85
run_processMethod · 0.80
run_jsMethod · 0.80
sleepMethod · 0.80
assertIdenticalMethod · 0.80
get_cflagsMethod · 0.45

Tested by

no test coverage detected