diff --git a/src/fn_call.rs b/src/fn_call.rs
index bb6d6aed49..64dcce161d 100644
--- a/src/fn_call.rs
+++ b/src/fn_call.rs
@@ -241,9 +241,11 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
                         // neither of which have any effect on our current PRNG
                         let _flags = this.read_scalar(args[3])?.to_i32()?;
 
-                        let data = gen_random(this, len as usize)?;
-                        this.memory_mut().get_mut(ptr.alloc_id)?
-                                    .write_bytes(tcx, ptr, &data)?;
+                        if len > 0 {
+                            let data = gen_random(this, len as usize)?;
+                            this.memory_mut().get_mut(ptr.alloc_id)?
+                                        .write_bytes(tcx, ptr, &data)?;
+                        }
 
                         this.write_scalar(Scalar::from_uint(len, dest.layout.size), dest)?;
                     }
@@ -622,6 +624,11 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
                 this.write_null(dest)?;
             }
 
+            // We don't support fork so we don't have to do anything for atfork.
+            "pthread_atfork" => {
+                this.write_null(dest)?;
+            }
+
             "mmap" => {
                 // This is a horrible hack, but since the guard page mechanism calls mmap and expects a particular return value, we just give it that value.
                 let addr = this.read_scalar(args[0])?.not_undef()?;
@@ -767,11 +774,13 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
             // The actual name of 'RtlGenRandom'
             "SystemFunction036" => {
                 let ptr = this.read_scalar(args[0])?.to_ptr()?;
-                let len = this.read_scalar(args[1])?.to_usize(this)?;
+                let len = this.read_scalar(args[1])?.to_u32()?;
 
-                let data = gen_random(this, len as usize)?;
-                this.memory_mut().get_mut(ptr.alloc_id)?
-                    .write_bytes(tcx, ptr, &data)?;
+                if len > 0 {
+                    let data = gen_random(this, len as usize)?;
+                    this.memory_mut().get_mut(ptr.alloc_id)?
+                        .write_bytes(tcx, ptr, &data)?;
+                }
 
                 this.write_scalar(Scalar::from_bool(true), dest)?;
             }
diff --git a/test-cargo-miri/run-test.py b/test-cargo-miri/run-test.py
index 8c59b6bcde..f1412dbf39 100755
--- a/test-cargo-miri/run-test.py
+++ b/test-cargo-miri/run-test.py
@@ -43,7 +43,7 @@ def test_cargo_miri_run():
     )
 
 def test_cargo_miri_test():
-    test("cargo miri test", ["cargo", "miri", "test", "-q"], "test.stdout.ref", "test.stderr.ref")
+    test("cargo miri test", ["cargo", "miri", "test", "-q", "--", "-Zmiri-seed=feed"], "test.stdout.ref", "test.stderr.ref")
     test("cargo miri test (with filter)",
         ["cargo", "miri", "test", "-q", "--", "--", "impl"],
         "test.stdout.ref2", "test.stderr.ref"
diff --git a/test-cargo-miri/test.stdout.ref b/test-cargo-miri/test.stdout.ref
index 9c3621f215..97589e9a16 100644
--- a/test-cargo-miri/test.stdout.ref
+++ b/test-cargo-miri/test.stdout.ref
@@ -5,9 +5,10 @@ test test::rng ... ok
 test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
 
 
-running 2 tests
-test rng ... ok
+running 3 tests
+test entropy_rng ... ok
+test fixed_rng ... ok
 test simple ... ok
 
-test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
+test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
 
diff --git a/test-cargo-miri/test.stdout.ref2 b/test-cargo-miri/test.stdout.ref2
index ce3506709d..32d943623a 100644
--- a/test-cargo-miri/test.stdout.ref2
+++ b/test-cargo-miri/test.stdout.ref2
@@ -7,5 +7,5 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
 running 1 test
 test simple ... ok
 
-test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out
 
diff --git a/test-cargo-miri/tests/test.rs b/test-cargo-miri/tests/test.rs
index e9faaf2fb2..69a31c42a7 100644
--- a/test-cargo-miri/tests/test.rs
+++ b/test-cargo-miri/tests/test.rs
@@ -1,6 +1,8 @@
+#![allow(unused_imports)] // FIXME for macOS
+
 extern crate rand;
 
-use rand::{Rng, SeedableRng};
+use rand::{SeedableRng, FromEntropy, Rng, rngs::SmallRng};
 
 #[test]
 fn simple() {
@@ -10,13 +12,28 @@ fn simple() {
 // Having more than 1 test does seem to make a difference
 // (i.e., this calls ptr::swap which having just one test does not).
 #[test]
-fn rng() {
+fn fixed_rng() {
     let mut rng = rand::rngs::StdRng::seed_from_u64(0xdeadcafe);
     let x: u32 = rng.gen();
     let y: u32 = rng.gen();
     assert_ne!(x, y);
 }
 
+#[test]
+fn entropy_rng() {
+    #[cfg(not(target_os="macos"))] // FIXME entropy does not work on macOS
+    // (Not disabling the entire test as that would change the output.)
+    {
+        // Use this opportunity to test querying the RNG (needs an external crate, hence tested here and not in the compiletest suite)
+        let mut rng = SmallRng::from_entropy();
+        let _val = rng.gen::<i32>();
+
+        // Also try per-thread RNG.
+        let mut rng = rand::thread_rng();
+        let _val = rng.gen::<i32>();
+    }
+}
+
 // A test that won't work on miri
 #[cfg(not(miri))]
 #[test]
diff --git a/tests/compile-fail/getrandom.rs b/tests/compile-fail/getrandom.rs
index 4dc3e863aa..d54c95c823 100644
--- a/tests/compile-fail/getrandom.rs
+++ b/tests/compile-fail/getrandom.rs
@@ -1,5 +1,5 @@
-// ignore-macos
-// ignore-windows
+// ignore-macos: Uses Linux-only APIs
+// ignore-windows: Uses Linux-only APIs
 
 #![feature(rustc_private)]
 extern crate libc;
diff --git a/tests/run-pass/hashmap.rs b/tests/run-pass/hashmap.rs
index b29b681939..796e63c81a 100644
--- a/tests/run-pass/hashmap.rs
+++ b/tests/run-pass/hashmap.rs
@@ -27,12 +27,13 @@ fn test_map<S: BuildHasher>(mut map: HashMap<i32, i32, S>) {
 }
 
 fn main() {
-    // TODO: Implement random number generation on OS X
     if cfg!(not(target_os = "macos")) {
-        let map_normal: HashMap<i32, i32> = HashMap::new();
-        test_map(map_normal);
+        let map: HashMap<i32, i32> = HashMap::default();
+        test_map(map);
     } else {
-        let map : HashMap<i32, i32, BuildHasherDefault<collections::hash_map::DefaultHasher>> = Default::default();
+        // TODO: Implement random number generation on OS X.
+        // Until then, use a deterministic map.
+        let map : HashMap<i32, i32, BuildHasherDefault<collections::hash_map::DefaultHasher>> = HashMap::default();
         test_map(map);
     }
 }