diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/filesystem/output.txt | 208 | ||||
-rw-r--r-- | tests/filesystem/src.js | 46 | ||||
-rw-r--r-- | tests/runner.py | 11 |
3 files changed, 265 insertions, 0 deletions
diff --git a/tests/filesystem/output.txt b/tests/filesystem/output.txt new file mode 100644 index 00000000..dd58133c --- /dev/null +++ b/tests/filesystem/output.txt @@ -0,0 +1,208 @@ + + isRoot: false + exists: true + error: 0 + path: /abc + name: abc + object.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/ + isRoot: true + exists: true + error: 0 + path: / + name: / + object.contents: ["forbidden","abc","def"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +. + isRoot: false + exists: true + error: 0 + path: /abc + name: abc + object.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +.. + isRoot: true + exists: true + error: 0 + path: / + name: / + object.contents: ["forbidden","abc","def"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +../.. + isRoot: true + exists: true + error: 0 + path: / + name: / + object.contents: ["forbidden","abc","def"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/abc + isRoot: false + exists: true + error: 0 + path: /abc + name: abc + object.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/abc/123 + isRoot: false + exists: true + error: 0 + path: /abc/123 + name: 123 + object.contents: [] + parentExists: true + parentPath: /abc + parentObject.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + +/abc/noexist + isRoot: false + exists: false + error: 2 + path: null + name: noexist + object.contents: null + parentExists: true + parentPath: /abc + parentObject.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + +/abc/deviceA + isRoot: false + exists: true + error: 0 + path: /abc/deviceA + name: deviceA + object.contents: [] + parentExists: true + parentPath: /abc + parentObject.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + +/abc/localLink + isRoot: false + exists: true + error: 0 + path: /abc/123 + name: 123 + object.contents: [] + parentExists: true + parentPath: /abc + parentObject.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + +/abc/rootLink + isRoot: true + exists: true + error: 0 + path: / + name: / + object.contents: ["forbidden","abc","def"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/abc/relativeLink + isRoot: false + exists: true + error: 0 + path: /def + name: def + object.contents: ["789","deviceB"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/abc/relativeLink/deviceB + isRoot: false + exists: true + error: 0 + path: /def/deviceB + name: deviceB + object.contents: [] + parentExists: true + parentPath: /def + parentObject.contents: ["789","deviceB"] + +/abc/rootLink/noexist + isRoot: false + exists: false + error: 2 + path: null + name: noexist + object.contents: null + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/abc/rootLink/abc/noexist + isRoot: false + exists: false + error: 2 + path: null + name: noexist + object.contents: null + parentExists: true + parentPath: /abc + parentObject.contents: ["123","456","deviceA","localLink","rootLink","relativeLink"] + +/forbidden + isRoot: false + exists: true + error: 0 + path: /forbidden + name: forbidden + object.contents: ["test"] + parentExists: true + parentPath: / + parentObject.contents: ["forbidden","abc","def"] + +/forbidden/test + isRoot: false + exists: false + error: 13 + path: null + name: test + object.contents: null + parentExists: true + parentPath: /forbidden + parentObject.contents: ["test"] + +/forbidden/noexist + isRoot: false + exists: false + error: 13 + path: null + name: noexist + object.contents: null + parentExists: true + parentPath: /forbidden + parentObject.contents: ["test"] + +/noexist1/noexist2 + isRoot: false + exists: false + error: 2 + path: null + name: null + object.contents: null + parentExists: false + parentPath: null + parentObject.contents: null diff --git a/tests/filesystem/src.js b/tests/filesystem/src.js new file mode 100644 index 00000000..5fdef564 --- /dev/null +++ b/tests/filesystem/src.js @@ -0,0 +1,46 @@ +FS.createFolder('/', 'forbidden', false, false); +FS.createFolder('/forbidden', 'test', true, true); +FS.createPath('/', 'abc/123', true, true); +FS.createPath('/', 'abc/456', true, true); +FS.createPath('/', 'def/789', true, true); +FS.createDevice('/abc', 'deviceA', function() {}, function() {}); +FS.createDevice('/def', 'deviceB', function() {}, function() {}); +FS.createLink('/abc', 'localLink', '123', true, true); +FS.createLink('/abc', 'rootLink', '/', true, true); +FS.createLink('/abc', 'relativeLink', '../def', true, true); + +function explore(path) { + print(path); + var ret = FS.analyzePath(path); + print(' isRoot: ' + ret.isRoot); + print(' exists: ' + ret.exists); + print(' error: ' + ret.error); + print(' path: ' + ret.path); + print(' name: ' + ret.name); + print(' object.contents: ' + (ret.object && JSON.stringify(Object.keys(ret.object.contents || {})))); + print(' parentExists: ' + ret.parentExists); + print(' parentPath: ' + ret.parentPath); + print(' parentObject.contents: ' + (ret.parentObject && JSON.stringify(Object.keys(ret.parentObject.contents)))); + print(''); +} + +FS.currentPath = '/abc'; +explore(''); +explore('/'); +explore('.'); +explore('..'); +explore('../..'); +explore('/abc'); +explore('/abc/123'); +explore('/abc/noexist'); +explore('/abc/deviceA'); +explore('/abc/localLink'); +explore('/abc/rootLink'); +explore('/abc/relativeLink'); +explore('/abc/relativeLink/deviceB'); +explore('/abc/rootLink/noexist'); +explore('/abc/rootLink/abc/noexist'); +explore('/forbidden'); +explore('/forbidden/test'); +explore('/forbidden/noexist'); +explore('/noexist1/noexist2'); diff --git a/tests/runner.py b/tests/runner.py index 99ab9974..b673b45c 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -2404,6 +2404,17 @@ if 'benchmark' not in sys.argv: ''' self.do_test(src, re.sub('(^|\n)\s+', '\\1', expected), post_build=addPreRunAndChecks) + def test_fs_base(self): + global INCLUDE_FULL_LIBRARY; INCLUDE_FULL_LIBRARY = 1 + def addJS(filename): + src = open(filename, 'r').read().replace( + '// {{PRE_RUN_ADDITIONS}}', + open(path_from_root('tests', 'filesystem', 'src.js'), 'r').read()) + open(filename, 'w').write(src) + src = 'int main() {return 0;}\n' + expected = open(path_from_root('tests', 'filesystem', 'output.txt'), 'r').read() + self.do_test(src, expected, post_build=addJS) + ### 'Big' tests def test_fannkuch(self): |