GraphicsMagick: Add a simple bitstream test to test suite. Tidy ...

GraphicsMagick Commits <[email protected]> Fri, 01 Nov 2024 10:47:41 -0500
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.31929.1730476076.1470.graphicsmagick-commit@lists.sourceforge.net>
changeset 88c662852f31 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=88c662852f31
summary: Add a simple bitstream test to test suite. Tidy bitstream code.

diffstat:

 ChangeLog                              |   6 +++
 Makefile.in                            |   1 +
 VisualMagick/installer/inc/version.isx |   4 +-
 magick/studio.h                        |   4 +-
 magick/version.h                       |   4 +-
 tests/Makefile.am                      |   1 +
 tests/bitstream.c                      |  64 ++++++++++++++++++---------------
 tests/bitstream.tap                    |  12 ++++++
 tests/maptest.c                        |   8 ++--
 www/ChangeLog.html                     |   7 +++
 10 files changed, 72 insertions(+), 39 deletions(-)

diffs (321 lines):

diff -r 2ef812207a00 -r 88c662852f31 ChangeLog
--- a/ChangeLog	Thu Oct 31 15:34:12 2024 -0500
+++ b/ChangeLog	Fri Nov 01 10:47:22 2024 -0500
@@ -1,3 +1,9 @@
+2024-11-01  Bob Friesenhahn  <[email protected]>
+
+	* tests/bitstream.c: Tidy printfs and exit status.
+
+	* tests/bitstream.tap: Add a simple bitstream test to test suite.
+
 2024-10-31  Bob Friesenhahn  <[email protected]>
 
 	* magick/render.c (DrawImage): Add more validity checks for color
diff -r 2ef812207a00 -r 88c662852f31 Makefile.in
--- a/Makefile.in	Thu Oct 31 15:34:12 2024 -0500
+++ b/Makefile.in	Fri Nov 01 10:47:22 2024 -0500
@@ -4384,6 +4384,7 @@
 tests_drawtest_LDADD = $(LIBMAGICK)
 TESTS_XFAIL_TESTS = 
 TESTS_TESTS = \
+	tests/bitstream.tap \
 	tests/constitute.tap \
 	tests/drawtests.tap \
 	tests/rwblob.tap \
diff -r 2ef812207a00 -r 88c662852f31 VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Thu Oct 31 15:34:12 2024 -0500
+++ b/VisualMagick/installer/inc/version.isx	Fri Nov 01 10:47:22 2024 -0500
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020241031"
-#define public MagickPackageReleaseDate "snapshot-20241031"
+#define public MagickPackageVersionAddendum ".020241101"
+#define public MagickPackageReleaseDate "snapshot-20241101"
diff -r 2ef812207a00 -r 88c662852f31 magick/studio.h
--- a/magick/studio.h	Thu Oct 31 15:34:12 2024 -0500
+++ b/magick/studio.h	Fri Nov 01 10:47:22 2024 -0500
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2003 - 2022 GraphicsMagick Group
+  Copyright (C) 2003 - 2024 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
 
   This program is covered by multiple licenses, which are described in
@@ -320,6 +320,7 @@
 #  define ReadCommandlLine(argc,argv)
 #  define SetNotifyHandlers
 #  define MagickSleep(seconds) sleep(seconds)
+#  define MAGICK_DEVNULL "/dev/null"
 #endif
 
 #if defined(MSWINDOWS)
@@ -336,6 +337,7 @@
     SetErrorHandler(NTErrorHandler); \
     SetWarningHandler(NTWarningHandler)
 #  define MagickSleep(seconds)  Sleep(seconds*1000)
+#  define MAGICK_DEVNULL "NUL"
 #  if !defined(HAVE_TIFFCONF_H)
 #    define HAVE_TIFFCONF_H
 #  endif
diff -r 2ef812207a00 -r 88c662852f31 magick/version.h
--- a/magick/version.h	Thu Oct 31 15:34:12 2024 -0500
+++ b/magick/version.h	Fri Nov 01 10:47:22 2024 -0500
@@ -38,8 +38,8 @@
 #define MagickLibVersion  0x282502
 #define MagickLibVersionText  "1.4"
 #define MagickLibVersionNumber 28,25,2
-#define MagickChangeDate   "20241031"
-#define MagickReleaseDate  "snapshot-20241031"
+#define MagickChangeDate   "20241101"
+#define MagickReleaseDate  "snapshot-20241101"
 
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r 2ef812207a00 -r 88c662852f31 tests/Makefile.am
--- a/tests/Makefile.am	Thu Oct 31 15:34:12 2024 -0500
+++ b/tests/Makefile.am	Fri Nov 01 10:47:22 2024 -0500
@@ -43,6 +43,7 @@
 TESTS_XFAIL_TESTS =
 
 TESTS_TESTS = \
