| 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/seccomp-bpf/syscall_iterator.h" | 5 #include "sandbox/linux/seccomp-bpf/syscall_iterator.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h" | 9 #include "sandbox/linux/seccomp-bpf/linux_seccomp.h" |
| 10 #include "sandbox/linux/tests/unit_tests.h" | 10 #include "sandbox/linux/tests/unit_tests.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 if (!SyscallSet::IsValid(sysnum)) { | 86 if (!SyscallSet::IsValid(sysnum)) { |
| 87 SANDBOX_ASSERT(i < arraysize(kExpected)); | 87 SANDBOX_ASSERT(i < arraysize(kExpected)); |
| 88 SANDBOX_ASSERT(kExpected[i] == sysnum); | 88 SANDBOX_ASSERT(kExpected[i] == sysnum); |
| 89 ++i; | 89 ++i; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 SANDBOX_ASSERT(i == arraysize(kExpected)); | 92 SANDBOX_ASSERT(i == arraysize(kExpected)); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 SANDBOX_TEST(SyscallIterator, ValidOnlyIsOnlyValid) { |
| 97 for (uint32_t sysnum : SyscallSet::ValidOnly()) { |
| 98 SANDBOX_ASSERT(SyscallSet::IsValid(sysnum)); |
| 99 } |
| 100 } |
| 101 |
| 96 SANDBOX_TEST(SyscallIterator, InvalidOnlyIsOnlyInvalid) { | 102 SANDBOX_TEST(SyscallIterator, InvalidOnlyIsOnlyInvalid) { |
| 97 for (uint32_t sysnum : SyscallSet::InvalidOnly()) { | 103 for (uint32_t sysnum : SyscallSet::InvalidOnly()) { |
| 98 SANDBOX_ASSERT(!SyscallSet::IsValid(sysnum)); | 104 SANDBOX_ASSERT(!SyscallSet::IsValid(sysnum)); |
| 99 } | 105 } |
| 100 } | 106 } |
| 101 | 107 |
| 108 SANDBOX_TEST(SyscallIterator, AllIsValidOnlyPlusInvalidOnly) { |
| 109 std::vector<uint32_t> merged; |
| 110 const SyscallSet valid_only = SyscallSet::ValidOnly(); |
| 111 const SyscallSet invalid_only = SyscallSet::InvalidOnly(); |
| 112 std::merge(valid_only.begin(), |
| 113 valid_only.end(), |
| 114 invalid_only.begin(), |
| 115 invalid_only.end(), |
| 116 std::back_inserter(merged)); |
| 117 |
| 118 const SyscallSet all = SyscallSet::All(); |
| 119 SANDBOX_ASSERT(merged == std::vector<uint32_t>(all.begin(), all.end())); |
| 120 } |
| 121 |
| 102 } // namespace | 122 } // namespace |
| 103 | 123 |
| 104 } // namespace sandbox | 124 } // namespace sandbox |
| OLD | NEW |