summaryrefslogtreecommitdiff
path: root/test/test_load.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_load.cpp')
-rw-r--r--test/test_load.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/test/test_load.cpp b/test/test_load.cpp
index 1728263..6a3e3b2 100644
--- a/test/test_load.cpp
+++ b/test/test_load.cpp
@@ -4,6 +4,7 @@
#include <fcntl.h>
#include "config.h"
+#include "test_common.h"
int debug = 0;
@@ -13,8 +14,6 @@ int debug = 0;
#define EXPECT_OK(x) EXPECT_FALSE(x)
#define EXPECT_ERR(x) EXPECT_TRUE(x)
-#define TOPDIR SRC_DIR
-#define IMGDIR TOPDIR "/test/images"
#define FILE_REF "icon-64.png"
static const char *const pfxs[] = {
@@ -78,7 +77,7 @@ test_load(void)
int fd;
int err;
- snprintf(filei, sizeof(filei), "%s/%s", IMGDIR, FILE_REF);
+ snprintf(filei, sizeof(filei), "%s/%s", IMG_SRC, FILE_REF);
D("Load '%s'\n", filei);
im = imlib_load_image(filei);
@@ -89,7 +88,7 @@ test_load(void)
for (i = 0; i < N_PFX; i++)
{
// Load files of all types
- snprintf(fileo, sizeof(fileo), "%s/%s.%s", IMGDIR, "icon-64", pfxs[i]);
+ snprintf(fileo, sizeof(fileo), "%s/%s.%s", IMG_SRC, "icon-64", pfxs[i]);
D("Load '%s'\n", fileo);
im = imlib_load_image_with_error_return(fileo, &lerr);
EXPECT_TRUE(im);
@@ -103,11 +102,12 @@ test_load(void)
if (strchr(pfxs[i], '.') == 0)
{
- snprintf(filei, sizeof(filei), "%s.%s", "icon-64", pfxs[i]);
+ snprintf(filei, sizeof(filei),
+ "../%s/%s.%s", IMG_SRC, "icon-64", pfxs[i]);
for (j = 0; j < N_PFX; j++)
{
// Load certain types pretending they are something else
- snprintf(fileo, sizeof(fileo), "%s/%s.%s.%s", IMGDIR,
+ snprintf(fileo, sizeof(fileo), "%s/%s.%s.%s", IMG_GEN,
"icon-64", pfxs[i], pfxs[j]);
unlink(fileo);
symlink(filei, fileo);
@@ -123,7 +123,7 @@ test_load(void)
}
// Empty files of all types
- snprintf(fileo, sizeof(fileo), "%s/%s.%s", IMGDIR, "empty", pfxs[i]);
+ snprintf(fileo, sizeof(fileo), "%s/%s.%s", IMG_GEN, "empty", pfxs[i]);
unlink(fileo);
fp = fopen(fileo, "wb");
fclose(fp);
@@ -133,7 +133,7 @@ test_load(void)
EXPECT_TRUE(lerr == IMLIB_LOAD_ERROR_UNKNOWN);
// Non-existing files of all types
- snprintf(fileo, sizeof(fileo), "%s/%s.%s", IMGDIR, "nonex", pfxs[i]);
+ snprintf(fileo, sizeof(fileo), "%s/%s.%s", IMG_GEN, "nonex", pfxs[i]);
unlink(fileo);
symlink("non-existing", fileo);
D("Load non-existing '%s'\n", fileo);
@@ -141,7 +141,7 @@ test_load(void)
EXPECT_EQ(lerr, IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST);
// Load via fd
- snprintf(fileo, sizeof(fileo), "%s/%s.%s", IMGDIR, "icon-64", pfxs[i]);
+ snprintf(fileo, sizeof(fileo), "%s/%s.%s", IMG_SRC, "icon-64", pfxs[i]);
fd = open(fileo, O_RDONLY);
D("Load fd %d '%s'\n", fd, fileo);
snprintf(fileo, sizeof(fileo), ".%s", pfxs[i]);
@@ -186,5 +186,7 @@ main(int argc, char **argv)
}
}
+ mkdir(IMG_GEN, 0755);
+
return RUN_ALL_TESTS();
}