+	tests/bitstream.tap \
 	tests/constitute.tap \
 	tests/drawtests.tap \
 	tests/rwblob.tap \
diff -r 2ef812207a00 -r 88c662852f31 tests/bitstream.c
--- a/tests/bitstream.c	Thu Oct 31 15:34:12 2024 -0500
+++ b/tests/bitstream.c	Fri Nov 01 10:47:22 2024 -0500
@@ -34,6 +34,7 @@
     result=0;
 
   unsigned int
+    status=EXIT_SUCCESS,
     quantum;
 
   FILE
@@ -41,17 +42,17 @@
 
   if (argc < 2)
     {
-      (void) printf("usage: %s read/write/test args\n", argv[0]);
-      exit(1);
+      (void) fprintf(stderr, "usage: %s read/write/test args\n", argv[0]);
+      exit(EXIT_FAILURE);
     }
 
   mode = argv[1];
 
-  file=fopen("/dev/null","wb+");
+  file=fopen(MAGICK_DEVNULL,"wb+");
   if (!file)
     {
-      (void) printf("Failed to open file\n");
-      exit(1);
+      (void) fprintf(stderr, "Failed to open file %s\n", MAGICK_DEVNULL);
+      exit(EXIT_FAILURE);
     }
 
   if (strcmp(mode,"read") == 0)
@@ -67,28 +68,28 @@
 
       if (argc != 4)
         {
-          (void) printf("usage: %s read repetitions bits\n", argv[0]);
-          exit(1);
+          (void) fprintf(stderr, "usage: %s read repetitions bits\n", argv[0]);
+          exit(EXIT_FAILURE);
         }
 
       reps = atoi(argv[2]);
       if ((reps == 0) || (reps > INT_MAX))
         {
-          (void) printf("Unreasonable reps %u!\n", reps);
-          exit(1);
+          (void) fprintf(stderr, "Unreasonable reps %u!\n", reps);
+          exit(EXIT_FAILURE);
         }
       bits = atoi(argv[3]);
       if ((bits == 0) || (bits > 32))
         {
-          (void) printf("Unreasonable bits %u!\n", bits);
-          exit(1);
+          (void) fprintf(stderr, "Unreasonable bits %u!\n", bits);
+          exit(EXIT_FAILURE);
         }
 
       bytes=(unsigned char *)malloc((size_t) reps*2);
       if (!bytes)
         {
-          (void) printf("Failed to allocate %lu bytes\n", (unsigned long) reps*2);
-          exit(1);
+          (void) fprintf(stderr, "Failed to allocate %lu bytes\n", (unsigned long) reps*2);
+          exit(EXIT_FAILURE);
         }
       for (rep=0; rep < reps*2; rep++)
         bytes[rep]=(unsigned char) rep;
@@ -118,28 +119,28 @@
 
       if (argc != 4)
         {
-          (void) printf("usage: %s write repetitions bits\n", argv[0]);
-          exit(1);
+          (void) fprintf(stderr, "usage: %s write repetitions bits\n", argv[0]);
+          exit(EXIT_FAILURE);
         }
 
       reps = atoi(argv[2]);
       if ((reps == 0) || (reps > INT_MAX))
         {
-          (void) printf("Unreasonable reps %u!\n", reps);
-          exit(1);
+          (void) fprintf(stderr, "Unreasonable reps %u!\n", reps);
+          exit(EXIT_FAILURE);
         }
       bits = atoi(argv[3]);
       if ((bits == 0) || (bits > 32))
         {
-          (void) printf("Unreasonable bits %u!\n", bits);
-          exit(1);
+          (void) fprintf(stderr, "Unreasonable bits %u!\n", bits);
+          exit(EXIT_FAILURE);
         }
 
       bytes=(unsigned char *)calloc(reps,2);
       if (!bytes)
         {
-          (void) printf("Failed to allocate %lu bytes\n", (unsigned long) reps*2);
-          exit(1);
+          (void) fprintf(stderr, "Failed to allocate %lu bytes\n", (unsigned long) reps*2);
+          exit(EXIT_FAILURE);
         }
       (void) memset(bytes,0,(size_t) reps*2);
 
