aboutsummaryrefslogtreecommitdiff
path: root/tests/hello_world_worker.cpp
blob: 5b673df82ad7815f6e64f8c81d859cb6dc080b47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <string.h>
#include <stdio.h>
#include <emscripten.h>

int main()
{
  printf("you should not see this text when in a worker!\n"); // this should not crash, but also should not show up anywhere if you are in a worker
  FILE *f = fopen("file.dat", "r");
  char buffer[100];
  memset(buffer, 0, 100);
  buffer[0] = 0;
  fread(buffer, 10, 1, f);
  char buffer2[100];
  sprintf(buffer2, "if (typeof postMessage !== 'undefined') { postMessage('hello from worker, and |%s|') }", buffer);
  emscripten_run_script(buffer2);
}