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

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=7094f7c428f1f871b1b83bf5f895ab66f9e3d55a

commit 7094f7c428f1f871b1b83bf5f895ab66f9e3d55a
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Wed Aug 22 22:38:50 2018 +0200

    libdpkg: Add support for new test_get_srcdir() and test_get_builddir()
---
 debian/changelog    |  1 +
 lib/dpkg/t/t-test.c |  7 ++++++-
 lib/dpkg/test.h     | 12 ++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 5ad7d759b..b52f91e05 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -243,6 +243,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
     - Add new test cases to clarify arch-qualified dependency simplification.
     - Add several TODO tests cases for dependency simplification.
     - Add new cppcheck author test.
+    - Add support for new test_get_srcdir() test_get_builddir().
 
   [ Updated programs translations ]
   * Dutch (Frans Spiesschaert). Closes: #881401
diff --git a/lib/dpkg/t/t-test.c b/lib/dpkg/t/t-test.c
index 62b35ce2f..48ce8726b 100644
--- a/lib/dpkg/t/t-test.c
+++ b/lib/dpkg/t/t-test.c
@@ -25,7 +25,7 @@
 
 TEST_ENTRY(test)
 {
-       test_plan(20);
+       test_plan(22);
 
        test_pass(1);
        test_fail(0);
@@ -58,4 +58,9 @@ TEST_ENTRY(test)
        test_mem("abcd", ==, "abcd", 5);
        test_mem("ababcd", ==, "ababff", 4);
        test_mem("ababcd", !=, "ababff", 6);
+
+       setenv("srcdir", "aaa", 1);
+       setenv("builddir", "bbb", 1);
+       test_str(test_get_srcdir(), ==, "aaa");
+       test_str(test_get_builddir(), ==, "bbb");
 }
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;

-- 
Dpkg.Org's dpkg

Reply via email to