On 12/12/18 1:13 pm, Sunil Mohan Adapa wrote:
> On 12/12/18 11:27 am, Paul Gevers wrote:
> [...]
>>> Attached patch uses runuser in the pgsql methods instead of su.
>>
>> Did you run the tests that are part of dbconfig-common with your patch
>> applied? I am running it now and there seems to be at least one test
>> case failing.
>>
>> test_dbc_psql_db_installed_real
>>         case 1: pgsqld in path
>>         case 2: pgsqld not in path
>> ASSERT:pgsqld should not have been found
>>
> 
> Looks like this test at least fails even without a patch and code seems
> outdated considering the method it tests.
> 
> Currently, for me all mock tests pass and real test are failing with or
> without the patch.
> 

Attached patch fixes the outdated test case.

With the patch, I have successfully run the test cases as follows:

$ cd test
$ ./runtests.sh
<success and no assertions printed>
$ echo $?
0
$ export dbc_test_with_client=true
$ ./runtests.sh
<success and no assertions printed>
$ echo $?
0

Thank you,

-- 
Sunil
From 873725cc75b5fc0056ad3d0ee80e51f2cc0d041d Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa <su...@medhas.org>
Date: Wed, 12 Dec 2018 13:52:11 -0800
Subject: [PATCH 2/2] test: Fix case that checks if a db is installed

The test relied on mysql, sqlite, sqlite3 and find binaries not being found in
/bin, the path set during test. Since /bin is now a symlink to /usr/bin on many
machines, these binaries are found and test case fails.

Set the path to empty to make sure 'which' command is found and 'find' and other
database commands are not found. 'which' is a shell builtin from some shells
only.
---
 test/common | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/test/common b/test/common
index c809bf2..cdddef2 100755
--- a/test/common
+++ b/test/common
@@ -565,8 +565,11 @@ dbc_common_db_installed(){
     # the logic there is different and instead it fails on being unable
     # to find /usr/bin/find
     log_tc "${test_dbtype}d not in path"
-    ( PATH="/bin"; dbc_${test_dbtype}_db_installed ) > /dev/null 2>&1
+    # Copy which command needed for checking mysql, sqlite, sqlite3
+    cp /bin/which ./tmp/
+    ( PATH="./tmp"; dbc_${test_dbtype}_db_installed ) > /dev/null 2>&1
     assertFalse "${test_dbtype}d should not have been found" $?
+    rm -f ./tmp/which
 }
 
 dbc_common_escape_str(){
-- 
2.19.2

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to