From f453ec77fa9e6fd961a1f5f0b221260a5a21bba2 Mon Sep 17 00:00:00 2001
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date: Tue, 27 Aug 2024 14:08:47 +0300
Subject: [PATCH] deqp-runner: drop zstd support

Building zstd-sys results in the "foo contains reference to TMPDIR" QA
error. Revert commit 1adddf3aa89f21b472d8046347ccdfa4612f141b to drop
zstd dependency.

Upstream-Status: Inappropriate [oe specific]
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 Cargo.lock | 45 ---------------------------------------------
 Cargo.toml |  3 ---
 src/lib.rs | 31 +++++++------------------------
 3 files changed, 7 insertions(+), 72 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 8443695e2bd5..50924576a8e3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -94,7 +94,6 @@ version = "1.0.83"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
 dependencies = [
- "jobserver",
  "libc",
 ]
 
@@ -271,7 +270,6 @@ dependencies = [
  "structopt",
  "tempfile",
  "toml",
- "zstd",
 ]
 
 [[package]]
@@ -423,15 +421,6 @@ version = "1.0.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
 
-[[package]]
-name = "jobserver"
-version = "0.1.31"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e"
-dependencies = [
- "libc",
-]
-
 [[package]]
 name = "js-sys"
 version = "0.3.64"
@@ -544,12 +533,6 @@ version = "11.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
 
-[[package]]
-name = "pkg-config"
-version = "0.3.30"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
-
 [[package]]
 name = "plotters"
 version = "0.3.5"
@@ -1217,31 +1200,3 @@ name = "xmlparser"
 version = "0.13.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd"
-
-[[package]]
-name = "zstd"
-version = "0.13.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a"
-dependencies = [
- "zstd-safe",
-]
-
-[[package]]
-name = "zstd-safe"
-version = "7.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a"
-dependencies = [
- "zstd-sys",
-]
-
-[[package]]
-name = "zstd-sys"
-version = "2.0.10+zstd.1.5.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa"
-dependencies = [
- "cc",
- "pkg-config",
-]
diff --git a/Cargo.toml b/Cargo.toml
index ac6295763e87..1fa1344a3105 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -120,9 +120,6 @@ version = "3.2"
 [dependencies.toml]
 version = "0.5"
 
-[dependencies.zstd]
-version = "0.13.0"
-
 [dev-dependencies.criterion]
 version = "0.3.0"
 
diff --git a/src/lib.rs b/src/lib.rs
index e7095267f1cd..ff7bc4f5d025 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -63,7 +63,6 @@ use rayon::prelude::*;
 use regex::RegexSet;
 use serde::{Deserialize, Serialize};
 use std::collections::HashMap;
-use std::ffi::OsStr;
 use std::fs::File;
 use std::io::prelude::*;
 use std::io::BufReader;
@@ -76,7 +75,6 @@ use std::time::Duration;
 use std::time::Instant;
 use structopt::StructOpt;
 use timeout::{TimeoutChildExt, TimeoutChildStdout, Timer};
-use zstd::stream::read::Decoder;
 
 fn parse_key_val<T, U>(s: &str) -> Result<(T, U), Box<dyn std::error::Error>>
 where
@@ -1082,32 +1080,17 @@ pub fn read_lines<I: IntoIterator<Item = impl AsRef<Path>>>(files: I) -> Result<
     let mut lines: Vec<String> = Vec::new();
 
     for path in files {
-        let mut path: &Path = path.as_ref();
-        let mut path_compressed: PathBuf = path.to_path_buf();
-
-        // always try append zst extension (and keep existing one, e.g. .txt)
-        let ext = if let Some(file_ext) = path.extension().and_then(|ext| ext.to_str()) {
-            format!("{}.zst", file_ext)
-        } else {
-            (".zst").to_string()
-        };
-
-        path_compressed.set_extension(ext);
-        if path_compressed.exists() {
-            path = path_compressed.as_ref();
-        }
-        let file = File::open(path).with_context(|| format!("opening path: {}", path.display()))?;
-        let reader: Box<dyn Read> = match path.extension().and_then(OsStr::to_str) {
-            Some("zst") => Box::new(Decoder::new(file).unwrap()),
-            _ => Box::new(file),
-        };
-
-        for line in BufReader::new(reader).lines() {
+        let path = path.as_ref();
+        for line in BufReader::new(
+            File::open(path).with_context(|| format!("opening path: {}", path.display()))?,
+        )
+        .lines()
+        {
             let line = line.with_context(|| format!("reading line from {}", path.display()))?;
             // In newer dEQP, vk-master.txt just contains a list of .txt
             // caselist files relative to its current path, so recursively read
             // thoseand append their contents.
-            if line.ends_with(".txt") || line.ends_with(".txt.zst") {
+            if line.ends_with(".txt") {
                 let sub_path = path.parent().context("Getting path parent dir")?.join(line);
 
                 lines.extend_from_slice(
