This is an automated email from the ASF dual-hosted git repository.

erickguan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 4fe7b39f3 fix(fuzz): resolve fuzz_reader timeout on OSS-Fuzz (#7831)
4fe7b39f3 is described below

commit 4fe7b39f30fb0573ff19c9e65a23ac480dde24d9
Author: tonghuaroot (童话) <[email protected]>
AuthorDate: Tue Jun 30 13:49:45 2026 +0800

    fix(fuzz): resolve fuzz_reader timeout on OSS-Fuzz (#7831)
    
    Closes #7808.
---
 core/fuzz/fuzz_reader.rs  |  4 ++--
 core/fuzz/fuzz_writer.rs  |  4 ++--
 core/testkit/src/read.rs  | 13 +++++++------
 core/testkit/src/write.rs | 12 +++++++-----
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/core/fuzz/fuzz_reader.rs b/core/fuzz/fuzz_reader.rs
index 12ed887f0..1424ff443 100644
--- a/core/fuzz/fuzz_reader.rs
+++ b/core/fuzz/fuzz_reader.rs
@@ -31,7 +31,7 @@ use opendal::tests::ReadChecker;
 use opendal::tests::TEST_RUNTIME;
 use opendal::tests::init_test_service;
 
-const MAX_DATA_SIZE: usize = 16 * 1024 * 1024;
+const MAX_DATA_SIZE: usize = 4 * 1024 * 1024;
 
 #[derive(Clone)]
 struct FuzzInput {
@@ -59,7 +59,7 @@ impl Arbitrary<'_> for FuzzInput {
     fn arbitrary(u: &mut Unstructured<'_>) -> arbitrary::Result<Self> {
         let total_size = u.int_in_range(1..=MAX_DATA_SIZE)?;
 
-        let count = u.int_in_range(1..=1024)?;
+        let count = u.int_in_range(1..=256)?;
         let mut actions = vec![];
 
         for _ in 0..count {
diff --git a/core/fuzz/fuzz_writer.rs b/core/fuzz/fuzz_writer.rs
index 546decf38..789cf2e85 100644
--- a/core/fuzz/fuzz_writer.rs
+++ b/core/fuzz/fuzz_writer.rs
@@ -29,7 +29,7 @@ use opendal::tests::WriteAction;
 use opendal::tests::WriteChecker;
 use opendal::tests::init_test_service;
 
-const MAX_DATA_SIZE: usize = 16 * 1024 * 1024;
+const MAX_DATA_SIZE: usize = 4 * 1024 * 1024;
 
 #[derive(Debug, Clone)]
 struct FuzzInput {
@@ -52,7 +52,7 @@ impl Arbitrary<'_> for FuzzInput {
             None
         };
 
-        let count = u.int_in_range(1..=1024)?;
+        let count = u.int_in_range(1..=256)?;
 
         for _ in 0..count {
             let size = u.int_in_range(1..=MAX_DATA_SIZE)?;
diff --git a/core/testkit/src/read.rs b/core/testkit/src/read.rs
index 5454edb28..1d82d9bd3 100644
--- a/core/testkit/src/read.rs
+++ b/core/testkit/src/read.rs
@@ -91,12 +91,13 @@ impl ReadChecker {
 
         let expected = &self.raw_data[offset..offset + output.len()];
 
-        // Check the read result
-        assert_eq!(
-            sha256_digest(output),
-            sha256_digest(expected),
-            "check read failed: output bs is different with expected bs",
-        );
+        if output != expected {
+            assert_eq!(
+                sha256_digest(output),
+                sha256_digest(expected),
+                "check read failed: output bs is different with expected bs",
+            );
+        }
     }
 
     /// Check will check the correctness of the read process via given actions.
diff --git a/core/testkit/src/write.rs b/core/testkit/src/write.rs
index 13925eb1f..c81db68e3 100644
--- a/core/testkit/src/write.rs
+++ b/core/testkit/src/write.rs
@@ -70,10 +70,12 @@ impl WriteChecker {
 
     /// Check the correctness of the write process.
     pub fn check(&self, actual: &[u8]) {
-        assert_eq!(
-            sha256_digest(actual),
-            sha256_digest(&self.data),
-            "check failed: result is not expected"
-        )
+        if actual != self.data.as_ref() {
+            assert_eq!(
+                sha256_digest(actual),
+                sha256_digest(&self.data),
+                "check failed: result is not expected"
+            );
+        }
     }
 }

Reply via email to