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

Side by Side Diff: components/nacl/browser/pnacl_translation_cache_unittest.cc

Issue 163433015: Add sandbox ISA and extra compile flag fields to PNaCl translation cache key (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/nacl/browser/pnacl_translation_cache.h" 5 #include "components/nacl/browser/pnacl_translation_cache.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 static const std::string test_key("1"); 121 static const std::string test_key("1");
122 static const std::string test_store_val("testnexe"); 122 static const std::string test_store_val("testnexe");
123 static const int kLargeNexeSize = 8 * 1024 * 1024; 123 static const int kLargeNexeSize = 8 * 1024 * 1024;
124 124
125 TEST(PnaclTranslationCacheKeyTest, CacheKeyTest) { 125 TEST(PnaclTranslationCacheKeyTest, CacheKeyTest) {
126 nacl::PnaclCacheInfo info; 126 nacl::PnaclCacheInfo info;
127 info.pexe_url = GURL("http://www.google.com"); 127 info.pexe_url = GURL("http://www.google.com");
128 info.abi_version = 0; 128 info.abi_version = 0;
129 info.opt_level = 0; 129 info.opt_level = 0;
130 info.sandbox_isa = "x86-32";
130 std::string test_time("Wed, 15 Nov 1995 06:25:24 GMT"); 131 std::string test_time("Wed, 15 Nov 1995 06:25:24 GMT");
131 base::Time::FromString(test_time.c_str(), &info.last_modified); 132 base::Time::FromString(test_time.c_str(), &info.last_modified);
132 // Basic check for URL and time components 133 // Basic check for URL and time components
133 EXPECT_EQ("ABI:0;opt:0;URL:http://www.google.com/;" 134 EXPECT_EQ("ABI:0;opt:0;URL:http://www.google.com/;"
134 "modified:1995:11:15:6:25:24:0:UTC;etag:", 135 "modified:1995:11:15:6:25:24:0:UTC;etag:;"
136 "sandbox:x86-32;extra_flags:;",
135 PnaclTranslationCache::GetKey(info)); 137 PnaclTranslationCache::GetKey(info));
136 // Check that query portion of URL is not stripped 138 // Check that query portion of URL is not stripped
137 info.pexe_url = GURL("http://www.google.com/?foo=bar"); 139 info.pexe_url = GURL("http://www.google.com/?foo=bar");
138 EXPECT_EQ("ABI:0;opt:0;URL:http://www.google.com/?foo=bar;" 140 EXPECT_EQ("ABI:0;opt:0;URL:http://www.google.com/?foo=bar;"
139 "modified:1995:11:15:6:25:24:0:UTC;etag:", 141 "modified:1995:11:15:6:25:24:0:UTC;etag:;"
142 "sandbox:x86-32;extra_flags:;",
140 PnaclTranslationCache::GetKey(info)); 143 PnaclTranslationCache::GetKey(info));
141 // Check that username, password, and normal port are stripped 144 // Check that username, password, and normal port are stripped
142 info.pexe_url = GURL("https://user:host@www.google.com:443/"); 145 info.pexe_url = GURL("https://user:host@www.google.com:443/");
143 EXPECT_EQ("ABI:0;opt:0;URL:https://www.google.com/;" 146 EXPECT_EQ("ABI:0;opt:0;URL:https://www.google.com/;"
144 "modified:1995:11:15:6:25:24:0:UTC;etag:", 147 "modified:1995:11:15:6:25:24:0:UTC;etag:;"
148 "sandbox:x86-32;extra_flags:;",
145 PnaclTranslationCache::GetKey(info)); 149 PnaclTranslationCache::GetKey(info));
146 // Check that unusual port is not stripped but ref is stripped 150 // Check that unusual port is not stripped but ref is stripped
147 info.pexe_url = GURL("https://www.google.com:444/#foo"); 151 info.pexe_url = GURL("https://www.google.com:444/#foo");
148 EXPECT_EQ("ABI:0;opt:0;URL:https://www.google.com:444/;" 152 EXPECT_EQ("ABI:0;opt:0;URL:https://www.google.com:444/;"
149 "modified:1995:11:15:6:25:24:0:UTC;etag:", 153 "modified:1995:11:15:6:25:24:0:UTC;etag:;"
154 "sandbox:x86-32;extra_flags:;",
150 PnaclTranslationCache::GetKey(info)); 155 PnaclTranslationCache::GetKey(info));
151 // Check chrome-extesnsion scheme 156 // Check chrome-extesnsion scheme
152 info.pexe_url = GURL("chrome-extension://ljacajndfccfgnfohlgkdphmbnpkjflk/"); 157 info.pexe_url = GURL("chrome-extension://ljacajndfccfgnfohlgkdphmbnpkjflk/");
153 EXPECT_EQ("ABI:0;opt:0;" 158 EXPECT_EQ("ABI:0;opt:0;"
154 "URL:chrome-extension://ljacajndfccfgnfohlgkdphmbnpkjflk/;" 159 "URL:chrome-extension://ljacajndfccfgnfohlgkdphmbnpkjflk/;"
155 "modified:1995:11:15:6:25:24:0:UTC;etag:", 160 "modified:1995:11:15:6:25:24:0:UTC;etag:;"
161 "sandbox:x86-32;extra_flags:;",
156 PnaclTranslationCache::GetKey(info)); 162 PnaclTranslationCache::GetKey(info));
157 // Check that ABI version, opt level, and etag are in the key 163 // Check that ABI version, opt level, and etag are in the key
158 info.pexe_url = GURL("http://www.google.com/"); 164 info.pexe_url = GURL("http://www.google.com/");
159 info.abi_version = 2; 165 info.abi_version = 2;
160 EXPECT_EQ("ABI:2;opt:0;URL:http://www.google.com/;" 166 EXPECT_EQ("ABI:2;opt:0;URL:http://www.google.com/;"
161 "modified:1995:11:15:6:25:24:0:UTC;etag:", 167 "modified:1995:11:15:6:25:24:0:UTC;etag:;"
168 "sandbox:x86-32;extra_flags:;",
162 PnaclTranslationCache::GetKey(info)); 169 PnaclTranslationCache::GetKey(info));
163 info.opt_level = 2; 170 info.opt_level = 2;
164 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;" 171 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;"
165 "modified:1995:11:15:6:25:24:0:UTC;etag:", 172 "modified:1995:11:15:6:25:24:0:UTC;etag:;"
173 "sandbox:x86-32;extra_flags:;",
166 PnaclTranslationCache::GetKey(info)); 174 PnaclTranslationCache::GetKey(info));
167 info.etag = std::string("etag"); 175 info.etag = std::string("etag");
168 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;" 176 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;"
169 "modified:1995:11:15:6:25:24:0:UTC;etag:etag", 177 "modified:1995:11:15:6:25:24:0:UTC;etag:etag;"
178 "sandbox:x86-32;extra_flags:;",
170 PnaclTranslationCache::GetKey(info)); 179 PnaclTranslationCache::GetKey(info));
171 180
172 // Check for all the time components, and null time 181 // Check for all the time components, and null time
173 info.last_modified = base::Time(); 182 info.last_modified = base::Time();
174 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;" 183 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;"
175 "modified:0:0:0:0:0:0:0:UTC;etag:etag", 184 "modified:0:0:0:0:0:0:0:UTC;etag:etag;"
185 "sandbox:x86-32;extra_flags:;",
176 PnaclTranslationCache::GetKey(info)); 186 PnaclTranslationCache::GetKey(info));
177 test_time.assign("Fri, 29 Feb 2008 13:04:12 GMT"); 187 test_time.assign("Fri, 29 Feb 2008 13:04:12 GMT");
178 base::Time::FromString(test_time.c_str(), &info.last_modified); 188 base::Time::FromString(test_time.c_str(), &info.last_modified);
179 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;" 189 EXPECT_EQ("ABI:2;opt:2;URL:http://www.google.com/;"
180 "modified:2008:2:29:13:4:12:0:UTC;etag:etag", 190 "modified:2008:2:29:13:4:12:0:UTC;etag:etag;"
191 "sandbox:x86-32;extra_flags:;",
181 PnaclTranslationCache::GetKey(info)); 192 PnaclTranslationCache::GetKey(info));
jvoung (off chromium) 2014/02/15 02:07:27 maybe add a test where info.extra_flags is actuall
Derek Schuff 2014/02/15 05:59:18 Done.
182 } 193 }
183 194
184 TEST_F(PnaclTranslationCacheTest, StoreSmallInMem) { 195 TEST_F(PnaclTranslationCacheTest, StoreSmallInMem) {
185 // Test that a single store puts something in the mem backend 196 // Test that a single store puts something in the mem backend
186 InitBackend(true); 197 InitBackend(true);
187 StoreNexe(test_key, test_store_val); 198 StoreNexe(test_key, test_store_val);
188 EXPECT_EQ(1, cache_->Size()); 199 EXPECT_EQ(1, cache_->Size());
189 } 200 }
190 201
191 TEST_F(PnaclTranslationCacheTest, StoreSmallOnDisk) { 202 TEST_F(PnaclTranslationCacheTest, StoreSmallOnDisk) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 StoreNexe(test_key, test_store_val); 271 StoreNexe(test_key, test_store_val);
261 TestNexeCallback load_cb; 272 TestNexeCallback load_cb;
262 std::string nexe; 273 std::string nexe;
263 cache_->GetNexe(test_key + "a", load_cb.callback()); 274 cache_->GetNexe(test_key + "a", load_cb.callback());
264 int rv; 275 int rv;
265 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv)); 276 scoped_refptr<net::DrainableIOBuffer> buf(load_cb.GetResult(&rv));
266 EXPECT_EQ(net::ERR_FAILED, rv); 277 EXPECT_EQ(net::ERR_FAILED, rv);
267 } 278 }
268 279
269 } // namespace pnacl 280 } // namespace pnacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698