diff options
author | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 21:02:09 +0000 |
---|---|---|
committer | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 21:02:09 +0000 |
commit | 606d7469d6da2cc63a7188b75059bd6e5fe1f82f (patch) | |
tree | 340e4dc42d3c40d145964877c620f607a9fc34a6 /sandbox/src/policy_low_level_unittest.cc | |
parent | 35c5886ee821ba615c512f5f310433e5d698b027 (diff) | |
download | chromium_src-606d7469d6da2cc63a7188b75059bd6e5fe1f82f.zip chromium_src-606d7469d6da2cc63a7188b75059bd6e5fe1f82f.tar.gz chromium_src-606d7469d6da2cc63a7188b75059bd6e5fe1f82f.tar.bz2 |
Fix a crash in the unittests caused by the fact that the order of
compilation of the files has changed.
Some tests were assuming that g_nt was already defined.
2/3 of the tests were calling SetupNtdllImports(), so I made
the rest call that too.
Review URL: http://codereview.chromium.org/113548
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16309 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/src/policy_low_level_unittest.cc')
-rw-r--r-- | sandbox/src/policy_low_level_unittest.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sandbox/src/policy_low_level_unittest.cc b/sandbox/src/policy_low_level_unittest.cc index 19d6656..20d1777 100644 --- a/sandbox/src/policy_low_level_unittest.cc +++ b/sandbox/src/policy_low_level_unittest.cc @@ -13,8 +13,11 @@ namespace sandbox { +bool SetupNtdllImports(); + // Testing that we allow opcode generation on valid string patterns. TEST(PolicyEngineTest, StringPatternsOK) { + SetupNtdllImports(); PolicyRule pr(ASK_BROKER); EXPECT_TRUE(pr.AddStringMatch(IF, 0, L"c:\\adobe\\ver??\\", CASE_SENSITIVE)); EXPECT_TRUE(pr.AddStringMatch(IF, 0, L"*.tmp", CASE_SENSITIVE)); @@ -26,6 +29,7 @@ TEST(PolicyEngineTest, StringPatternsOK) { // Testing that we signal invalid string patterns. TEST(PolicyEngineTest, StringPatternsBAD) { + SetupNtdllImports(); PolicyRule pr(ASK_BROKER); EXPECT_FALSE(pr.AddStringMatch(IF, 0, L"one**two", CASE_SENSITIVE)); EXPECT_FALSE(pr.AddStringMatch(IF, 0, L"**three", CASE_SENSITIVE)); @@ -46,6 +50,7 @@ PolicyGlobal* MakePolicyMemory() { // The simplest test using LowLevelPolicy it should test a single opcode which // does a exact string comparison. TEST(PolicyEngineTest, SimpleStrMatch) { + SetupNtdllImports(); PolicyRule pr(ASK_BROKER); EXPECT_TRUE(pr.AddStringMatch(IF, 0, L"z:\\Directory\\domo.txt", CASE_INSENSITIVE)); @@ -78,6 +83,7 @@ TEST(PolicyEngineTest, SimpleStrMatch) { } TEST(PolicyEngineTest, SimpleIfNotStrMatch) { + SetupNtdllImports(); PolicyRule pr(ASK_BROKER); EXPECT_TRUE(pr.AddStringMatch(IF_NOT, 0, L"c:\\Microsoft\\", CASE_SENSITIVE)); @@ -115,6 +121,7 @@ TEST(PolicyEngineTest, SimpleIfNotStrMatch) { } TEST(PolicyEngineTest, SimpleIfNotStrMatchWild1) { + SetupNtdllImports(); PolicyRule pr(ASK_BROKER); EXPECT_TRUE(pr.AddStringMatch(IF_NOT, 0, L"c:\\Microsoft\\*", CASE_SENSITIVE)); @@ -147,6 +154,7 @@ TEST(PolicyEngineTest, SimpleIfNotStrMatchWild1) { } TEST(PolicyEngineTest, SimpleIfNotStrMatchWild2) { + SetupNtdllImports(); PolicyRule pr(ASK_BROKER); EXPECT_TRUE(pr.AddStringMatch(IF_NOT, 0, L"c:\\Microsoft\\*.txt", CASE_SENSITIVE)); @@ -184,6 +192,7 @@ TEST(PolicyEngineTest, SimpleIfNotStrMatchWild2) { } TEST(PolicyEngineTest, IfNotStrMatchTwoRulesWild1) { + SetupNtdllImports(); PolicyRule pr(ASK_BROKER); EXPECT_TRUE(pr.AddStringMatch(IF_NOT, 0, L"c:\\Microsoft\\*", CASE_SENSITIVE)); @@ -231,6 +240,7 @@ TEST(PolicyEngineTest, IfNotStrMatchTwoRulesWild1) { } TEST(PolicyEngineTest, IfNotStrMatchTwoRulesWild2) { + SetupNtdllImports(); PolicyRule pr(ASK_BROKER); EXPECT_TRUE(pr.AddNumberMatch(IF, 1, 24, EQUAL)); EXPECT_TRUE(pr.AddStringMatch(IF_NOT, 0, L"c:\\GoogleV?\\*.txt", @@ -303,6 +313,7 @@ TEST(PolicyEngineTest, IfNotStrMatchTwoRulesWild2) { // Testing one single rule in one single service. The service is made to // resemble NtCreateFile. TEST(PolicyEngineTest, OneRuleTest) { + SetupNtdllImports(); PolicyRule pr(ASK_BROKER); EXPECT_TRUE(pr.AddStringMatch(IF, 0, L"c:\\*Microsoft*\\*.txt", CASE_SENSITIVE)); @@ -373,6 +384,7 @@ TEST(PolicyEngineTest, OneRuleTest) { // Testing 3 rules in 3 services. Two of the services resemble File services. TEST(PolicyEngineTest, ThreeRulesTest) { + SetupNtdllImports(); PolicyRule pr_pipe(FAKE_SUCCESS); EXPECT_TRUE(pr_pipe.AddStringMatch(IF, 0, L"\\\\/?/?\\Pipe\\Chrome.*", CASE_INSENSITIVE)); |