Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: ports/devenv/tests/common.js

Issue 1563073002: Re-enable io2014 + add cds2014 tests for devenv. (Closed) Base URL: https://chromium.googlesource.com/webports.git@master
Patch Set: fix Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ports/devenv/io2014_test.py ('k') | ports/devenv/tests/demo2014_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* globals ASSERT_EQ, EXPECT_EQ, EXPECT_TRUE, chrometest */ 7 /* globals ASSERT_EQ, EXPECT_EQ, EXPECT_TRUE, chrometest */
8 8
9 'use strict'; 9 'use strict';
10 10
(...skipping 22 matching lines...) Expand all
33 }).then(function() { 33 }).then(function() {
34 return chrometest.proxyExtension('TCP Interface'); 34 return chrometest.proxyExtension('TCP Interface');
35 }).then(function(ext) { 35 }).then(function(ext) {
36 self.tcp = ext; 36 self.tcp = ext;
37 return self.initFileSystem(); 37 return self.initFileSystem();
38 }).then(function() { 38 }).then(function() {
39 return self.mkdir('/home'); 39 return self.mkdir('/home');
40 }).then(function() { 40 }).then(function() {
41 return self.mkdir('/home/user'); 41 return self.mkdir('/home/user');
42 }).then(function() { 42 }).then(function() {
43 return self.checkCommand('bash -c exit 0', 0); 43 return self.checkCommand('bash -c exit', 0);
44 }).then(function() { 44 }).then(function() {
45 if (self.params['latest'] === '1') 45 if (self.params['latest'] === '1')
46 return self.setLocalRepo(window.location.origin); 46 return self.setLocalRepo(window.location.origin);
47 }); 47 });
48 }; 48 };
49 49
50 DevEnvTest.prototype.tearDown = function() { 50 DevEnvTest.prototype.tearDown = function() {
51 var self = this; 51 var self = this;
52 return Promise.resolve().then(function() { 52 return Promise.resolve().then(function() {
53 self.devEnv.disconnect(); 53 self.devEnv.disconnect();
(...skipping 26 matching lines...) Expand all
80 output += msg.output; 80 output += msg.output;
81 chrometest.info('stdout: ' + msg.output); 81 chrometest.info('stdout: ' + msg.output);
82 }); 82 });
83 }).then(function(msg) { 83 }).then(function(msg) {
84 ASSERT_EQ(name, msg.name, 'expected message'); 84 ASSERT_EQ(name, msg.name, 'expected message');
85 msg.output = output; 85 msg.output = output;
86 return msg; 86 return msg;
87 }); 87 });
88 }; 88 };
89 89
90 DevEnvTest.prototype.spawnCommand = function(cmd) { 90 DevEnvTest.prototype.spawnCommand = function(cmd, env) {
91 var self = this; 91 var self = this;
92 92
93 var env = ['HOME=/home/user', 'NACL_DATA_MOUNT_FLAGS=manifest=/manifest.txt']; 93 if (env === undefined) {
94 env = [];
95 }
96 env.push('HOME=/home/user');
97 env.push('NACL_DATA_MOUNT_FLAGS=manifest=/manifest.txt');
94 if (this.params['latest'] === '1') { 98 if (this.params['latest'] === '1') {
95 env.push('NACL_DEVENV_LOCAL=1'); 99 env.push('NACL_DEVENV_LOCAL=1');
96 } 100 }
97 101
98 return Promise.resolve().then(function() { 102 return Promise.resolve().then(function() {
99 self.devEnv.postMessage({ 103 self.devEnv.postMessage({
100 'name': 'nacl_spawn', 104 'name': 'nacl_spawn',
101 'nmf': 'bash.nmf', 105 'nmf': 'bash.nmf',
102 'argv': ['bash', '--login', '-c', cmd], 106 'argv': ['bash', '--login', '-c', cmd],
103 'cwd': '/home/user', 107 'cwd': '/home/user',
(...skipping 15 matching lines...) Expand all
119 'options': 0, 123 'options': 0,
120 }); 124 });
121 return self.gatherStdoutUntil('nacl_waitpid_reply'); 125 return self.gatherStdoutUntil('nacl_waitpid_reply');
122 }).then(function(msg) { 126 }).then(function(msg) {
123 ASSERT_EQ('nacl_waitpid_reply', msg.name); 127 ASSERT_EQ('nacl_waitpid_reply', msg.name);
124 ASSERT_EQ(pid, msg.pid); 128 ASSERT_EQ(pid, msg.pid);
125 return {status: msg.status, output: msg.output}; 129 return {status: msg.status, output: msg.output};
126 }); 130 });
127 }; 131 };
128 132
129 DevEnvTest.prototype.runCommand = function(cmd) { 133 DevEnvTest.prototype.runCommand = function(cmd, env) {
130 var self = this; 134 var self = this;
131 var earlyOutput; 135 var earlyOutput;
132 chrometest.info('runCommand: ' + cmd); 136 chrometest.info('runCommand: ' + cmd);
133 return Promise.resolve().then(function() { 137 return Promise.resolve().then(function() {
134 return self.spawnCommand(cmd); 138 return self.spawnCommand(cmd, env);
135 }).then(function(msg) { 139 }).then(function(msg) {
136 earlyOutput = msg.output; 140 earlyOutput = msg.output;
137 return self.waitCommand(msg.pid); 141 return self.waitCommand(msg.pid);
138 }).then(function(msg) { 142 }).then(function(msg) {
139 msg.output = earlyOutput + msg.output; 143 msg.output = earlyOutput + msg.output;
140 return msg; 144 return msg;
141 }); 145 });
142 }; 146 };
143 147
144 DevEnvTest.prototype.checkCommand = function( 148 DevEnvTest.prototype.checkCommand = function(
145 cmd, expectedStatus, expectedOutput) { 149 cmd, expectedStatus, expectedOutput, env) {
146 if (expectedStatus === undefined) { 150 if (expectedStatus === undefined) {
147 expectedStatus = 0; 151 expectedStatus = 0;
148 } 152 }
149 var self = this; 153 var self = this;
150 return Promise.resolve().then(function() { 154 return Promise.resolve().then(function() {
151 return self.runCommand(cmd); 155 return self.runCommand(cmd, env);
152 }).then(function(result) { 156 }).then(function(result) {
153 ASSERT_EQ(expectedStatus, result.status, result.output); 157 ASSERT_EQ(expectedStatus, result.status, result.output);
154 if (expectedOutput !== undefined) { 158 if (expectedOutput !== undefined) {
155 ASSERT_EQ(expectedOutput, result.output); 159 ASSERT_EQ(expectedOutput, result.output);
156 } 160 }
157 }); 161 });
158 }; 162 };
159 163
160 DevEnvTest.prototype.sigint = function(pid) { 164 DevEnvTest.prototype.sigint = function(pid) {
161 this.devEnv.postMessage({ 165 this.devEnv.postMessage({
162 'name': 'nacl_sigint', 166 'name': 'nacl_sigint',
163 }); 167 });
164 }; 168 };
165 169
166 DevEnvTest.prototype.installPackage = function(name) { 170 DevEnvTest.prototype.installPackage = function(name) {
167 var cmd = 'pkg install -f -y ' + name; 171 var cmd = 'pkg install -f -y ' + name;
168 chrometest.info(cmd); 172 chrometest.info(cmd);
169 return this.checkCommand(cmd, 0); 173 return this.checkCommand(cmd, 0);
170 }; 174 };
171 175
172 DevEnvTest.prototype.installDefaultPackages = function(name) { 176 DevEnvTest.prototype.installDefaultPackages = function(name) {
173 var cmd = 'bash /mnt/http/install-base-packages.sh'; 177 var env = ['INSTALL_BASE_PACKAGES=1'];
174 chrometest.info(cmd); 178 chrometest.info('install base packages');
175 return this.checkCommand(cmd, 0); 179 return this.checkCommand('exit', 0, undefined, env);
176 }; 180 };
177 181
178
179 DevEnvTest.prototype.checkCommandReLines = function( 182 DevEnvTest.prototype.checkCommandReLines = function(
180 cmd, expectedStatus, expectedOutput) { 183 cmd, expectedStatus, expectedOutput) {
181 var self = this; 184 var self = this;
182 return Promise.resolve().then(function() { 185 return Promise.resolve().then(function() {
183 return self.runCommand(cmd); 186 return self.runCommand(cmd);
184 }).then(function(result) { 187 }).then(function(result) {
185 ASSERT_EQ(expectedStatus, result.status, result.output); 188 ASSERT_EQ(expectedStatus, result.status, result.output);
186 var resultLines = result.output.split('\n'); 189 var resultLines = result.output.split('\n');
187 // Trim the last line if empty to reduce boilerplate. 190 // Trim the last line if empty to reduce boilerplate.
188 if (resultLines[resultLines.length - 1] === '') { 191 if (resultLines[resultLines.length - 1] === '') {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 * Close a TCP connection. 406 * Close a TCP connection.
404 * @param {number} socket The TCP socket. 407 * @param {number} socket The TCP socket.
405 * @returns {Promise} 408 * @returns {Promise}
406 */ 409 */
407 DevEnvTest.prototype.tcpClose = function(socket) { 410 DevEnvTest.prototype.tcpClose = function(socket) {
408 return this.tcpExec_({ 411 return this.tcpExec_({
409 name: 'tcp_close', 412 name: 'tcp_close',
410 socket: socket 413 socket: socket
411 }); 414 });
412 }; 415 };
OLDNEW
« no previous file with comments | « ports/devenv/io2014_test.py ('k') | ports/devenv/tests/demo2014_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698