Signed-off-by: Michal Privoznik <mpriv...@redhat.com>
---
 src/Makefile.am                              |  4 +++-
 tests/Makefile.am                            | 14 ++++++++++++++
 tests/{functions.phpt => functions.phpt.in}  |  4 +++-
 tests/runtests.sh                            |  4 +++-
 tests/test-domain-create-and-coredump.phpt   |  3 +--
 tests/test-domain-create-and-get-xpath.phpt  |  3 +--
 tests/test-domain-create-get-metadata.phpt   |  3 +--
 tests/test-domain-create.phpt                |  3 +--
 tests/test-domain-define-create-destroy.phpt |  3 +--
 tests/test-domain-define-undefine.phpt       |  3 +--
 tests/test-domain-snapshot.phpt              |  3 +--
 11 files changed, 30 insertions(+), 17 deletions(-)
 rename tests/{functions.phpt => functions.phpt.in} (91%)

diff --git a/src/Makefile.am b/src/Makefile.am
index 867f5df..a601ebe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,7 +6,9 @@ WL=@WL@
 SHLIB_FLAGS=@SHLIB_FLAGS@
 
 install-exec-local:
-       $(INSTALL) -m 644 -D $(PACKAGE).so $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so
+       $(MKDIR_P) $(DESTDIR)$(PHPEDIR)
+       $(MKDIR_P) $(DESTDIR)$(PHPCDIR)
+       $(INSTALL) -m 644 -D .libs/$(PACKAGE).so 
$(DESTDIR)$(PHPEDIR)/$(PACKAGE).so
        $(INSTALL) -m 755 -d $(DESTDIR)$(PHPCDIR)
        $(ECHO) "extension=$(PACKAGE).so" > $(DESTDIR)$(PHPCDIR)/libvirt-php.ini
        $(ECHO) >> $(DESTDIR)$(PHPCDIR)/libvirt-php.ini
diff --git a/tests/Makefile.am b/tests/Makefile.am
index aeb184e..3531369 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,6 +3,9 @@ test_scripts = runtests.sh
 TESTS = $(test_scripts)
 EXTRA_DIST = $(test_scripts) \
        runtests-report.sh \
+       data \
+       functions.phpt.in \
+       php.ini \
        test-connect.phpt \
        test-conn-limit.phpt \
        test-domain-create-and-coredump.phpt \
@@ -19,3 +22,14 @@ EXTRA_DIST = $(test_scripts) \
        test-logging.phpt \
        test-version-get.phpt \
        test-version-check.phpt
+
+runtests.sh: functions.phpt
+
+functions.phpt: functions.phpt.in
+       $(AM_V_GEN)sed \
+               -e 's|[@]abs_srcdir[@]|$(abs_srcdir)|g' \
+       < $< > $@-t && \
+       chmod a+x $@-t && \
+       mv $@-t $@
+
+CLEANFILES = functions.phpt
diff --git a/tests/functions.phpt b/tests/functions.phpt.in
similarity index 91%
rename from tests/functions.phpt
rename to tests/functions.phpt.in
index 5f95188..47dba2d 100644
--- a/tests/functions.phpt
+++ b/tests/functions.phpt.in
@@ -29,8 +29,10 @@
                exit(1);
        }
 
