diff --git a/package.json b/package.json index 9d96b02..155e9cd 100644 --- a/package.json +++ b/package.json @@ -56,15 +56,15 @@ "dependencies": { "bindings": "^1.2.1", "bluebird": "^2.9.34", - "nan": "^2.0.9" + "nan": "^2.1.0" }, "devDependencies": { - "chai": "^3.2.0", - "jshint": "^2.8.0", - "mocha": "^2.2.5", - "segfault-handler": "^0.2.5", - "semver": "^5.0.1", - "xpath": "~0.0.9", - "xmldom": "~0.1.19" + "chai": "^3.4.1", + "jshint": "^2.9.1-rc1", + "mocha": "^2.3.4", + "segfault-handler": "^1.0.0", + "semver": "^5.1.0", + "xpath": "^0.0.9", + "xmldom": "^0.1.19" } } diff --git a/src/error.cc b/src/error.cc index b2cf2dd..5a17c51 100644 --- a/src/error.cc +++ b/src/error.cc @@ -99,6 +99,10 @@ void Error::Initialize(Handle exports) NODE_DEFINE_CONSTANT(exports, VIR_ERR_INVALID_DOMAIN_SNAPSHOT); NODE_DEFINE_CONSTANT(exports, VIR_ERR_NO_DOMAIN_SNAPSHOT); +#if LIBVIR_CHECK_VERSION(1,2,21) + NODE_DEFINE_CONSTANT(exports, VIR_ERR_ARGUMENT_UNSUPPORTED); +#endif + //virErrorDomain NODE_DEFINE_CONSTANT(exports, VIR_FROM_NONE); NODE_DEFINE_CONSTANT(exports, VIR_FROM_XEN); diff --git a/src/error.h b/src/error.h index c65ae5f..a5e42f1 100644 --- a/src/error.h +++ b/src/error.h @@ -2,13 +2,7 @@ #ifndef ERROR_H #define ERROR_H -#include - -#include -#include - -using namespace v8; -using namespace node; +#include "node_libvirt.h" namespace NLV { diff --git a/src/node_libvirt.h b/src/node_libvirt.h index 0de6fd9..7d29797 100644 --- a/src/node_libvirt.h +++ b/src/node_libvirt.h @@ -14,4 +14,8 @@ using namespace node; #define NLV_WARN_UNFINISHED(Method) \ fprintf(stderr, "WARNING: " #Method " is still synchronous and needs to be ported\n"); +#ifndef LIBVIR_CHECK_VERSION +# define LIBVIR_CHECK_VERSION(major, minor, micro) false +#endif + #endif // NODE_LIBVIRT_H diff --git a/test/domain.test.js b/test/domain.test.js index 3a42d34..e2e4c94 100644 --- a/test/domain.test.js +++ b/test/domain.test.js @@ -312,9 +312,13 @@ describe('Domain', function() { test.domain.migrate({ dest_uri: 'test:///default', dest_name: 'test2', bandwidth: 100, flags: flags }, function(err) { expect(err).to.exist; // some libvirt versions report different error codes. - var expected = err.code === libvirt.VIR_ERR_OPERATION_INVALID ? libvirt.VIR_ERR_OPERATION_INVALID : libvirt.VIR_ERR_NO_SUPPORT; - expect(err.code).to.be.equal(expected); + var possibleErrors = [ + libvirt.VIR_ERR_OPERATION_INVALID, + libvirt.VIR_ERR_NO_SUPPORT, + libvirt.VIR_ERR_ARGUMENT_UNSUPPORTED + ]; + expect(possibleErrors).to.include(err.code); // NOTE: not supported by test driver // expect(err).to.not.exist; @@ -342,9 +346,12 @@ describe('Domain', function() { var physical = [test.domain.VIR_MEMORY_PHYSICAL]; var virtual = [test.domain.VIR_MEMORY_VIRTUAL]; + // support different errors for different libvirt versions + var possibleErrors = [ libvirt.VIR_ERR_INVALID_ARG, libvirt.VIR_ERR_NO_SUPPORT ]; + test.domain.memoryPeek(0, 1024, physical, function(err, res) { expect(err).to.exist; - expect(err.code).to.be.equal(libvirt.VIR_ERR_INVALID_ARG); + expect(possibleErrors).to.include(err.code); // NOTE: not supported by test driver // expect(err).to.not.exist; @@ -352,7 +359,7 @@ describe('Domain', function() { test.domain.memoryPeek(0, 1024, virtual, function(err, res) { expect(err).to.exist; - expect(err.code).to.be.equal(libvirt.VIR_ERR_INVALID_ARG); + expect(possibleErrors).to.include(err.code); // NOTE: not supported by test driver //expect(err).to.not.exist;