Debian Codegraph @

tests/test.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 // Copyright 2014 The syscall.rs Project Developers. See the
2 // COPYRIGHT file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
•10 #![cfg(any(target_arch = "aarch64", target_arch = "riscv64", target_arch = "x86_64"))]
11
12 #[macro_use]
13 extern crate sc;
14
15 #[cfg(target_os = "linux")]
16 #[test]
17 fn ebadf() {
18 static MESSAGE: &'static str = "Hello, world!";
19
20 unsafe {
21 assert_eq!(syscall!(WRITE, 4, MESSAGE.as_ptr(), MESSAGE.len()) as isize,
22 -9)
23 }
24 }
25
26 // getpid() is POSIX but that doesn't guarantee it's a system call.
27 #[cfg(any(target_os = "linux", target_os = "freebsd"))]
28 #[test]
29 fn getpid() {
30 unsafe {
31 assert!(0 < sc::syscall0(sc::nr::GETPID));
32 }
33 }
34
35 #[cfg(any(target_os = "linux", target_os = "freebsd"))]
36 #[test]
37 fn getpid_macro() {
38 unsafe {
39 assert!(0 < syscall!(GETPID));
40 }
41 }