~ubuntu-branches/ubuntu/vivid/emscripten/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/fs/test_idbfs_sync.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (4.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140119141240-nfiw0p8033oitpfz
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <emscripten.h>
 
3
 
 
4
#define EM_ASM_REEXPAND(x) EM_ASM(x)
 
5
 
 
6
void success() {
 
7
  int result = 1;
 
8
  REPORT_RESULT();
 
9
}
 
10
 
 
11
int main() {
 
12
  EM_ASM(
 
13
    FS.mkdir('/working');
 
14
    FS.mount(IDBFS, {}, '/working');
 
15
  );
 
16
 
 
17
#if FIRST
 
18
  // store local files to backing IDB
 
19
  EM_ASM_REEXPAND(
 
20
    FS.writeFile('/working/waka.txt', 'az');
 
21
    FS.writeFile('/working/moar.txt', SECRET);
 
22
    FS.syncfs(function (err) {
 
23
      assert(!err);
 
24
 
 
25
      ccall('success', 'v', '', []);
 
26
    });
 
27
  );
 
28
#else
 
29
  // load files from backing IDB
 
30
  EM_ASM_REEXPAND(
 
31
    FS.syncfs(true, function (err) {
 
32
      assert(!err);
 
33
 
 
34
      var contents = FS.readFile('/working/waka.txt', { encoding: 'utf8' });
 
35
      assert(contents === 'az');
 
36
 
 
37
      var secret = FS.readFile('/working/moar.txt', { encoding: 'utf8' });
 
38
      assert(secret === SECRET);
 
39
 
 
40
      ccall('success', 'v', '', []);
 
41
    });
 
42
  );
 
43
#endif
 
44
 
 
45
  emscripten_exit_with_live_runtime();
 
46
 
 
47
  return 0;
 
48
}