(self)
| 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 | |
| 12249 | int 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 | ''') |
| 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') |
nothing calls this directly
no test coverage detected