git ssb

0+

cel-desktop / ssb-pkg



Tree: 938b7ea4cfaa3cef6e1690b9ef3ea8bd7a0d2de1

Files: 938b7ea4cfaa3cef6e1690b9ef3ea8bd7a0d2de1 / test / test-50-corrupt-executable / main.js

1211 bytesRaw
1#!/usr/bin/env node
2
3'use strict';
4
5const fs = require('fs');
6const path = require('path');
7const assert = require('assert');
8const utils = require('../utils.js');
9
10assert(!module.parent);
11assert(__dirname === process.cwd());
12
13const host = 'node' + process.version.match(/^v(\d+)/)[1];
14const target = process.argv[2] || host;
15const input = './test-x-index.js';
16const output = './test-output.exe';
17
18let right;
19
20utils.pkg.sync([
21 '--target', target,
22 '--output', output, input
23]);
24
25const damage = fs.readFileSync(output);
26const boundary = 4096;
27damage[damage.length - 2 * boundary - 10] = 0x2;
28damage[damage.length - 3 * boundary - 10] = 0x2;
29damage[damage.length - 4 * boundary - 10] = 0x2;
30damage[damage.length - 2 * boundary + 10] = 0x2;
31damage[damage.length - 3 * boundary + 10] = 0x2;
32damage[damage.length - 4 * boundary + 10] = 0x2;
33fs.writeFileSync(output, damage);
34
35right = utils.spawn.sync(
36 './' + path.basename(output), [],
37 { cwd: path.dirname(output),
38 stdio: 'pipe', expect: 1 }
39);
40
41assert.equal(right.stdout, '');
42assert((right.stderr.indexOf('Invalid') >= 0) ||
43 (right.stderr.indexOf('ILLEGAL') >= 0) ||
44 (right.stderr.indexOf('SyntaxError') >= 0));
45utils.vacuum.sync(output);
46

Built with git-ssb-web