Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50641 views
1
// Copyright Joyent, Inc. and other Node contributors.
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a
4
// copy of this software and associated documentation files (the
5
// "Software"), to deal in the Software without restriction, including
6
// without limitation the rights to use, copy, modify, merge, publish,
7
// distribute, sublicense, and/or sell copies of the Software, and to permit
8
// persons to whom the Software is furnished to do so, subject to the
9
// following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included
12
// in all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22
var path = require('path');
23
var assert = require('assert');
24
25
exports.testDir = path.dirname(__filename);
26
exports.fixturesDir = path.join(exports.testDir, 'fixtures');
27
exports.libDir = path.join(exports.testDir, '../lib');
28
exports.tmpDir = path.join(exports.testDir, 'tmp');
29
exports.PORT = 12346;
30
31
if (process.platform == 'win32') {
32
exports.PIPE = '\\\\.\\pipe\\libuv-test';
33
} else {
34
exports.PIPE = exports.tmpDir + '/test.sock';
35
}
36
37
var util = require('util');
38
for (var i in util) exports[i] = util[i];
39
//for (var i in exports) global[i] = exports[i];
40
41
function protoCtrChain(o) {
42
var result = [];
43
for (; o; o = o.__proto__) { result.push(o.constructor); }
44
return result.join();
45
}
46
47
exports.indirectInstanceOf = function(obj, cls) {
48
if (obj instanceof cls) { return true; }
49
var clsChain = protoCtrChain(cls.prototype);
50
var objChain = protoCtrChain(obj);
51
return objChain.slice(-clsChain.length) === clsChain;
52
};
53
54
55
// Turn this off if the test should not check for global leaks.
56
exports.globalCheck = true;
57
58
process.on('exit', function() {
59
if (!exports.globalCheck) return;
60
var knownGlobals = [setTimeout,
61
setInterval,
62
clearTimeout,
63
clearInterval,
64
console,
65
Buffer,
66
process,
67
global.ArrayBuffer!==undefined?ArrayBuffer:null,
68
global.Int8Array!==undefined?Int8Array:null,
69
global.Uint8Array!==undefined?Uint8Array:null,
70
global.Int16Array!==undefined?Int16Array:null,
71
global.Uint16Array!==undefined?Uint16Array:null,
72
global.Int32Array!==undefined?Int32Array:null,
73
global.Uint32Array!==undefined?Uint32Array:null,
74
global.Float32Array!==undefined?Float32Array:null,
75
global.Float64Array!==undefined?Float64Array:null,
76
global.DataView!==undefined?DataView:null,
77
AssertionError,
78
global,
79
events
80
];
81
82
if (global.errno) {
83
knownGlobals.push(errno);
84
}
85
86
if (global.gc) {
87
knownGlobals.push(gc);
88
}
89
90
if (global.DTRACE_HTTP_SERVER_RESPONSE) {
91
knownGlobals.push(DTRACE_HTTP_SERVER_RESPONSE);
92
knownGlobals.push(DTRACE_HTTP_SERVER_REQUEST);
93
knownGlobals.push(DTRACE_HTTP_CLIENT_RESPONSE);
94
knownGlobals.push(DTRACE_HTTP_CLIENT_REQUEST);
95
knownGlobals.push(DTRACE_NET_STREAM_END);
96
knownGlobals.push(DTRACE_NET_SERVER_CONNECTION);
97
knownGlobals.push(DTRACE_NET_SOCKET_READ);
98
knownGlobals.push(DTRACE_NET_SOCKET_WRITE);
99
}
100
101
for (var x in global) {
102
var found = false;
103
104
for (var y in knownGlobals) {
105
if (global[x] === knownGlobals[y]) {
106
found = true;
107
break;
108
}
109
}
110
111
if (!found) {
112
console.error('Unknown global: %s', x);
113
assert.ok(false, 'Unknown global founded');
114
}
115
}
116
});
117
118
119
// This function allows one two run an HTTP test agaist both HTTPS and
120
// normal HTTP modules. This ensures they fit the same API.
121
exports.httpTest = function httpTest(cb) {
122
};
123
124
125