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

Side by Side Diff: sandbox/linux/seccomp-bpf/syscall_unittest.cc

Issue 260793003: [MIPS] Add seccomp bpf support (Closed) Base URL: https://git.chromium.org/git/chromium/src.git@master
Patch Set: Update per code review Created 6 years, 6 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
OLDNEW
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 <asm/unistd.h> 5 #include <asm/unistd.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <sys/mman.h> 7 #include <sys/mman.h>
8 #include <sys/syscall.h> 8 #include <sys/syscall.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #if defined(__i386__) 43 #if defined(__i386__)
44 EXPECT_EQ(0x80CDu, ((uint16_t*)SandboxSyscall(-1))[-1]); // INT 0x80 44 EXPECT_EQ(0x80CDu, ((uint16_t*)SandboxSyscall(-1))[-1]); // INT 0x80
45 #elif defined(__x86_64__) 45 #elif defined(__x86_64__)
46 EXPECT_EQ(0x050Fu, ((uint16_t*)SandboxSyscall(-1))[-1]); // SYSCALL 46 EXPECT_EQ(0x050Fu, ((uint16_t*)SandboxSyscall(-1))[-1]); // SYSCALL
47 #elif defined(__arm__) 47 #elif defined(__arm__)
48 #if defined(__thumb__) 48 #if defined(__thumb__)
49 EXPECT_EQ(0xDF00u, ((uint16_t*)SandboxSyscall(-1))[-1]); // SWI 0 49 EXPECT_EQ(0xDF00u, ((uint16_t*)SandboxSyscall(-1))[-1]); // SWI 0
50 #else 50 #else
51 EXPECT_EQ(0xEF000000u, ((uint32_t*)SandboxSyscall(-1))[-1]); // SVC 0 51 EXPECT_EQ(0xEF000000u, ((uint32_t*)SandboxSyscall(-1))[-1]); // SVC 0
52 #endif 52 #endif
53 #elif defined(__mips__)
54 // Opcode for MIPS sycall is in the lower 16-bits
55 EXPECT_EQ(0x0cu, (((uint32_t *)SandboxSyscall(-1))[-1])&0x0000FFFF);
53 #else 56 #else
54 #warning Incomplete test case; need port for target platform 57 #warning Incomplete test case; need port for target platform
55 #endif 58 #endif
56 } 59 }
57 60
58 TEST(Syscall, TrivialSyscallNoArgs) { 61 TEST(Syscall, TrivialSyscallNoArgs) {
59 // Test that we can do basic system calls 62 // Test that we can do basic system calls
60 EXPECT_EQ(SandboxSyscall(__NR_getpid), syscall(__NR_getpid)); 63 EXPECT_EQ(SandboxSyscall(__NR_getpid), syscall(__NR_getpid));
61 } 64 }
62 65
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 197
195 // Clean up 198 // Clean up
196 EXPECT_EQ(0, SandboxSyscall(__NR_munmap, addr2, 8192L)); 199 EXPECT_EQ(0, SandboxSyscall(__NR_munmap, addr2, 8192L));
197 EXPECT_EQ(0, SandboxSyscall(__NR_munmap, addr3, 4096L)); 200 EXPECT_EQ(0, SandboxSyscall(__NR_munmap, addr3, 4096L));
198 EXPECT_EQ(0, IGNORE_EINTR(SandboxSyscall(__NR_close, fd))); 201 EXPECT_EQ(0, IGNORE_EINTR(SandboxSyscall(__NR_close, fd)));
199 } 202 }
200 203
201 } // namespace 204 } // namespace
202 205
203 } // namespace sandbox 206 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698