summaryrefslogtreecommitdiff
path: root/lib/dpkg/test.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dpkg/test.h')
-rw-r--r--lib/dpkg/test.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/dpkg/test.h b/lib/dpkg/test.h
index 39ecb967b..a0e5ffdae 100644
--- a/lib/dpkg/test.h
+++ b/lib/dpkg/test.h
@@ -59,6 +59,18 @@ test_alloc(void *ptr, const char *reason)
#define test_alloc(ptr) \
test_alloc((ptr), "cannot allocate memory for " #ptr " in " __FILE__ ":" test_stringify(__LINE__))
+static inline const char *
+test_get_envdir(const char *envvar)
+{
+ const char *envdir = getenv(envvar);
+ return envdir ? envdir : ".";
+}
+
+#define test_get_srcdir() \
+ test_get_envdir("srcdir")
+#define test_get_builddir() \
+ test_get_envdir("builddir")
+
static int test_id = 1;
static int test_skip_code;
static const char *test_skip_prefix;