summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-02-10 17:19:52 +0000
committerGitHub <noreply@github.com>2023-02-10 17:19:52 +0000
commitfe44e006729c318897ca6e6090f183fab81a3326 (patch)
treee19387c8f60550a94687460235e71c87e6cfeff7
parent50aa471f9c38dc214dd86f3cad78a0e6b1065af5 (diff)
parent36937a72e0f50d95f2402e9c3e4316014765c8cc (diff)
-rw-r--r--Cargo.lock193
-rw-r--r--bindgen-tests/tests/quickchecking/Cargo.toml3
-rw-r--r--bindgen-tests/tests/quickchecking/src/bin.rs3
-rw-r--r--bindgen-tests/tests/quickchecking/src/fuzzers.rs51
-rw-r--r--bindgen-tests/tests/quickchecking/src/lib.rs14
-rw-r--r--bindgen-tests/tests/quickchecking/tests/fuzzed-c-headers.rs33
6 files changed, 112 insertions, 185 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 5517f93d..81941183 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,20 +4,11 @@ version = 3
[[package]]
name = "aho-corasick"
-version = "0.5.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66"
-dependencies = [
- "memchr 0.1.11",
-]
-
-[[package]]
-name = "aho-corasick"
version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [
- "memchr 2.5.0",
+ "memchr",
]
[[package]]
@@ -26,7 +17,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -37,7 +28,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi 0.1.19",
"libc",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -49,11 +40,11 @@ dependencies = [
"clang-sys",
"lazy_static",
"lazycell",
- "log 0.4.17",
+ "log",
"peeking_take_while",
"proc-macro2",
"quote",
- "regex 1.7.1",
+ "regex",
"rustc-hash",
"shlex",
"syn",
@@ -67,7 +58,7 @@ dependencies = [
"bindgen",
"clap 4.1.4",
"env_logger 0.9.3",
- "log 0.4.17",
+ "log",
"shlex",
]
@@ -200,12 +191,12 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
name = "env_logger"
-version = "0.3.5"
+version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f"
+checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [
- "log 0.3.9",
- "regex 0.1.80",
+ "log",
+ "regex",
]
[[package]]
@@ -216,8 +207,8 @@ checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
dependencies = [
"atty",
"humantime",
- "log 0.4.17",
- "regex 1.7.1",
+ "log",
+ "regex",
"termcolor",
]
@@ -229,7 +220,7 @@ checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
dependencies = [
"errno-dragonfly",
"libc",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -258,6 +249,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
+name = "getrandom"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -325,16 +327,6 @@ dependencies = [
]
[[package]]
-name = "kernel32-sys"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-dependencies = [
- "winapi 0.2.8",
- "winapi-build",
-]
-
-[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -359,7 +351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883"
dependencies = [
"cfg-if",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -369,7 +361,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -380,15 +372,6 @@ checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
[[package]]
name = "log"
-version = "0.3.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
-dependencies = [
- "log 0.4.17",
-]
-
-[[package]]
-name = "log"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
@@ -407,15 +390,6 @@ dependencies = [
[[package]]
name = "memchr"
-version = "0.1.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
-dependencies = [
- "libc",
-]
-
-[[package]]
-name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
@@ -432,7 +406,7 @@ version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
- "memchr 2.5.0",
+ "memchr",
"minimal-lexical",
]
@@ -498,13 +472,13 @@ dependencies = [
[[package]]
name = "quickcheck"
-version = "0.4.1"
+version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "02c2411d418cea2364325b18a205664f9ef8252e06b2e911db97c0b0d98b1406"
+checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
dependencies = [
- "env_logger 0.3.5",
- "log 0.3.9",
- "rand 0.3.23",
+ "env_logger 0.8.4",
+ "log",
+ "rand 0.8.5",
]
[[package]]
@@ -514,7 +488,6 @@ dependencies = [
"clap 2.34.0",
"lazy_static",
"quickcheck",
- "rand 0.3.23",
"tempdir",
]
@@ -529,25 +502,24 @@ dependencies = [
[[package]]
name = "rand"
-version = "0.3.23"
+version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c"
+checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
dependencies = [
+ "fuchsia-cprng",
"libc",
- "rand 0.4.6",
+ "rand_core 0.3.1",
+ "rdrand",
+ "winapi",
]
[[package]]
name = "rand"
-version = "0.4.6"
+version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
+checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
- "fuchsia-cprng",
- "libc",
- "rand_core 0.3.1",
- "rdrand",
- "winapi 0.3.9",
+ "rand_core 0.6.4",
]
[[package]]
@@ -566,6 +538,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
+name = "rand_core"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -585,36 +566,17 @@ dependencies = [
[[package]]
name = "regex"
-version = "0.1.80"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
-dependencies = [
- "aho-corasick 0.5.3",
- "memchr 0.1.11",
- "regex-syntax 0.3.9",
- "thread_local",
- "utf8-ranges",
-]
-
-[[package]]
-name = "regex"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
dependencies = [
- "aho-corasick 0.7.20",
- "memchr 2.5.0",
- "regex-syntax 0.6.28",
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
]
[[package]]
name = "regex-syntax"
-version = "0.3.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
-
-[[package]]
-name = "regex-syntax"
version = "0.6.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
@@ -625,7 +587,7 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -698,7 +660,7 @@ dependencies = [
"libc",
"redox_syscall",
"remove_dir_all",
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
@@ -729,25 +691,6 @@ dependencies = [
]
[[package]]
-name = "thread-id"
-version = "2.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
-dependencies = [
- "kernel32-sys",
- "libc",
-]
-
-[[package]]
-name = "thread_local"
-version = "0.2.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
-dependencies = [
- "thread-id",
-]
-
-[[package]]
name = "unicode-ident"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -760,12 +703,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
[[package]]
-name = "utf8-ranges"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
-
-[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -778,6 +715,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
+name = "wasi"
+version = "0.11.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+
+[[package]]
name = "which"
version = "4.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -790,12 +733,6 @@ dependencies = [
[[package]]
name = "winapi"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
-
-[[package]]
-name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
@@ -805,12 +742,6 @@ dependencies = [
]
[[package]]
-name = "winapi-build"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
-
-[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -822,7 +753,7 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
- "winapi 0.3.9",
+ "winapi",
]
[[package]]
diff --git a/bindgen-tests/tests/quickchecking/Cargo.toml b/bindgen-tests/tests/quickchecking/Cargo.toml
index 455a8240..b579d4ea 100644
--- a/bindgen-tests/tests/quickchecking/Cargo.toml
+++ b/bindgen-tests/tests/quickchecking/Cargo.toml
@@ -15,8 +15,7 @@ path = "src/bin.rs"
[dependencies]
clap = "2.28"
lazy_static = "1.0"
-quickcheck = "0.4"
-rand = "0.3"
+quickcheck = "1.0"
tempdir = "0.3"
[features]
diff --git a/bindgen-tests/tests/quickchecking/src/bin.rs b/bindgen-tests/tests/quickchecking/src/bin.rs
index f2b52e82..7c189ee8 100644
--- a/bindgen-tests/tests/quickchecking/src/bin.rs
+++ b/bindgen-tests/tests/quickchecking/src/bin.rs
@@ -105,8 +105,7 @@ fn main() {
let output_path: Option<&str> = matches.value_of("path");
let generate_range: usize =
matches.value_of("range").unwrap().parse::<usize>().unwrap();
- let tests: usize =
- matches.value_of("count").unwrap().parse::<usize>().unwrap();
+ let tests: u64 = matches.value_of("count").unwrap().parse::<u64>().unwrap();
quickchecking::test_bindgen(generate_range, tests, output_path)
}
diff --git a/bindgen-tests/tests/quickchecking/src/fuzzers.rs b/bindgen-tests/tests/quickchecking/src/fuzzers.rs
index 4188f8f5..003e9bf3 100644
--- a/bindgen-tests/tests/quickchecking/src/fuzzers.rs
+++ b/bindgen-tests/tests/quickchecking/src/fuzzers.rs
@@ -1,5 +1,4 @@
-use quickcheck::{Arbitrary, Gen, StdGen};
-use rand::thread_rng;
+use quickcheck::{Arbitrary, Gen};
use std::fmt;
/// BaseTypeC is used in generation of C headers to represent the C language's
@@ -182,8 +181,8 @@ impl MakeUnique for DeclarationC {
/// A qucickcheck trait for describing how DeclarationC types can be
/// randomly generated and shrunk.
impl Arbitrary for DeclarationC {
- fn arbitrary<G: Gen>(g: &mut G) -> DeclarationC {
- match g.gen_range(0, 5) {
+ fn arbitrary(g: &mut Gen) -> DeclarationC {
+ match gen_range(g, 0, 5) {
0 => DeclarationC::FunctionDecl(FunctionPrototypeC::arbitrary(g)),
1 => DeclarationC::FunctionPtrDecl(
FunctionPointerDeclarationC::arbitrary(g),
@@ -214,7 +213,7 @@ impl fmt::Display for DeclarationC {
/// A qucickcheck trait for describing how DeclarationListC types can be
/// randomly generated and shrunk.
impl Arbitrary for DeclarationListC {
- fn arbitrary<G: Gen>(g: &mut G) -> DeclarationListC {
+ fn arbitrary(g: &mut Gen) -> DeclarationListC {
DeclarationListC {
decls: Arbitrary::arbitrary(g),
}
@@ -235,7 +234,7 @@ impl fmt::Display for DeclarationListC {
/// A qucickcheck trait for describing how BaseTypeC types can be
/// randomly generated and shrunk.
impl Arbitrary for BaseTypeC {
- fn arbitrary<G: Gen>(g: &mut G) -> BaseTypeC {
+ fn arbitrary(g: &mut Gen) -> BaseTypeC {
// Special case `long double` until issue #550 is resolved.
let base_type = vec![
"char",
@@ -286,7 +285,7 @@ impl fmt::Display for BaseTypeC {
/// A qucickcheck trait for describing how TypeQualifierC types can be
/// randomly generated and shrunk.
impl Arbitrary for TypeQualifierC {
- fn arbitrary<G: Gen>(g: &mut G) -> TypeQualifierC {
+ fn arbitrary(g: &mut Gen) -> TypeQualifierC {
let qualifier = vec!["const", ""];
TypeQualifierC {
def: String::from(*g.choose(&qualifier).unwrap()),
@@ -304,10 +303,10 @@ impl fmt::Display for TypeQualifierC {
/// A qucickcheck trait for describing how PointerLevelC types can be
/// randomly generated and shrunk.
impl Arbitrary for PointerLevelC {
- fn arbitrary<G: Gen>(g: &mut G) -> PointerLevelC {
+ fn arbitrary(g: &mut Gen) -> PointerLevelC {
PointerLevelC {
// 16 is an arbitrary "not too big" number for capping pointer level.
- def: (0..g.gen_range(0, 16)).map(|_| "*").collect::<String>(),
+ def: (0..gen_range(g, 0, 16)).map(|_| "*").collect::<String>(),
}
}
}
@@ -322,16 +321,16 @@ impl fmt::Display for PointerLevelC {
/// A qucickcheck trait for describing how ArrayDimensionC types can be
/// randomly generated and shrunk.
impl Arbitrary for ArrayDimensionC {
- fn arbitrary<G: Gen>(g: &mut G) -> ArrayDimensionC {
+ fn arbitrary(g: &mut Gen) -> ArrayDimensionC {
// Keep these small, clang complains when they get too big.
- let dimensions = g.gen_range(0, 5);
+ let dimensions = gen_range(g, 0, 5);
let mut def = String::new();
- let lower_bound = i32::from(cfg!(feature = "zero-sized-arrays"));
+ let lower_bound = u64::from(cfg!(feature = "zero-sized-arrays"));
for _ in 1..dimensions {
// 16 is an arbitrary "not too big" number for capping array size.
- def += &format!("[{}]", g.gen_range(lower_bound, 16));
+ def += &format!("[{}]", gen_range(g, lower_bound, 16));
}
ArrayDimensionC { def }
}
@@ -355,7 +354,7 @@ impl MakeUnique for BasicTypeDeclarationC {
/// A qucickcheck trait for describing how BasicTypeDeclarationC types can be
/// randomly generated and shrunk.
impl Arbitrary for BasicTypeDeclarationC {
- fn arbitrary<G: Gen>(g: &mut G) -> BasicTypeDeclarationC {
+ fn arbitrary(g: &mut Gen) -> BasicTypeDeclarationC {
BasicTypeDeclarationC {
type_qualifier: Arbitrary::arbitrary(g),
type_name: Arbitrary::arbitrary(g),
@@ -392,12 +391,12 @@ impl MakeUnique for StructDeclarationC {
/// A qucickcheck trait for describing how StructDeclarationC types can be
/// randomly generated and shrunk.
impl Arbitrary for StructDeclarationC {
- fn arbitrary<G: Gen>(g: &mut G) -> StructDeclarationC {
+ fn arbitrary(g: &mut Gen) -> StructDeclarationC {
// Reduce generator size as a method of putting a bound on recursion.
// When size < 1 the empty list is generated.
let reduced_size: usize = (g.size() / 2) + 1;
let mut decl_list: DeclarationListC =
- Arbitrary::arbitrary(&mut StdGen::new(thread_rng(), reduced_size));
+ Arbitrary::arbitrary(&mut Gen::new(reduced_size));
let mut fields: DeclarationListC = DeclarationListC { decls: vec![] };
for (i, decl) in decl_list.decls.iter_mut().enumerate() {
@@ -440,12 +439,12 @@ impl MakeUnique for UnionDeclarationC {
/// A qucickcheck trait for describing how UnionDeclarationC types can be
/// randomly generated and shrunk.
impl Arbitrary for UnionDeclarationC {
- fn arbitrary<G: Gen>(g: &mut G) -> UnionDeclarationC {
+ fn arbitrary(g: &mut Gen) -> UnionDeclarationC {
// Reduce generator size as a method of putting a bound on recursion.
// When size < 1 the empty list is generated.
let reduced_size: usize = (g.size() / 2) + 1;
let mut decl_list: DeclarationListC =
- Arbitrary::arbitrary(&mut StdGen::new(thread_rng(), reduced_size));
+ Arbitrary::arbitrary(&mut Gen::new(reduced_size));
let mut fields: DeclarationListC = DeclarationListC { decls: vec![] };
for (i, decl) in decl_list.decls.iter_mut().enumerate() {
@@ -488,7 +487,7 @@ impl MakeUnique for FunctionPointerDeclarationC {
/// A qucickcheck trait for describing how FunctionPointerDeclarationC types can
/// be randomly generated and shrunk.
impl Arbitrary for FunctionPointerDeclarationC {
- fn arbitrary<G: Gen>(g: &mut G) -> FunctionPointerDeclarationC {
+ fn arbitrary(g: &mut Gen) -> FunctionPointerDeclarationC {
FunctionPointerDeclarationC {
type_qualifier: Arbitrary::arbitrary(g),
type_name: Arbitrary::arbitrary(g),
@@ -525,7 +524,7 @@ impl MakeUnique for FunctionPrototypeC {
/// A qucickcheck trait for describing how FunctionPrototypeC types can be
/// randomly generated and shrunk.
impl Arbitrary for FunctionPrototypeC {
- fn arbitrary<G: Gen>(g: &mut G) -> FunctionPrototypeC {
+ fn arbitrary(g: &mut Gen) -> FunctionPrototypeC {
FunctionPrototypeC {
type_qualifier: Arbitrary::arbitrary(g),
type_name: Arbitrary::arbitrary(g),
@@ -554,7 +553,7 @@ impl fmt::Display for FunctionPrototypeC {
/// A qucickcheck trait for describing how ParameterC types can be
/// randomly generated and shrunk.
impl Arbitrary for ParameterC {
- fn arbitrary<G: Gen>(g: &mut G) -> ParameterC {
+ fn arbitrary(g: &mut Gen) -> ParameterC {
ParameterC {
type_qualifier: Arbitrary::arbitrary(g),
type_name: Arbitrary::arbitrary(g),
@@ -577,7 +576,7 @@ impl fmt::Display for ParameterC {
/// A qucickcheck trait for describing how ParameterListC types can be
/// randomly generated and shrunk.
impl Arbitrary for ParameterListC {
- fn arbitrary<G: Gen>(g: &mut G) -> ParameterListC {
+ fn arbitrary(g: &mut Gen) -> ParameterListC {
ParameterListC {
params: Arbitrary::arbitrary(g),
}
@@ -601,7 +600,7 @@ impl fmt::Display for ParameterListC {
/// A qucickcheck trait for describing how HeaderC types can be
/// randomly generated and shrunk.
impl Arbitrary for HeaderC {
- fn arbitrary<G: Gen>(g: &mut G) -> HeaderC {
+ fn arbitrary(g: &mut Gen) -> HeaderC {
let mut decl_list: DeclarationListC = Arbitrary::arbitrary(g);
for (i, decl) in decl_list.decls.iter_mut().enumerate() {
decl.make_unique(i);
@@ -628,3 +627,9 @@ impl fmt::Debug for HeaderC {
write!(f, "{}", self)
}
}
+
+/// FIXME: is this actually uniform?
+fn gen_range(gen: &mut Gen, lo: u64, hi: u64) -> u64 {
+ let len = hi - lo;
+ (u64::arbitrary(gen) % len) + lo
+}
diff --git a/bindgen-tests/tests/quickchecking/src/lib.rs b/bindgen-tests/tests/quickchecking/src/lib.rs
index 75bfc237..e9f3798d 100644
--- a/bindgen-tests/tests/quickchecking/src/lib.rs
+++ b/bindgen-tests/tests/quickchecking/src/lib.rs
@@ -5,16 +5,14 @@
//! ```rust
//! extern crate quickcheck;
//! extern crate quickchecking;
-//! extern crate rand;
-//! use quickcheck::{Arbitrary, Gen, StdGen};
+//! use quickcheck::{Arbitrary, Gen};
//! use quickchecking::fuzzers;
-//! use rand::thread_rng;
//!
//! fn main() {
//! let generate_range: usize = 10; // Determines things like the length of
//! // arbitrary vectors generated.
//! let header = fuzzers::HeaderC::arbitrary(
-//! &mut StdGen::new(thread_rng(), generate_range));
+//! &mut Gen::new(generate_range));
//! println!("{}", header);
//! }
//! ```
@@ -23,11 +21,9 @@
#[macro_use]
extern crate lazy_static;
extern crate quickcheck;
-extern crate rand;
extern crate tempdir;
-use quickcheck::{QuickCheck, StdGen, TestResult};
-use rand::thread_rng;
+use quickcheck::{Gen, QuickCheck, TestResult};
use std::error::Error;
use std::fs::File;
use std::io::Write;
@@ -110,7 +106,7 @@ fn bindgen_prop(header: fuzzers::HeaderC) -> TestResult {
/// to the `csmith-fuzzing/predicate.py` script.
pub fn test_bindgen(
generate_range: usize,
- tests: usize,
+ tests: u64,
output_path: Option<&str>,
) {
if let Some(path) = output_path {
@@ -120,6 +116,6 @@ pub fn test_bindgen(
QuickCheck::new()
.tests(tests)
- .gen(StdGen::new(thread_rng(), generate_range))
+ .gen(Gen::new(generate_range))
.quickcheck(bindgen_prop as fn(fuzzers::HeaderC) -> TestResult)
}
diff --git a/bindgen-tests/tests/quickchecking/tests/fuzzed-c-headers.rs b/bindgen-tests/tests/quickchecking/tests/fuzzed-c-headers.rs
index 0d43f300..e394efe3 100644
--- a/bindgen-tests/tests/quickchecking/tests/fuzzed-c-headers.rs
+++ b/bindgen-tests/tests/quickchecking/tests/fuzzed-c-headers.rs
@@ -1,96 +1,93 @@
extern crate quickcheck;
extern crate quickchecking;
-extern crate rand;
-use quickcheck::{Arbitrary, StdGen};
+use quickcheck::{Arbitrary, Gen};
use quickchecking::fuzzers::{
ArrayDimensionC, BaseTypeC, BasicTypeDeclarationC, DeclarationC,
DeclarationListC, FunctionPointerDeclarationC, FunctionPrototypeC, HeaderC,
ParameterC, ParameterListC, PointerLevelC, StructDeclarationC,
TypeQualifierC, UnionDeclarationC,
};
-use rand::thread_rng;
-
#[test]
fn test_declaraion_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: DeclarationC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_declaraion_list_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: DeclarationListC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_base_type_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: BaseTypeC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_type_qualifier_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: TypeQualifierC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_pointer_level_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: PointerLevelC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_array_dimension_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: ArrayDimensionC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_basic_type_declaration_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: BasicTypeDeclarationC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_struct_declaration_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: StructDeclarationC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_union_declaration_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: UnionDeclarationC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_function_pointer_declaration_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: FunctionPointerDeclarationC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_function_prototype_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: FunctionPrototypeC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_parameter_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: ParameterC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_parameter_list_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: ParameterListC = Arbitrary::arbitrary(gen);
}
#[test]
fn test_header_c_does_not_panic() {
- let gen = &mut StdGen::new(thread_rng(), 50);
+ let gen = &mut Gen::new(50);
let _: HeaderC = Arbitrary::arbitrary(gen);
}