OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sandbox/linux/bpf_dsl/codegen.h" | 5 #include "sandbox/linux/bpf_dsl/codegen.h" |
6 | 6 |
7 #include <linux/filter.h> | |
8 | |
9 #include <map> | 7 #include <map> |
10 #include <utility> | 8 #include <utility> |
11 #include <vector> | 9 #include <vector> |
12 | 10 |
13 #include "base/macros.h" | 11 #include "base/macros.h" |
14 #include "base/md5.h" | 12 #include "base/md5.h" |
15 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 14 #include "sandbox/linux/system_headers/linux_filter.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
17 | 16 |
18 namespace sandbox { | 17 namespace sandbox { |
19 namespace { | 18 namespace { |
20 | 19 |
21 // Hash provides an abstraction for building "hash trees" from BPF | 20 // Hash provides an abstraction for building "hash trees" from BPF |
22 // control flow graphs, and efficiently identifying equivalent graphs. | 21 // control flow graphs, and efficiently identifying equivalent graphs. |
23 // | 22 // |
24 // For simplicity, we use MD5, because base happens to provide a | 23 // For simplicity, we use MD5, because base happens to provide a |
25 // convenient API for its use. However, any collision-resistant hash | 24 // convenient API for its use. However, any collision-resistant hash |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // Branching again to the same target nodes should require only one | 393 // Branching again to the same target nodes should require only one |
395 // new instruction, as we can reuse the previous branch's jumps. | 394 // new instruction, as we can reuse the previous branch's jumps. |
396 CodeGen::Node two = | 395 CodeGen::Node two = |
397 MakeInstruction(BPF_JMP + BPF_JEQ + BPF_K, 1, nodes[0], nodes[1]); | 396 MakeInstruction(BPF_JMP + BPF_JEQ + BPF_K, 1, nodes[0], nodes[1]); |
398 EXPECT_EQ(one + 1, two); // XXX: Implementation detail! | 397 EXPECT_EQ(one + 1, two); // XXX: Implementation detail! |
399 RunTest(two); | 398 RunTest(two); |
400 } | 399 } |
401 | 400 |
402 } // namespace | 401 } // namespace |
403 } // namespace sandbox | 402 } // namespace sandbox |
OLD | NEW |