This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository legacy-imlib2.

View the commit online.

commit cef7a6339cc6971a75193b566964d1cdeb7a741a
Author: Kim Woelders <[email protected]>
AuthorDate: Thu Feb 24 19:30:43 2022 +0100

    test: Add big bad file load test
---
 test/test.cpp        | 24 ++++++++++++++++++++++++
 test/test.h          |  2 ++
 test/test_load_2.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+)

diff --git a/test/test.cpp b/test/test.cpp
index 2f22bb3..44afd53 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -82,3 +82,27 @@ image_get_crc32(Imlib_Image im)
 
    return crc;
 }
+
+#if USE_MONOTONIC_CLOCK
+#include <time.h>
+#else
+#include <sys/time.h>
+#endif
+
+unsigned int
+time_us(void)
+{
+#if USE_MONOTONIC_CLOCK
+   struct timespec     ts;
+
+   clock_gettime(CLOCK_MONOTONIC, &ts);
+
+   return (unsigned int)(ts.tv_sec * 1000000 + ts.tv_nsec / 1000);
+#else
+   struct timeval      timev;
+
+   gettimeofday(&timev, NULL);
+
+   return (unsigned int)(timev.tv_sec * 1000000 + timev.tv_usec);
+#endif
+}
diff --git a/test/test.h b/test/test.h
index 724bea0..7c139d9 100644
--- a/test/test.h
+++ b/test/test.h
@@ -13,6 +13,8 @@ extern int          debug;
 
 void                pr_info(const char *fmt, ...);
 
+unsigned int        time_us(void);
+
 unsigned int        image_get_crc32(Imlib_Image im);
 
 #endif /* TEST_H */
diff --git a/test/test_load_2.cpp b/test/test_load_2.cpp
index 3b79994..79fe1bc 100644
--- a/test/test_load_2.cpp
+++ b/test/test_load_2.cpp
@@ -212,3 +212,49 @@ TEST(LOAD2, load_1)
         imlib_free_image_and_decache();
      }
 }
+
+static const char  *const bfs[] = {
+   "/local/stuff/qemu/boxes-win10k",
+   "/local/stuff/images/elive_3.7.3_alpha_hybrid.iso",
+   "/local/stuff/images/nisc.img",
+};
+#define N_BFS (sizeof(bfs) / sizeof(char*))
+
+#ifdef __i386__
+#define BIGFILE_ERRNO EOVERFLOW
+#define BIGFILE_ERROR IMLIB_LOAD_ERROR_UNKNOWN
+#else
+#define BIGFILE_ERRNO IMLIB_ERR_NO_LOADER
+#define BIGFILE_ERROR IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT
+#endif
+
+TEST(LOAD2, load_bigfile_time)
+{
+   unsigned int        i;
+   Imlib_Image         im;
+   int                 err;
+   Imlib_Load_Error    lerr;
+   const char         *file;
+   unsigned int        tu;
+   double              tf;
+
+   for (i = 0; i < N_BFS; i++)
+     {
+        file = bfs[i];
+        D("Load '%s'\n", file);
+        tu = time_us();
+        im = imlib_load_image_with_errno_return(file, &err);
+        tu = time_us() - tu;
+        tf = 1e-6 * tu;
+        ASSERT_FALSE(im);
+        D("  t   = %.3f s\n", tf);
+        D("  err = %d\n", err);
+        EXPECT_EQ(err, BIGFILE_ERRNO);
+        EXPECT_LT(tf, .050);
+
+        im = imlib_load_image_with_error_return(file, &lerr);
+        D("  err = %d\n", lerr);
+        ASSERT_FALSE(im);
+        EXPECT_EQ(lerr, BIGFILE_ERROR);
+     }
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to