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

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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #if defined(__i386__) 45 #if defined(__i386__)
46 EXPECT_EQ(0x80CDu, ((uint16_t*)Syscall::Call(-1))[-1]); // INT 0x80 46 EXPECT_EQ(0x80CDu, ((uint16_t*)Syscall::Call(-1))[-1]); // INT 0x80
47 #elif defined(__x86_64__) 47 #elif defined(__x86_64__)
48 EXPECT_EQ(0x050Fu, ((uint16_t*)Syscall::Call(-1))[-1]); // SYSCALL 48 EXPECT_EQ(0x050Fu, ((uint16_t*)Syscall::Call(-1))[-1]); // SYSCALL
49 #elif defined(__arm__) 49 #elif defined(__arm__)
50 #if defined(__thumb__) 50 #if defined(__thumb__)
51 EXPECT_EQ(0xDF00u, ((uint16_t*)Syscall::Call(-1))[-1]); // SWI 0 51 EXPECT_EQ(0xDF00u, ((uint16_t*)Syscall::Call(-1))[-1]); // SWI 0
52 #else 52 #else
53 EXPECT_EQ(0xEF000000u, ((uint32_t*)Syscall::Call(-1))[-1]); // SVC 0 53 EXPECT_EQ(0xEF000000u, ((uint32_t*)Syscall::Call(-1))[-1]); // SVC 0
54 #endif 54 #endif
55 #elif defined(__mips__)
56 // Opcode for MIPS sycall is in the lower 16-bits
57 EXPECT_EQ(0x0cu, (((uint32_t*)Syscall::Call(-1))[-1]) & 0x0000FFFF);
55 #else 58 #else
56 #warning Incomplete test case; need port for target platform 59 #warning Incomplete test case; need port for target platform
57 #endif 60 #endif
58 } 61 }
59 62
60 TEST(Syscall, TrivialSyscallNoArgs) { 63 TEST(Syscall, TrivialSyscallNoArgs) {
61 // Test that we can do basic system calls 64 // Test that we can do basic system calls
62 EXPECT_EQ(Syscall::Call(__NR_getpid), syscall(__NR_getpid)); 65 EXPECT_EQ(Syscall::Call(__NR_getpid), syscall(__NR_getpid));
63 } 66 }
64 67
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 208
206 // Clean up 209 // Clean up
207 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr2, 8192L)); 210 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr2, 8192L));
208 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr3, 4096L)); 211 EXPECT_EQ(0, Syscall::Call(__NR_munmap, addr3, 4096L));
209 EXPECT_EQ(0, IGNORE_EINTR(Syscall::Call(__NR_close, fd))); 212 EXPECT_EQ(0, IGNORE_EINTR(Syscall::Call(__NR_close, fd)));
210 } 213 }
211 214
212 } // namespace 215 } // namespace
213 216
214 } // namespace sandbox 217 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698