|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 "use strict"; |
|
5 |
|
6 let os = require("node/os"); |
|
7 let system = require("sdk/system"); |
|
8 |
|
9 exports["test os"] = function (assert) { |
|
10 assert.equal(os.tmpdir(), system.pathFor("TmpD"), "os.tmpdir() matches temp dir"); |
|
11 assert.ok(os.endianness() === "BE" || os.endianness() === "LE", "os.endianness is BE or LE"); |
|
12 |
|
13 assert.ok(os.arch().length > 0, "os.arch() returns a value"); |
|
14 assert.equal(typeof os.arch(), "string", "os.arch() returns a string"); |
|
15 assert.ok(os.type().length > 0, "os.type() returns a value"); |
|
16 assert.equal(typeof os.type(), "string", "os.type() returns a string"); |
|
17 assert.ok(os.platform().length > 0, "os.platform() returns a value"); |
|
18 assert.equal(typeof os.platform(), "string", "os.platform() returns a string"); |
|
19 |
|
20 assert.ok(os.release().length > 0, "os.release() returns a value"); |
|
21 assert.equal(typeof os.release(), "string", "os.release() returns a string"); |
|
22 assert.ok(os.hostname().length > 0, "os.hostname() returns a value"); |
|
23 assert.equal(typeof os.hostname(), "string", "os.hostname() returns a string"); |
|
24 assert.ok(os.EOL === "\n" || os.EOL === "\r\n", "os.EOL returns a correct EOL char"); |
|
25 |
|
26 assert.deepEqual(os.loadavg(), [0, 0, 0], "os.loadavg() returns an array of 0s"); |
|
27 |
|
28 ["uptime", "totalmem", "freemem", "cpus"].forEach(method => { |
|
29 assert.throws(() => os[method](), "os." + method + " throws"); |
|
30 }); |
|
31 }; |
|
32 |
|
33 require("test").run(exports); |