Changeset: 1ec9865f6c7b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1ec9865f6c7b
Modified Files:
        clients/mapiclient/mclient.c
        testing/Mtest.py.in
Branch: Mar2018
Log Message:

When testing, allow password option on mclient command line; add Mtest 
conditionals.
In the All files we can now have "conditions" of the form USER=user
and PASSWD=secret which causes mclient to be called with appropriate
-u and -P options (the latter only allowed when -ftest is also
passed).
This makes it easier to test with other users than monetdb.


diffs (120 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -3017,6 +3017,7 @@ main(int argc, char **argv)
        bool settz = true;
        bool autocommit = true; /* autocommit mode default on */
        bool user_set_as_flag = false;
+       bool passwd_set_as_flag = false;
        static struct option long_options[] = {
                {"autocommit", 0, 0, 'a'},
                {"database", 1, 0, 'd'},
@@ -3077,7 +3078,7 @@ main(int argc, char **argv)
 #ifdef HAVE_ICONV
                                "E:"
 #endif
-                               "f:h:Hil:L:n:Np:r:s:t:u:vw:Xz"
+                               "f:h:Hil:L:n:Np:P:r:s:t:u:vw:Xz"
 #ifdef HAVE_POPEN
                                "|:"
 #endif
@@ -3167,6 +3168,13 @@ main(int argc, char **argv)
                        assert(optarg);
                        port = atoi(optarg);
                        break;
+               case 'P':
+                       assert(optarg);
+                       if (passwd)
+                               free(passwd);
+                       passwd = strdup(optarg);
+                       passwd_set_as_flag = true;
+                       break;
                case 'r':
                        assert(optarg);
                        rowsperpage = atoi(optarg);
@@ -3241,6 +3249,12 @@ main(int argc, char **argv)
                        /* not reached */
                }
        }
+       if (passwd_set_as_flag &&
+           (output == NULL || strcmp(output, "test") != 0)) {
+               usage(argv[0], -1);
+               /* not reached */
+       }
+
 #ifdef HAVE_ICONV
 #ifdef HAVE_NL_LANGINFO
        if (encoding == NULL)
@@ -3261,9 +3275,10 @@ main(int argc, char **argv)
 
        /* when config file would provide defaults */
        if (user_set_as_flag) {
-               if (passwd)
+               if (passwd && !passwd_set_as_flag) {
                        free(passwd);
-               passwd = NULL;
+                       passwd = NULL;
+               }
        }
 
        if (user == NULL)
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -1941,6 +1941,8 @@ def RunTest(env, TST, BusyPorts, COND, o
     MissingMods = CheckMods(env, TST, SERVER, CALL)
     MissingTests = CheckTests(env, TST, oktests)
     nomito = os.path.isfile(TST + '.nomito')
+    user = None
+    passwd = None
 
 
     os.chdir(TSTTRGDIR)
@@ -2014,6 +2016,18 @@ def RunTest(env, TST, BusyPorts, COND, o
                     reason = "as number of threads is wrong"
                     elem = SkipTest(env, TST, EXT, reason, length)
                     break
+            elif cond.startswith('USER='):
+                if negate:
+                    reason = "impossible combination of USER= and negation"
+                    elem = SkipTest(env, TST, EXT, reason, length)
+                    break
+                user = cond[5:]
+            elif cond.startswith('PASSWD='):
+                if negate:
+                    reason = "impossible combination of PASSWD= and negation"
+                    elem = SkipTest(env, TST, EXT, reason, length)
+                    break
+                passwd = cond[7:]
             elif cond not in CONDITIONALS:
                 reason = "as conditional '%s' is unknown." % cond
                 elem = SkipTest(env, TST, EXT, reason, length)
@@ -2193,7 +2207,7 @@ def RunTest(env, TST, BusyPorts, COND, o
         TestErr.close()
 
         t0 = time.time()
-        tres = DoIt(env, SERVER, CALL, TST, EXT, PRELUDE, TestOutFile, 
TestErrFile, STIMEOUT, CTIMEOUT, TIMEOUT, ME, MAPIsockets, length, nomito, 
threads, COND, all_tests)
+        tres = DoIt(env, SERVER, CALL, TST, EXT, PRELUDE, TestOutFile, 
TestErrFile, STIMEOUT, CTIMEOUT, TIMEOUT, ME, MAPIsockets, length, nomito, 
threads, user, passwd, COND, all_tests)
         if tres == 'segfault':
             # rename core file, if any -- might have to check
             # /proc/sys/kernel/core_pattern in the future but hopefully
@@ -2822,7 +2836,7 @@ def mapi_ping(port,lang) :
     return False
 ### mapi_ping() #
 
-def DoIt(env, SERVER, CALL, TST, EXT, PRELUDE, TestOutFile, TestErrFile, 
STIMEOUT, CTIMEOUT, TIMEOUT, ME, MAPIsockets, length, nomito, threads, COND, 
all_tests) :
+def DoIt(env, SERVER, CALL, TST, EXT, PRELUDE, TestOutFile, TestErrFile, 
STIMEOUT, CTIMEOUT, TIMEOUT, ME, MAPIsockets, length, nomito, threads, user, 
passwd, COND, all_tests) :
     ATJOB2 = ""
     STDERR.flush()
     if quiet:
@@ -3052,6 +3066,10 @@ def DoIt(env, SERVER, CALL, TST, EXT, PR
                         TSTs.append(f)
 
                 Clnt = splitcommand(exe['SQL_Client'][1])
+                if user:
+                    Clnt.append('-u%s' % user)
+                if passwd:
+                    Clnt.append('-P%s' % passwd)
                 for f in TSTs:
                     returncode = RunIt(Clnt, open(f), ClntOut, ClntErr, 
TIMEOUT)
                     if returncode:
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to