forked from NodeOS/NodeOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest
More file actions
executable file
·81 lines (63 loc) · 1.76 KB
/
test
File metadata and controls
executable file
·81 lines (63 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env node
/**
* NodeOS
*
* @copyright 2013-2017 Jacob Groundwater, Jesús Leganés-Combarro 'piranna'
* and other contributors
*
* @license MIT
*/
const join = require('path').join
const suppose = require('suppose')
const prepareCommandLine = require('..')
const TIMEOUT = 300 // seconds
let {command, argv, cwd, platform, timeout_rate} =
prepareCommandLine(process.argv.slice(2), 'nographic')
switch(platform)
{
case 'tar':
fs.accessSync(join(cwd, 'bootfs.tar.gz'))
fs.accessSync(join(cwd, 'usersfs.tar.gz'))
process.exit()
break
case 'vagga':
fs.accessSync(join(cwd, 'barebones.tar.gz'))
fs.accessSync(join(cwd, 'initramfs.tar.gz'))
fs.accessSync(join(cwd, 'usersfs.tar.gz'))
process.exit()
break
}
// Exec test
let exe
let timeout = setTimeout(function()
{
exe.kill()
console.error('Timeout while waiting an answer')
process.exit(-2)
}, TIMEOUT*timeout_rate*1000)
const options = {stripAnsi: true, debug: true, cwd}
//const options = {stripAnsi: true, debug: process.argv[2] === 'debug', cwd}
exe = suppose(command, argv, options)
// On disk images, hook on the bootloader and force kernel to output to console
if(platform === 'disk' || platform === 'img' || platform === 'iso')
exe.when('boot: ').respond('NodeOS console=ttyS0\n')
exe
.when(/username: /, 'nodeos\n')
.when(/password: /, 'nodeos\n')
.when('~ > ' , 'node\n')
.when('> ', 'setTimeout(console.log, 2000, "this is","a test")\n')
.when(/this is a test/, function(exe)
{
exe.kill()
})
.on('error', function(error)
{
if(error.message.indexOf('terminating on signal 15 from pid') < 0)
console.trace(error)
})
.end(function()
{
clearTimeout(timeout)
var expects = this.expects.length
if(expects) process.exit(expects)
})