OLD | NEW |
| (Empty) |
1 /* | |
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 | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 /* globals TEST_F, ASSERT_EQ, ASSERT_TRUE, chrometest, DevEnvTest */ | |
8 | |
9 'use strict'; | |
10 | |
11 // Tests of the Google I/O 2014 tutorial at: | |
12 // https://developer.chrome.com/native-client/io2014 | |
13 | |
14 // Install the default packages. | |
15 // This test must be run before any tests that use these packages. | |
16 TEST_F(DevEnvTest, 'testDefaultPackageInstall', function() { | |
17 var self = this; | |
18 return Promise.resolve().then(function() { | |
19 return self.installDefaultPackages(); | |
20 }); | |
21 }); | |
22 | |
23 TEST_F(DevEnvTest, 'testDemo', function() { | |
24 // Test cat and rm. | |
25 var self = this; | |
26 var pid; | |
27 var bashrc = 'git config --global user.name "John Doe"\n' + | |
28 'git config --global user.email johndoe@example.com\n'; | |
29 var patch = | |
30 'diff --git a/voronoi.cc b/voronoi.cc\n' + | |
31 'index 897ec35..6e0b080 100644\n' + | |
32 '--- a/voronoi.cc\n' + | |
33 '+++ b/voronoi.cc\n' + | |
34 '@@ -503,7 +503,7 @@ void Voronoi::Update() {\n' + | |
35 ' if (NULL == ps_context_->data)\n' + | |
36 ' return;\n' + | |
37 ' assert(is_pow2(ps_context_->width));\n' + | |
38 '- assert(is_pow2(ps_context_->hieght));\n' + | |
39 '+ assert(is_pow2(ps_context_->height));\n' + | |
40 ' \n' + | |
41 " // When benchmarking is running, don't update display via\n" + | |
42 ' // PSContext2DSwapBuffer() - vsync is enabled by default,' + | |
43 ' and will throttle\n'; | |
44 return Promise.resolve().then(function() { | |
45 return self.initFileSystem(); | |
46 }).then(function() { | |
47 return self.writeFile('/home/user/.bashrc', bashrc); | |
48 }).then(function() { | |
49 return self.checkCommand('source ~/.bashrc'); | |
50 }).then(function() { | |
51 return self.checkCommand('mkdir work'); | |
52 }).then(function() { | |
53 return self.checkCommand( | |
54 'cd work && ' + | |
55 'curl http://nacltools.storage.googleapis.com/io2014/voronoi.zip -O'); | |
56 }).then(function() { | |
57 return self.checkCommand('cd work && ls', 0, 'voronoi.zip\n'); | |
58 }).then(function() { | |
59 return self.checkCommand('cd work && unzip voronoi.zip'); | |
60 }).then(function() { | |
61 return self.checkCommand('cd work/voronoi && ls Makefile', 0, 'Makefile\n'); | |
62 }).then(function() { | |
63 return self.checkCommand('cd work/voronoi && git init'); | |
64 }).then(function() { | |
65 return self.checkCommand('cd work/voronoi && git add .'); | |
66 }).then(function() { | |
67 return self.checkCommand( | |
68 'cd work/voronoi && git commit -m "imported voronoi demo"'); | |
69 }).then(function() { | |
70 return self.checkCommand('cd work/voronoi && make', 2); | |
71 }).then(function() { | |
72 return self.writeFile('/home/user/patch1', patch); | |
73 }).then(function() { | |
74 return self.checkCommand('cd work/voronoi && git apply ~/patch1'); | |
75 }).then(function() { | |
76 return self.checkCommand('cd work/voronoi && make -j10'); | |
77 }).then(function() { | |
78 return self.checkCommand( | |
79 'cd work/voronoi && git commit -am "fixed build error"'); | |
80 }).then(function() { | |
81 var sysArch = self.params['SYS_ARCH']; | |
82 var libDir; | |
83 var suffix; | |
84 if (sysArch === 'i686') { | |
85 libDir = 'lib32'; | |
86 suffix = 'x86_32'; | |
87 } else if (sysArch === 'x86_64') { | |
88 libDir = 'lib64'; | |
89 suffix = 'x86_64'; | |
90 } else { | |
91 ASSERT_TRUE(false, 'unknown arch: ' + sysArch); | |
92 } | |
93 return self.spawnCommand( | |
94 'cd work/voronoi && ' + | |
95 'LD_LIBRARY_PATH=' + libDir + ' ' + | |
96 'NACL_SPAWN_MODE=popup ' + | |
97 'NACL_POPUP_WIDTH=512 ' + | |
98 'NACL_POPUP_HEIGHT=512 ' + | |
99 './voronoi_' + suffix + '.nexe'); | |
100 }).then(function(msg) { | |
101 pid = msg.pid; | |
102 return chrometest.sleep(1000); | |
103 }).then(function(msg) { | |
104 self.sigint(); | |
105 return self.waitCommand(pid); | |
106 }).then(function(msg) { | |
107 ASSERT_EQ(128 + 9, msg.status, 'Expect kill status'); | |
108 }); | |
109 }); | |
OLD | NEW |