2014-01-14 19:50:20 +00:00
|
|
|
define(["Filer"], function(Filer) {
|
2013-12-20 16:50:59 +00:00
|
|
|
|
2013-12-21 21:30:40 +00:00
|
|
|
describe('fs.xattr', function() {
|
2013-12-20 16:50:59 +00:00
|
|
|
beforeEach(function() {
|
|
|
|
this.db_name = mk_db_name();
|
2014-01-14 19:50:20 +00:00
|
|
|
this.fs = new Filer.FileSystem({
|
2013-12-20 16:50:59 +00:00
|
|
|
name: this.db_name,
|
|
|
|
flags: 'FORMAT'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
indexedDB.deleteDatabase(this.db_name);
|
|
|
|
delete this.fs;
|
|
|
|
});
|
|
|
|
|
2013-12-21 21:30:40 +00:00
|
|
|
it('should be a function', function () {
|
|
|
|
expect(typeof this.fs.setxattr).toEqual('function');
|
|
|
|
expect(typeof this.fs.getxattr).toEqual('function');
|
2014-01-14 01:03:54 +00:00
|
|
|
expect(typeof this.fs.removexattr).toEqual('function');
|
|
|
|
expect(typeof this.fs.fsetxattr).toEqual('function');
|
|
|
|
expect(typeof this.fs.fgetxattr).toEqual('function');
|
2013-12-21 21:30:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should error when setting with a name that is not a string', function () {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 89, 'testvalue', function (error) {
|
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_error.name).toEqual('EInvalid');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should error when setting with a name that is null', function () {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', null, 'testvalue', function (error) {
|
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_error.name).toEqual('EInvalid');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should error when setting with an invalid flag', function () {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', 'value', 'InvalidFlag', function (error) {
|
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_error.name).toEqual('EInvalid');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should error when when setting an extended attribute which exists with XATTR_CREATE flag', function (error) {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', 'value', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', 'othervalue', 'CREATE', function (error) {
|
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_error.name).toEqual('EExists');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should error when setting an extended attribute which does not exist with XATTR_REPLACE flag', function (error) {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', 'value', 'REPLACE', function (error) {
|
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_error.name).toEqual('ENoAttr');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-12-23 01:58:00 +00:00
|
|
|
it ('should error when getting an attribute with a name that is empty', function (error) {
|
2013-12-21 21:30:40 +00:00
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', '', function (error, value) {
|
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_error.name).toEqual('EInvalid');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-12-23 01:58:00 +00:00
|
|
|
it('should error when getting an attribute where the name is not a string', function (error) {
|
2013-12-21 21:30:40 +00:00
|
|
|
var complete = false;
|
|
|
|
var _error;
|
2013-12-23 01:58:00 +00:00
|
|
|
var that = this;
|
2013-12-21 21:30:40 +00:00
|
|
|
|
2013-12-23 01:58:00 +00:00
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
2013-12-21 21:30:40 +00:00
|
|
|
if (error) throw error;
|
|
|
|
|
2013-12-23 01:58:00 +00:00
|
|
|
that.fs.getxattr('/testfile', 89, function (error, value) {
|
2013-12-21 21:30:40 +00:00
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_error.name).toEqual('EInvalid');
|
|
|
|
});
|
|
|
|
});
|
2013-12-23 01:58:00 +00:00
|
|
|
|
|
|
|
it('should error when getting an attribute that does not exist', function (error) {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'test', function (error, value) {
|
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_error.name).toEqual('ENoAttr');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should error when file descriptor is invalid', function (error) {
|
2014-01-02 22:50:26 +00:00
|
|
|
var completeSet, completeGet, completeRemove;
|
|
|
|
var _errorSet, _errorGet, _errorRemove;
|
2013-12-23 01:58:00 +00:00
|
|
|
var that = this;
|
|
|
|
var _value;
|
|
|
|
|
2014-01-02 22:50:26 +00:00
|
|
|
completeSet = completeGet = completeRemove = false;
|
2013-12-23 01:58:00 +00:00
|
|
|
|
2014-01-14 19:50:20 +00:00
|
|
|
that.fs.fsetxattr(1, 'test', 'value', function (error) {
|
2013-12-23 01:58:00 +00:00
|
|
|
_errorSet = error;
|
|
|
|
completeSet = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
that.fs.fgetxattr(1, 'test', function (error, value) {
|
|
|
|
_errorGet = error;
|
|
|
|
_value = value;
|
|
|
|
completeGet = true;
|
|
|
|
});
|
|
|
|
|
2014-01-02 22:50:26 +00:00
|
|
|
that.fs.fremovexattr(1, 'test', function (error, value) {
|
|
|
|
_errorRemove = error;
|
|
|
|
completeRemove = true;
|
|
|
|
});
|
|
|
|
|
2013-12-23 01:58:00 +00:00
|
|
|
waitsFor(function () {
|
2014-01-02 22:50:26 +00:00
|
|
|
return completeSet && completeGet && completeRemove;
|
2013-12-23 01:58:00 +00:00
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_value).toEqual(null);
|
|
|
|
expect(_errorSet).toBeDefined();
|
|
|
|
expect(_errorSet.name).toEqual('EBadFileDescriptor');
|
|
|
|
expect(_errorGet).toBeDefined();
|
|
|
|
expect(_errorGet.name).toEqual('EBadFileDescriptor');
|
2014-01-02 22:50:26 +00:00
|
|
|
expect(_errorRemove).toBeDefined();
|
|
|
|
expect(_errorRemove.name).toEqual('EBadFileDescriptor');
|
2013-12-23 01:58:00 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should set and get an extended attribute of a path', function (error) {
|
|
|
|
var complete = false;
|
|
|
|
var _errorSet;
|
|
|
|
var that = this;
|
|
|
|
var name = 'test';
|
|
|
|
var _value;;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', name, 'somevalue', function (error) {
|
|
|
|
_errorSet = error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', name, function (error, value) {
|
|
|
|
_errorGet = error;
|
|
|
|
_value = value;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_errorSet).toEqual(null);
|
|
|
|
expect(_errorGet).toEqual(null);
|
|
|
|
expect(_value).toEqual('somevalue');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-12-24 20:10:17 +00:00
|
|
|
it('should error when attempting to remove a non-existing attribute', function (error) {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.removexattr('/testfile', 'testenoattr', function (error) {
|
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_error.name).toEqual('ENoAttr');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-12-23 01:58:00 +00:00
|
|
|
it('should set and get an empty string as a value', function (error) {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var _value;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', '', function (error) {
|
|
|
|
_error = error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'test', function (error, value) {
|
|
|
|
_error = error;
|
|
|
|
_value = value;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_value).toBeDefined();
|
|
|
|
expect(_value).toEqual('');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should set and get an extended attribute for a valid file descriptor', function (error) {
|
|
|
|
var complete = false;
|
|
|
|
var _errorSet, _errorGet;
|
|
|
|
var _value;
|
|
|
|
var that = this;
|
|
|
|
var ofd;
|
|
|
|
|
|
|
|
that.fs.open('/testfile', 'w', function (error, result) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
ofd = result;
|
|
|
|
|
|
|
|
that.fs.fsetxattr(ofd, 'test', 'value', function (error) {
|
|
|
|
_errorSet = error;
|
|
|
|
|
|
|
|
that.fs.fgetxattr(ofd, 'test', function (error, value) {
|
|
|
|
_errorGet = error;
|
|
|
|
_value = value;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_errorSet).toEqual(null);
|
|
|
|
expect(_errorGet).toEqual(null);
|
|
|
|
expect(_value).toBeDefined();
|
|
|
|
expect(_value).toEqual('value');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-12-24 20:10:17 +00:00
|
|
|
it('should set and get an object to an extended attribute', function (error) {
|
2013-12-23 01:58:00 +00:00
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
var value;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', { key1: 'test', key2: 'value', key3: 87 }, function (error) {
|
|
|
|
_error = error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'test', function (error, value) {
|
|
|
|
_error = error;
|
|
|
|
_value = value;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-01-14 19:50:20 +00:00
|
|
|
waitsFor(function () {
|
2013-12-23 01:58:00 +00:00
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_value).toEqual({ key1: 'test', key2: 'value', key3: 87 });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should update/overwrite an existing extended attribute', function (error) {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
var _value1, _value2, _value3;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', 'value', function (error) {
|
|
|
|
_error = error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'test', function (error, value) {
|
|
|
|
_error = error;
|
|
|
|
_value1 = value;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', { o: 'object', t: 'test' }, function (error) {
|
|
|
|
_error = error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'test', function (error, value) {
|
|
|
|
_error = error;
|
|
|
|
_value2 = value;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', 100, 'REPLACE', function (error) {
|
|
|
|
_error = error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'test', function (error, value) {
|
|
|
|
_error = error;
|
|
|
|
_value3 = value;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete' , DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_value1).toEqual('value');
|
|
|
|
expect(_value2).toEqual({ o: 'object', t: 'test' });
|
|
|
|
expect(_value3).toEqual(100);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should set multiple extended attributes for a path', function (error) {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var that = this;
|
|
|
|
var _value1, _value2;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', 89, function (error) {
|
|
|
|
_error = error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'other', 'attribute', function (error) {
|
|
|
|
_error = error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'test', function (error, value) {
|
|
|
|
_error = error;
|
|
|
|
_value1 = value;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'other', function (error, value) {
|
|
|
|
_error = error;
|
|
|
|
_value2 = value;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_value1).toEqual(89);
|
|
|
|
expect(_value2).toEqual('attribute');
|
|
|
|
});
|
|
|
|
});
|
2013-12-24 20:10:17 +00:00
|
|
|
|
|
|
|
it('should remove an extended attribute from a path', function (error) {
|
|
|
|
var complete = false;
|
|
|
|
var _error, _value;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', 'somevalue', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'test', function (error, value) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
_value = value;
|
|
|
|
|
|
|
|
that.fs.removexattr('/testfile', 'test', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'test', function (error) {
|
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_value).toBeDefined();
|
|
|
|
expect(_value).toEqual('somevalue');
|
|
|
|
expect(_error.name).toEqual('ENoAttr');
|
|
|
|
});
|
2014-01-02 22:50:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should remove an extended attribute from a valid file descriptor', function () {
|
|
|
|
var complete = false;
|
|
|
|
var _error, _value;
|
|
|
|
var that = this;
|
|
|
|
var ofd;
|
|
|
|
|
|
|
|
that.fs.open('/testfile', 'w', function (error, result) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
var ofd = result;
|
|
|
|
|
|
|
|
that.fs.fsetxattr(ofd, 'test', 'somevalue', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.fgetxattr(ofd, 'test', function (error, value) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
_value = value;
|
|
|
|
|
|
|
|
that.fs.fremovexattr(ofd, 'test', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.fgetxattr(ofd, 'test', function (error) {
|
|
|
|
_error = error;
|
|
|
|
complete = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
2013-12-24 20:10:17 +00:00
|
|
|
|
2014-01-02 22:50:26 +00:00
|
|
|
runs(function () {
|
|
|
|
expect(_error).toBeDefined();
|
|
|
|
expect(_value).toBeDefined();
|
|
|
|
expect(_value).toEqual('somevalue');
|
|
|
|
expect(_error.name).toEqual('ENoAttr');
|
|
|
|
});
|
2013-12-24 20:10:17 +00:00
|
|
|
});
|
2014-01-05 17:22:57 +00:00
|
|
|
|
|
|
|
it('should allow setting with a null value', function () {
|
|
|
|
var complete = false;
|
|
|
|
var _error;
|
|
|
|
var _value;
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
that.fs.writeFile('/testfile', '', function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.setxattr('/testfile', 'test', null, function (error) {
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
that.fs.getxattr('/testfile', 'test', function (error, value) {
|
|
|
|
_error = error;
|
|
|
|
_value = value;
|
|
|
|
complete = true;
|
2014-01-14 19:50:20 +00:00
|
|
|
});
|
2014-01-05 17:22:57 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitsFor(function () {
|
|
|
|
return complete;
|
|
|
|
}, 'test to complete', DEFAULT_TIMEOUT);
|
|
|
|
|
|
|
|
runs(function () {
|
|
|
|
expect(_error).toEqual(null);
|
|
|
|
expect(_value).toEqual(null);
|
|
|
|
});
|
|
|
|
});
|
2013-12-20 16:50:59 +00:00
|
|
|
});
|
2013-12-21 21:30:40 +00:00
|
|
|
});
|