|
| 1 | +var m0 = require('./test_proxyfs.js'); |
| 2 | +var m1 = require('./test_proxyfs1.js'); |
| 3 | +var m2 = require('./test_proxyfs2.js'); |
| 4 | + |
| 5 | +var section; |
| 6 | +function print(str){ |
| 7 | + process.stdout.write(section+":"+str+":"); |
| 8 | +} |
| 9 | + |
| 10 | +m0.FS.mkdir('/working'); |
| 11 | +m0.FS.mount(m0.PROXYFS,{root:'/',fs:m1.FS},'/working'); |
| 12 | +m0.FS.mkdir('/working2'); |
| 13 | +m0.FS.mount(m0.PROXYFS,{root:'/',fs:m2.FS},'/working2'); |
| 14 | + |
| 15 | +section = "child m1 reads and writes local file."; |
| 16 | +print("m1 read embed"); |
| 17 | +m1.ccall('myreade','number',[],[]); |
| 18 | +print("m1 write");console.log(""); |
| 19 | +m1.ccall('mywrite0','number',['number'],[1]); |
| 20 | +print("m1 read"); |
| 21 | +m1.ccall('myread0','number',[],[]); |
| 22 | + |
| 23 | +section = "child m2 reads and writes local file."; |
| 24 | +print("m2 read embed"); |
| 25 | +m2.ccall('myreade','number',[],[]); |
| 26 | +print("m2 write");console.log(""); |
| 27 | +m2.ccall('mywrite0','number',['number'],[2]); |
| 28 | +print("m2 read"); |
| 29 | +m2.ccall('myread0','number',[],[]); |
| 30 | + |
| 31 | +section = "child m1 reads local file."; |
| 32 | +print("m1 read"); |
| 33 | +m1.ccall('myread0','number',[],[]); |
| 34 | + |
| 35 | +section = "parent m0 accesses children's file."; |
| 36 | +print("m0 access existing"); |
| 37 | +m0.ccall('myaccess0existing','number',[],[]); |
| 38 | +print("m0 access absent"); |
| 39 | +m0.ccall('myaccess0absent','number',[],[]); |
| 40 | + |
| 41 | +section = "child m1 accesses local file."; |
| 42 | +print("m1 access existing"); |
| 43 | +m1.ccall('myaccess1existing','number',[],[]); |
| 44 | +print("m1 access absent"); |
| 45 | +m1.ccall('myaccess1absent','number',[],[]); |
| 46 | + |
| 47 | +section = "parent m0 reads and writes local and children's file."; |
| 48 | +print("m0 read embed"); |
| 49 | +m0.ccall('myreade','number',[],[]); |
| 50 | +print("m0 read m1"); |
| 51 | +m0.ccall('myread1','number',[],[]); |
| 52 | +print("m0 read m2"); |
| 53 | +m0.ccall('myread2','number',[],[]); |
| 54 | + |
| 55 | +section = "m0,m1 and m2 verify local files."; |
| 56 | +print("m0 write");console.log(""); |
| 57 | +m0.ccall('mywrite0','number',['number'],[0]); |
| 58 | +print("m0 read"); |
| 59 | +m0.ccall('myread0','number',[],[]); |
| 60 | +print("m1 read"); |
| 61 | +m1.ccall('myread0','number',[],[]); |
| 62 | +print("m2 read"); |
| 63 | +m2.ccall('myread0','number',[],[]); |
| 64 | + |
| 65 | +print("m0 read embed"); |
| 66 | +m0.ccall('myreade','number',[],[]); |
| 67 | +print("m1 read embed"); |
| 68 | +m1.ccall('myreade','number',[],[]); |
| 69 | +print("m2 read embed"); |
| 70 | +m2.ccall('myreade','number',[],[]); |
| 71 | + |
| 72 | +section = "parent m0 writes and reads children's files."; |
| 73 | +print("m0 write m1");console.log(""); |
| 74 | +m0.ccall('mywrite1','number',[],[]); |
| 75 | +print("m0 read m1"); |
| 76 | +m0.ccall('myread1','number',[],[]); |
| 77 | +print("m0 write m2");console.log(""); |
| 78 | +m0.ccall('mywrite2','number',[],[]); |
| 79 | +print("m0 read m2"); |
| 80 | +m0.ccall('myread2','number',[],[]); |
| 81 | +print("m1 read"); |
| 82 | +m1.ccall('myread0','number',[],[]); |
| 83 | +print("m2 read"); |
| 84 | +m2.ccall('myread0','number',[],[]); |
| 85 | +print("m0 read m0"); |
| 86 | +m0.ccall('myread0','number',[],[]); |
| 87 | + |
| 88 | +section = "parent m0 renames a file in child fs."; |
| 89 | +m0.FS.writeFile('/working/test', 'testme'); |
| 90 | +m0.FS.rename('/working/test', '/working/test.bak'); |
| 91 | +console.log(section + ":renamed file accessible by the new name:" + m0.FS.analyzePath('/working/test.bak').exists); |
| 92 | +console.log(section + ":renamed file accessible by the old name:" + m0.FS.analyzePath('/working/test').exists); |
| 93 | + |
| 94 | +section = "test seek."; |
| 95 | +print("file size"); |
| 96 | +m0.ccall('myreadSeekEnd', 'number', [], []); |
0 commit comments