]> git.proxmox.com Git - libxdgmime-perl.git/blobdiff - src/test-mime-data.c
Squashed 'xdgmime-source/' changes from 28b70c4..3e7ee2d
[libxdgmime-perl.git] / src / test-mime-data.c
index 1dbc6368facad80529543098b9bd4d940eb4b64a..14fb94e549d05ed35fece933d442a86b332a0ff1 100644 (file)
@@ -5,28 +5,13 @@
  * Copyright (C) 2005  Red Hat, Inc.
  * Copyright (C) 2005  Matthias Clasen <mclasen@redhat.com>
  *
- * Licensed under the Academic Free License version 2.0
- * Or under the following terms:
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
  */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <libgen.h>
 
 #include "xdgmime.h"
@@ -63,8 +48,8 @@ check_mime_type (const char *mt,
       else
        {
          if (verbose > 0)
-           printf ("%s, '%s' test: expected %s, got %s\n", 
-                   filename, test, mt_expected, mt);
+           fprintf (stderr, "%s, '%s' test: expected %s, got %s\n",
+                    filename, test, mt_expected, mt);
        }
 
     }
@@ -114,7 +99,7 @@ test_by_data (const char *dir,
 
   if (file == NULL)
     {
-      printf ("Could not open %s\n", path);
+      fprintf (stderr, "Could not open %s\n", path);
       error++;
 
       return;
@@ -125,7 +110,7 @@ test_by_data (const char *dir,
 
   if (data == NULL)
     {
-      printf ("Failed to allocate memory for file %s\n", filename);
+      fprintf (stderr, "Failed to allocate memory for file %s\n", filename);
       error++;
 
       fclose (file);
@@ -136,7 +121,7 @@ test_by_data (const char *dir,
   
   if (ferror (file))
     {
-      printf ("Error reading file %s\n", path);
+      fprintf (stderr, "Error reading file %s\n", path);
       error++;
 
       free (data);
@@ -200,7 +185,7 @@ read_from_file (const char *filename)
 
   if (file == NULL)
     {
-      printf ("Could not open %s\n", filename);
+      fprintf (stderr, "Could not open %s\n", filename);
       exit (1);
     }
 
@@ -217,7 +202,7 @@ read_from_file (const char *filename)
       space = strchr (rest, ' ');
       if (!space)
        {
-         printf ("Malformed line in %s:%d\n\t%s\n", filename, lineno, line);
+         fprintf (stderr, "Malformed line in %s:%d\n\t%s\n", filename, lineno, line);
          continue;
        }
 
@@ -312,22 +297,15 @@ main (int argc, char *argv[])
        read_from_file (argv[i]);
     }
   
-  if (error > 0 || failed > 0)
-    {
-      printf ("%d errors, %d comparisons, %d failed",
-             error, total, failed);
-      if (xfailed > 0)
-       printf (" (%d expected)", xfailed);
-      if (xmatch > 0)
-       printf (", %d unexpected successes", xmatch);
-      printf ("\n");
-
-      if (xmatch > 0)
-        return 1;
-      if (xfailed == failed)
-        return 0;
-      return 1;
-    }
-
+  printf ("%d errors, %d comparisons, %d failed",
+          error, total, failed);
+  if (xfailed > 0)
+    printf (" (%d expected)", xfailed);
+  if (xmatch > 0)
+    printf (", %d unexpected successes", xmatch);
+  printf ("\n");
+
+  if (error > 0 || xmatch > 0 || failed != xfailed)
+    return 1;
   return 0;
 }