+    $abs_srcdir = '@abs_srcdir@' ?: getcwd();
+
        if (!extension_loaded('libvirt')) {
-               if (!dl('../src/libvirt-php.so'))
+               if (!dl('libvirt-php.so'))
                        bail('Cannot load libvirt-php extension. Please install 
libvirt-php first (using `make install`)');
        }
 ?>
diff --git a/tests/runtests.sh b/tests/runtests.sh
index 24cbcf2..8280be7 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+: ${srcdir=.}
+
 nf=$1
 tests=( "test-version-check" "test-version-get" "test-get-emulator" 
"test-logging"
                "test-connect" "test-conn-limit"
@@ -15,7 +17,7 @@ run_test()
        local nf=$2
        ret=0
 
-       php -n -c "./php.ini" $name.phpt
+       php -n -c "${srcdir}/php.ini" "${srcdir}/${name}.phpt"
        if [ "x$?" != "x0" ]; then
                if [ "x$nf" == 'x1' ]; then
                        ret=1
diff --git a/tests/test-domain-create-and-coredump.phpt 
b/tests/test-domain-create-and-coredump.phpt
index abfd520..840bab9 100644
--- a/tests/test-domain-create-and-coredump.phpt
+++ b/tests/test-domain-create-and-coredump.phpt
@@ -5,8 +5,7 @@
        if (!is_resource($conn))
                bail('Connection to default hypervisor failed');
 
-       $curdir = getcwd();
-       $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml');
+       $xml = 
file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml');
 
        $res = libvirt_domain_create_xml($conn, $xml);
        if (!is_resource($res))
diff --git a/tests/test-domain-create-and-get-xpath.phpt 
b/tests/test-domain-create-and-get-xpath.phpt
index d370216..26176f8 100644
--- a/tests/test-domain-create-and-get-xpath.phpt
+++ b/tests/test-domain-create-and-get-xpath.phpt
@@ -5,8 +5,7 @@
        if (!is_resource($conn))
                bail('Connection to default hypervisor failed');
 
-       $curdir = getcwd();
-       $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml');
+       $xml = 
file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml');
 
        $res = libvirt_domain_create_xml($conn, $xml);
        if (!is_resource($res))
diff --git a/tests/test-domain-create-get-metadata.phpt 
b/tests/test-domain-create-get-metadata.phpt
index 8c22c34..72cd0c8 100644
--- a/tests/test-domain-create-get-metadata.phpt
+++ b/tests/test-domain-create-get-metadata.phpt
@@ -5,8 +5,7 @@
        if (!is_resource($conn))
                bail('Connection to default hypervisor failed');
 
-       $curdir = getcwd();
-       $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml');
+       $xml = 
file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml');
 
        $res = libvirt_domain_create_xml($conn, $xml);
        if (!is_resource($res))
diff --git a/tests/test-domain-create.phpt b/tests/test-domain-create.phpt
index 1bcccb8..5a69db7 100644
--- a/tests/test-domain-create.phpt
+++ b/tests/test-domain-create.phpt
@@ -5,8 +5,7 @@
        if (!is_resource($conn))
                bail('Connection to default hypervisor failed');
 
-       $curdir = getcwd();
-       $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml');
+       $xml = 
file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml');
 
        $res = libvirt_domain_create_xml($conn, $xml);
        if (!is_resource($res))
diff --git a/tests/test-domain-define-create-destroy.phpt 
b/tests/test-domain-define-create-destroy.phpt
index 0c41c2d..77fafda 100644
--- a/tests/test-domain-define-create-destroy.phpt
+++ b/tests/test-domain-define-create-destroy.phpt
@@ -5,8 +5,7 @@
        if (!is_resource($conn))
                bail('Connection to default hypervisor failed');
 
-       $curdir = getcwd();
-       $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml');
+       $xml = 
file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml');
 
        $res = libvirt_domain_define_xml($conn, $xml);
        if (!is_resource($res))
diff --git a/tests/test-domain-define-undefine.phpt 
b/tests/test-domain-define-undefine.phpt
index 61ff3a7..2627272 100644
--- a/tests/test-domain-define-undefine.phpt
+++ b/tests/test-domain-define-undefine.phpt
@@ -5,8 +5,7 @@
        if (!is_resource($conn))
                bail('Connection to default hypervisor failed');
 
-       $curdir = getcwd();
-       $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml');
+       $xml = 
file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml');
 
        $res = libvirt_domain_define_xml($conn, $xml);
        if (!is_resource($res))
diff --git a/tests/test-domain-snapshot.phpt b/tests/test-domain-snapshot.phpt
index c30a458..2c43085 100644
--- a/tests/test-domain-snapshot.phpt
+++ b/tests/test-domain-snapshot.phpt
@@ -11,8 +11,7 @@
                @libvirt_domain_undefine($res);
        }
 
-       $curdir = getcwd();
-       $xml = file_get_contents($curdir.'/data/example-qcow2-disk.xml');
+       $xml = file_get_contents($abs_srcdir.'/data/example-qcow2-disk.xml');
 
        /* This is applicable only for QEMU/KVM so check whether we're on 
QEMU/KVM */
        $e = @libvirt_connect_get_emulator($conn);
-- 
2.3.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to