]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
support feature checks in testcases
authorMichael Schroeder <mls@suse.de>
Fri, 20 Mar 2015 12:49:32 +0000 (13:49 +0100)
committerMichael Schroeder <mls@suse.de>
Fri, 20 Mar 2015 12:49:32 +0000 (13:49 +0100)
ext/testcase.c
test/runtestcases
tools/testsolv.c

index f0057e6c7a9af86e22dd05fc49f27b653b4c2643..c808c0e3185cb1a8fd10f11139f630c39660d247 100644 (file)
@@ -158,6 +158,15 @@ static struct selflags2str {
   { 0, 0 }
 };
 
+static const char *features[] = {
+#ifdef ENABLE_LINKED_PACKAGES
+  "linked_packages",
+#endif
+#ifdef ENABLE_COMPLEX_DEPS
+  "complex_deps",
+#endif
+  0
+};
 
 typedef struct strqueue {
   char **str;
@@ -2221,6 +2230,7 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp,
   int prepared = 0;
   int closefp = !fp;
   int poolflagsreset = 0;
+  int missing_features = 0;
 
   if (!fp && !(fp = fopen(testcase, "r")))
     {
@@ -2511,6 +2521,23 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp,
          else
            pool_debug(pool, SOLV_ERROR, "disable: unknown package '%s'\n", pieces[2]);
        }
+      else if (!strcmp(pieces[0], "feature"))
+       {
+         int i, j;
+         for (i = 1; i < npieces; i++)
+           {
+             for (j = 0; features[j]; j++)
+               if (!strcmp(pieces[i], features[j]))
+                 break;
+             if (!features[j])
+               {
+                 pool_debug(pool, SOLV_ERROR, "testcase_read: missing feature '%s'\n", pieces[i]);
+                 missing_features++;
+               }
+           }
+         if (missing_features)
+           break;
+       }
       else
        {
          pool_debug(pool, SOLV_ERROR, "testcase_read: cannot parse command '%s'\n", pieces[0]);
@@ -2531,6 +2558,13 @@ testcase_read(Pool *pool, FILE *fp, char *testcase, Queue *job, char **resultp,
     }
   if (closefp)
     fclose(fp);
+  if (missing_features)
+    {
+      solver_free(solv);
+      solv = 0;
+      if (resultflagsp)
+       *resultflagsp = 77;     /* hack for testsolv */
+    }
   return solv;
 }
 
index 2edf743117a54937556cc6659c4866c68a0ec386..3d736630e3883d90e4a362479685f1e6ea1112b0 100755 (executable)
@@ -3,15 +3,23 @@
 cmd=$1
 dir=$2
 
-if test -z "$dir"; then
+if test -z "$cmd" -o -z "$dir"; then
   echo "Usage: runtestcases <cmd> <dir>";
   exit 1
 fi
 
 ex=0
 for tc in $(find $dir -name \*.t) ; do
-  if ! $cmd $tc > /dev/null ; then
-    echo "failed test: ${tc#$dir/}"
+  $cmd $tc >/dev/null
+  tex=$?
+  tcn="${tc#$dir/} .................................................."
+  tcn="${tcn:0:50}"
+  if test "$tex" -eq 0 ; then
+    echo "$tcn   Passed"
+  elif test "$tex" -eq 77 ; then
+    echo "$tcn   Skipped"
+  else
+    echo "$tcn***Failed"
     ex=1
   fi
 done
index 279b43bc609801f816c43d1311fffe92e82d8e06..12829220f4946b14bb8871f49f6b88a0d838fd96 100644 (file)
@@ -131,7 +131,7 @@ main(int argc, char **argv)
          if (!solv)
            {
              pool_free(pool);
-             exit(1);
+             exit(resultflags == 77 ? 77 : 1);
            }
 
          if (!multijob && !feof(fp))