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

Side by Side Diff: src/trusted/validator_arm/validator_tests.cc

Issue 8275008: Make validator require read sandboxing on ARM. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « src/trusted/validator_arm/validator.cc ('k') | src/untrusted/stubs/setjmp_arm.S » ('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 2010 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can be
4 * be found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * Unit tests for the ARM validator 8 * Unit tests for the ARM validator
9 * 9 *
10 * These tests use the google-test framework (gtest for short) to exercise the 10 * These tests use the google-test framework (gtest for short) to exercise the
11 * ARM validator. The tests currently fall into two rough categories: 11 * ARM validator. The tests currently fall into two rough categories:
12 * 1. Simple method-level tests that exercise the validator's primitive 12 * 1. Simple method-level tests that exercise the validator's primitive
13 * capabilities, and 13 * capabilities, and
14 * 2. Instruction pattern tests that run the entire validator. 14 * 2. Instruction pattern tests that run the entire validator.
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 EXPECT_EQ(1U, problems.size()); 415 EXPECT_EQ(1U, problems.size());
416 if (problems.size() != 1) continue; 416 if (problems.size() != 1) continue;
417 417
418 ProblemRecord first = problems[0]; 418 ProblemRecord first = problems[0];
419 EXPECT_EQ(kDefaultBaseAddr + 4, first.vaddr) 419 EXPECT_EQ(kDefaultBaseAddr + 4, first.vaddr)
420 << "Problem report must point to the store: " 420 << "Problem report must point to the store: "
421 << message.str(); 421 << message.str();
422 EXPECT_EQ(nacl_arm_dec::MAY_BE_SAFE, first.safety) 422 EXPECT_EQ(nacl_arm_dec::MAY_BE_SAFE, first.safety)
423 << "Store should not be unsafe even though mask is bogus: " 423 << "Store should not be unsafe even though mask is bogus: "
424 << message.str(); 424 << message.str();
425 EXPECT_EQ(nacl::string(nacl_arm_val::kProblemUnsafeStore), 425 EXPECT_EQ(nacl::string(nacl_arm_val::kProblemUnsafeLoadStore),
426 first.problem_code) 426 first.problem_code)
427 << message; 427 << message;
428 } 428 }
429 } 429 }
430 } 430 }
431 } 431 }
432 432
433 TEST_F(ValidatorTests, InvalidGuardsOnSafeStores) { 433 TEST_F(ValidatorTests, InvalidGuardsOnSafeStores) {
434 static const AnnotatedInstruction invalid_guards[] = { 434 static const AnnotatedInstruction invalid_guards[] = {
435 { 0x03110100, "tst r1, #0: always sets Z" }, 435 { 0x03110100, "tst r1, #0: always sets Z" },
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 EXPECT_EQ(1U, problems.size()); 469 EXPECT_EQ(1U, problems.size());
470 if (problems.size() != 1) continue; 470 if (problems.size() != 1) continue;
471 471
472 ProblemRecord first = problems[0]; 472 ProblemRecord first = problems[0];
473 EXPECT_EQ(kDefaultBaseAddr + 4, first.vaddr) 473 EXPECT_EQ(kDefaultBaseAddr + 4, first.vaddr)
474 << "Problem report must point to the store: " 474 << "Problem report must point to the store: "
475 << message.str(); 475 << message.str();
476 EXPECT_EQ(nacl_arm_dec::MAY_BE_SAFE, first.safety) 476 EXPECT_EQ(nacl_arm_dec::MAY_BE_SAFE, first.safety)
477 << "Store should not be unsafe even though guard is bogus: " 477 << "Store should not be unsafe even though guard is bogus: "
478 << message.str(); 478 << message.str();
479 EXPECT_EQ(nacl::string(nacl_arm_val::kProblemUnsafeStore), 479 EXPECT_EQ(nacl::string(nacl_arm_val::kProblemUnsafeLoadStore),
480 first.problem_code) 480 first.problem_code)
481 << message; 481 << message;
482 } 482 }
483 } 483 }
484 } 484 }
485 485
486 TEST_F(ValidatorTests, ValidMasksOnUnsafeStores) { 486 TEST_F(ValidatorTests, ValidMasksOnUnsafeStores) {
487 static const AnnotatedInstruction invalid_stores[] = { 487 static const AnnotatedInstruction invalid_stores[] = {
488 { 0x07810002, "str r0, [r1, r2]: register-plus-register addressing" }, 488 { 0x07810002, "str r0, [r1, r2]: register-plus-register addressing" },
489 { 0x07010002, "str r0, [r1, -r2]: register-minus-register addressing" }, 489 { 0x07010002, "str r0, [r1, -r2]: register-minus-register addressing" },
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 522
523 ProblemRecord first = problems[0]; 523 ProblemRecord first = problems[0];
524 EXPECT_EQ(kDefaultBaseAddr + 4, first.vaddr) 524 EXPECT_EQ(kDefaultBaseAddr + 4, first.vaddr)
525 << "Problem report must point to the store: " 525 << "Problem report must point to the store: "
526 << message.str(); 526 << message.str();
527 EXPECT_NE(nacl_arm_dec::MAY_BE_SAFE, first.safety) 527 EXPECT_NE(nacl_arm_dec::MAY_BE_SAFE, first.safety)
528 << "Store must be flagged by the decoder as unsafe: " 528 << "Store must be flagged by the decoder as unsafe: "
529 << message.str(); 529 << message.str();
530 530
531 /* 531 /*
532 * Note that we expect kProblemUnsafe, *not* kProblemUnsafeStore. This 532 * Note that we expect kProblemUnsafe, *not* kProblemUnsafeLoadStore.
533 * is because the store instructions themselves, in isolation, are 533 * This is because the load/store instructions themselves, in
534 * unsafe to appear anywhere in a Native Client program -- whereas 534 * isolation, are unsafe to appear anywhere in a Native Client
535 * kProblemUnsafeStore indicates a legitimate store used in an unsafe 535 * program -- whereas kProblemUnsafeLoadStore indicates a legitimate
536 * manner. 536 * load/store used in an unsafe manner.
537 */ 537 */
538 EXPECT_EQ(nacl::string(nacl_arm_val::kProblemUnsafe), 538 EXPECT_EQ(nacl::string(nacl_arm_val::kProblemUnsafe),
539 first.problem_code) 539 first.problem_code)
540 << message; 540 << message;
541 } 541 }
542 } 542 }
543 } 543 }
544 } 544 }
545 545
546 TEST_F(ValidatorTests, ScaryUndefinedInstructions) { 546 TEST_F(ValidatorTests, ScaryUndefinedInstructions) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 return problems; 699 return problems;
700 } 700 }
701 701
702 }; // anonymous namespace 702 }; // anonymous namespace
703 703
704 // Test driver function. 704 // Test driver function.
705 int main(int argc, char *argv[]) { 705 int main(int argc, char *argv[]) {
706 testing::InitGoogleTest(&argc, argv); 706 testing::InitGoogleTest(&argc, argv);
707 return RUN_ALL_TESTS(); 707 return RUN_ALL_TESTS();
708 } 708 }
OLDNEW
« no previous file with comments | « src/trusted/validator_arm/validator.cc ('k') | src/untrusted/stubs/setjmp_arm.S » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698