From 8e26ab496429b0bb8f98041d63fffd20c03afc5d Mon Sep 17 00:00:00 2001
From: gnzlbg <gonzalobg88@gmail.com>
Date: Tue, 28 May 2019 16:07:46 +0200
Subject: [PATCH] Minor nitpicks

---
 libc-test/build.rs                 | 28 ++++++++++++++--------------
 libc-test/test/linux_elf.rs        |  4 +++-
 libc-test/test/linux_fcntl.rs      |  4 +++-
 libc-test/test/linux_ipv6.rs       |  4 +++-
 libc-test/test/linux_strerror_r.rs |  4 +++-
 libc-test/test/linux_termios.rs    |  4 +++-
 6 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/libc-test/build.rs b/libc-test/build.rs
index f7f8c7c1..e35dcb4e 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1428,7 +1428,7 @@ fn test_android(target: &str) {
 
     cfg.generate("../src/lib.rs", "main.rs");
 
-    test_linux_incompatible_apis(target);
+    test_linux_like_apis(target);
 }
 
 fn test_freebsd(target: &str) {
@@ -2241,17 +2241,19 @@ fn test_linux(target: &str) {
 
     cfg.generate("../src/lib.rs", "main.rs");
 
-    test_linux_incompatible_apis(target);
+    test_linux_like_apis(target);
 }
 
 // This function tests APIs that are incompatible to test when other APIs
 // are included (e.g. because including both sets of headers clashes)
-fn test_linux_incompatible_apis(target: &str) {
-    assert!(target.contains("linux") || target.contains("android"));
+fn test_linux_like_apis(target: &str) {
     let musl = target.contains("musl");
     let linux = target.contains("linux");
+    let emscripten = target.contains("emscripten");
+    let android = target.contains("android");
+    assert!(linux || android || emscripten);
 
-    {
+    if linux || android || emscripten {
         // test strerror_r from the `string.h` header
         let mut cfg = ctest::TestGenerator::new();
         cfg.skip_type(|_| true).skip_static(|_| true);
@@ -2265,7 +2267,8 @@ fn test_linux_incompatible_apis(target: &str) {
         .skip_struct(|_| true);
         cfg.generate("../src/lib.rs", "linux_strerror_r.rs");
     }
-    {
+
+    if linux || android || emscripten {
         // test fcntl - see:
         // http://man7.org/linux/man-pages/man2/fcntl.2.html
         let mut cfg = ctest::TestGenerator::new();
@@ -2295,7 +2298,8 @@ fn test_linux_incompatible_apis(target: &str) {
 
         cfg.generate("../src/lib.rs", "linux_fcntl.rs");
     }
-    {
+
+    if linux || android {
         // test termios
         let mut cfg = ctest::TestGenerator::new();
         cfg.header("asm/termbits.h");
@@ -2312,12 +2316,7 @@ fn test_linux_incompatible_apis(target: &str) {
         cfg.generate("../src/lib.rs", "linux_termios.rs");
     }
 
-    if !linux {
-        return;
-    }
-    // linux-only tests (no android):
-
-    {
+    if linux || android {
         // test IPV6_ constants:
         let mut cfg = ctest::TestGenerator::new();
         headers! {
@@ -2344,7 +2343,8 @@ fn test_linux_incompatible_apis(target: &str) {
             });
         cfg.generate("../src/lib.rs", "linux_ipv6.rs");
     }
-    {
+
+    if linux || android {
         // Test Elf64_Phdr and Elf32_Phdr
         // These types have a field called `p_type`, but including
         // "resolve.h" defines a `p_type` macro that expands to `__p_type`
diff --git a/libc-test/test/linux_elf.rs b/libc-test/test/linux_elf.rs
index 8744200e..d149c9aa 100644
--- a/libc-test/test/linux_elf.rs
+++ b/libc-test/test/linux_elf.rs
@@ -7,4 +7,6 @@ use libc::*;
 include!(concat!(env!("OUT_DIR"), "/linux_elf.rs"));
 
 #[cfg(not(target_os = "linux"))]
-fn main() { println!("PASSED 0 tests"); }
+fn main() {
+    println!("PASSED 0 tests");
+}
diff --git a/libc-test/test/linux_fcntl.rs b/libc-test/test/linux_fcntl.rs
index 915a87dc..49c06cc4 100644
--- a/libc-test/test/linux_fcntl.rs
+++ b/libc-test/test/linux_fcntl.rs
@@ -7,4 +7,6 @@ use libc::*;
 include!(concat!(env!("OUT_DIR"), "/linux_fcntl.rs"));
 
 #[cfg(not(any(target_os = "linux", target_os = "android")))]
-fn main() { println!("PASSED 0 tests"); }
+fn main() {
+    println!("PASSED 0 tests");
+}
diff --git a/libc-test/test/linux_ipv6.rs b/libc-test/test/linux_ipv6.rs
index c4d0965a..83c389ce 100644
--- a/libc-test/test/linux_ipv6.rs
+++ b/libc-test/test/linux_ipv6.rs
@@ -7,4 +7,6 @@ use libc::*;
 include!(concat!(env!("OUT_DIR"), "/linux_ipv6.rs"));
 
 #[cfg(not(target_os = "linux"))]
-fn main() { println!("PASSED 0 tests"); }
+fn main() {
+    println!("PASSED 0 tests");
+}
diff --git a/libc-test/test/linux_strerror_r.rs b/libc-test/test/linux_strerror_r.rs
index 5139175f..17db959d 100644
--- a/libc-test/test/linux_strerror_r.rs
+++ b/libc-test/test/linux_strerror_r.rs
@@ -7,4 +7,6 @@ use libc::*;
 include!(concat!(env!("OUT_DIR"), "/linux_strerror_r.rs"));
 
 #[cfg(not(any(target_os = "linux", target_os = "android")))]
-fn main() { println!("PASSED 0 tests"); }
+fn main() {
+    println!("PASSED 0 tests");
+}
diff --git a/libc-test/test/linux_termios.rs b/libc-test/test/linux_termios.rs
index 9ee47631..703a9b9b 100644
--- a/libc-test/test/linux_termios.rs
+++ b/libc-test/test/linux_termios.rs
@@ -7,4 +7,6 @@ use libc::*;
 include!(concat!(env!("OUT_DIR"), "/linux_termios.rs"));
 
 #[cfg(not(any(target_os = "linux", target_os = "android")))]
-fn main() { println!("PASSED 0 tests"); }
+fn main() {
+    println!("PASSED 0 tests");
+}
-- 
GitLab