1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use anyhow::{Context, Result};
use rand::Rng;
use std::io::{BufRead, BufReader};
use std::{fs::File, path::PathBuf};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
pub struct MockDeqp {
#[structopt(long, help = "Path to the caselist file")]
deqp_caselist_file: PathBuf,
#[structopt(long, help = "Path to the QPA log output")]
deqp_log_filename: PathBuf,
#[structopt(long)]
deqp_log_flush: bool,
#[structopt(long, help = "Path to the .shader_cache output")]
deqp_shadercache_filename: PathBuf,
#[structopt(long)]
deqp_shadercache_truncate: bool,
}
pub fn mock_deqp(mock: &MockDeqp) -> Result<()> {
let file = File::open(&mock.deqp_caselist_file)
.with_context(|| format!("Opening {:?}", &mock.deqp_caselist_file))?;
let tests = BufReader::new(file)
.lines()
.collect::<std::result::Result<Vec<String>, std::io::Error>>()
.context("reading test caselist")?;
File::create(&mock.deqp_log_filename).context("Creating QPA file")?;
for test_name in tests {
if test_name.contains("dEQP-GLES2.test.m.") {
continue;
}
println!("Test case '{}'..", test_name);
if test_name.contains(".timeout.") {
#[allow(clippy::empty_loop)]
loop {}
}
if test_name.contains(".p.") {
println!(" Pass (success case)");
} else if test_name.contains(".f.") {
println!(" Fail (failure case)");
} else if test_name.contains(".flaky") {
if rand::thread_rng().gen::<bool>() {
println!(" Fail (failure case)");
} else {
println!(" Pass (success)");
}
} else if test_name.contains(".s.") {
println!(" NotSupported (skip case)");
} else if test_name.contains(".c.") {
break;
} else {
unimplemented!("unknown mock test name {}", test_name)
}
}
Ok(())
}