@@ -177,15 +178,15 @@
 
       if (argc != 3)
         {
-          (void) printf("usage: %s test max_bits\n", argv[0]);
-          exit(1);
+          (void) fprintf(stderr, "usage: %s test max_bits\n", argv[0]);
+          exit(EXIT_FAILURE);
         }
 
       max_bits = atoi(argv[2]);
       if ((max_bits == 0) || (max_bits > 32))
         {
-          (void) printf("Unreasonable max_bits %u!\n", max_bits);
-          exit(1);
+          (void) fprintf(stderr, "Unreasonable max_bits %u!\n", max_bits);
+          exit(EXIT_FAILURE);
         }
 
       for (bits=1 ; bits <= max_bits; bits++)
@@ -201,12 +202,13 @@
           bytes=(unsigned char *)malloc(allocated_bytes);
           if (!bytes)
             {
-              (void) printf("Failed to allocate %lu bytes\n",(unsigned long) allocated_bytes);
-              exit(1);
+              (void) fprintf(stderr, "Failed to allocate %lu bytes\n",(unsigned long) allocated_bytes);
+              exit(EXIT_FAILURE);
             }
           else
             {
-              (void) printf("Bits %02u, Allocated %lu bytes\n",bits, (unsigned long) allocated_bytes);
+              (void) fprintf(stdout, "Bits %02u, Allocated %lu bytes\n",bits, (unsigned long) allocated_bytes);
+              (void) fflush(stdout);
             }
           (void) memset(bytes,0xff,allocated_bytes);
 
@@ -219,8 +221,10 @@
               read_quantum=MagickBitStreamMSBRead(&read_stream,bits);
               if (read_quantum != write_quantum)
                 {
-                  (void) printf("mismatch: bits=%u write_quantum=%u read_quantum=%u\n",
+                  (void) fprintf(stderr, "mismatch: bits=%u write_quantum=%u read_quantum=%u\n",
                          bits,write_quantum,read_quantum);
+                  status = EXIT_FAILURE;
+                  break;
                 }
             }
 
@@ -231,5 +235,5 @@
   (void) fprintf(file,"result=%u\n",result);
   (void) fclose(file);
 
-  return 0;
+  return status;
 }
diff -r 2ef812207a00 -r 88c662852f31 tests/bitstream.tap
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/bitstream.tap	Fri Nov 01 10:47:22 2024 -0500
@@ -0,0 +1,12 @@
+#!/bin/sh
+# -*- shell-script -*-
+# Copyright (C) 2024 GraphicsMagick Group
+# Test bitstream algorithm
+. ./common.shi
+. ${top_srcdir}/tests/common.shi
+
+num_tests=1
+max_bits=16 # up to 32 bits supported, but test takes a lot of memory!
+test_plan_fn ${num_tests}
+test_command_fn "bitstream 1-${max_bits} bits" ${MEMCHECK} ./bitstream test ${max_bits}
+:
diff -r 2ef812207a00 -r 88c662852f31 tests/maptest.c
--- a/tests/maptest.c	Thu Oct 31 15:34:12 2024 -0500
+++ b/tests/maptest.c	Fri Nov 01 10:47:22 2024 -0500
@@ -1,6 +1,6 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
- 
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
@@ -8,7 +8,7 @@
  Test MagickMap key,value map functionality
 
  Written by Bob Friesenhahn <[email protected]>
- 
+
 */
 
 #include <magick/api.h>
@@ -28,7 +28,7 @@
 int main ( int argc, char **argv )
 {
   int
-    exit_status = 0,
+    exit_status = EXIT_SUCCESS,
     i;
 
   ExceptionInfo
@@ -116,7 +116,7 @@
   (void) printf("Add entry for key \"%s\" and then iterate forward ...\n",
                 KeyVal[i].key);
 
-  iterator=MagickMapAllocateIterator(map);  
+  iterator=MagickMapAllocateIterator(map);
   while(MagickMapIterateNext(iterator,&key))
     (void) printf("key=%s value=%s\n",key,
                   (char *)MagickMapDereferenceIterator(iterator,0));
diff -r 2ef812207a00 -r 88c662852f31 www/ChangeLog.html
--- a/www/ChangeLog.html	Thu Oct 31 15:34:12 2024 -0500
+++ b/www/ChangeLog.html	Fri Nov 01 10:47:22 2024 -0500
@@ -38,6 +38,13 @@
 
 <main id="graphicsmagick-changelog">
 <h1 class="title">GraphicsMagick ChangeLog</h1>
+<p>2024-11-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li><p>tests/bitstream.c: Tidy printfs and exit status.</p></li>
+<li><p>tests/bitstream.tap: Add a simple bitstream test to test suite.</p></li>
+</ul>
+</blockquote>
 <p>2024-10-31  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">