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

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, 5 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 "sandbox/linux/seccomp-bpf/syscall.h" 5 #include "sandbox/linux/seccomp-bpf/syscall.h"
6 6
7 #include <asm/unistd.h> 7 #include <asm/unistd.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/mman.h> 9 #include <sys/mman.h>
10 #include <sys/syscall.h> 10 #include <sys/syscall.h>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #if defined(__i386__) 47 #if defined(__i386__)
48 EXPECT_EQ(0x80CDu, ((uint16_t*)Syscall::Call(-1))[-1]); // INT 0x80 48 EXPECT_EQ(0x80CDu, ((uint16_t*)Syscall::Call(-1))[-1]); // INT 0x80
49 #elif defined(__x86_64__) 49 #elif defined(__x86_64__)
50 EXPECT_EQ(0x050Fu, ((uint16_t*)Syscall::Call(-1))[-1]); // SYSCALL 50 EXPECT_EQ(0x050Fu, ((uint16_t*)Syscall::Call(-1))[-1]); // SYSCALL
51 #elif defined(__arm__) 51 #elif defined(__arm__)
52 #if defined(__thumb__) 52 #if defined(__thumb__)
53 EXPECT_EQ(0xDF00u, ((uint16_t*)Syscall::Call(-1))[-1]); // SWI 0 53 EXPECT_EQ(0xDF00u, ((uint16_t*)Syscall::Call(-1))[-1]); // SWI 0
54 #else 54 #else
55 EXPECT_EQ(0xEF000000u, ((uint32_t*)Syscall::Call(-1))[-1]); // SVC 0 55 EXPECT_EQ(0xEF000000u, ((uint32_t*)Syscall::Call(-1))[-1]); // SVC 0
56 #endif 56 #endif
57 #elif defined(__mips__)
58 // Opcode for MIPS sycall is in the lower 16-bits
59 EXPECT_EQ(0x0cu, (((uint32_t*)Syscall::Call(-1))[-1]) & 0x0000FFFF);
57 #else 60 #else
58 #warning Incomplete test case; need port for target platform 61 #warning Incomplete test case; need port for target platform
59 #endif 62 #endif
60 } 63 }
61 64
62 TEST(Syscall, TrivialSyscallNoArgs) { 65 TEST(Syscall, TrivialSyscallNoArgs) {
63 // Test that we can do basic system calls 66 // Test that we can do basic system calls
64 EXPECT_EQ(Syscall::Call(__NR_getpid), syscall(__NR_getpid)); 67 EXPECT_EQ(Syscall::Call(__NR_getpid), syscall(__NR_getpid));
65 } 68 }
66 69
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 210
208 // Clean up 211 // Clean up
209 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr2, 8192L)); 212 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr2, 8192L));
210 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr3, 4096L)); 213 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr3, 4096L));
211 EXPECT_EQ(0, IGNORE_EINTR(Syscall::Call(__NR_close, fd))); 214 EXPECT_EQ(0, IGNORE_EINTR(Syscall::Call(__NR_close, fd)));
212 } 215 }
213 216
214 } // namespace 217 } // namespace
215 218
216 } // namespace sandbox 219 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/syscall_iterator_unittest.cc ('k') | sandbox/linux/seccomp-bpf/trap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698