From 09b4ce6d9b7f7191c300cf4df706ab4eac90be9f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 6 Oct 2019 10:55:19 +0100 Subject: [PATCH] test gifload for fd leaks --- test/test_descriptors.c | 15 +++++++++++---- test/test_descriptors.sh | 9 +++++++++ test/variables.sh.in | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/test/test_descriptors.c b/test/test_descriptors.c index d2740aad..9ae6cce3 100644 --- a/test/test_descriptors.c +++ b/test/test_descriptors.c @@ -39,6 +39,9 @@ main( int argc, char **argv ) if( VIPS_INIT( argv[0] ) ) vips_error_exit( "unable to start" ); + if( argc != 2 ) + vips_error_exit( "usage: %s test-image", argv[0] ); + vips_snprintf( fd_dir, 256, "/proc/%d/fd", getpid() ); n_files = count_files( fd_dir ); if( n_files == -1 ) @@ -57,7 +60,8 @@ main( int argc, char **argv ) NULL )) ) vips_error_exit( NULL ); if( count_files( fd_dir ) != n_files ) - vips_error_exit( "fd not closed after header read" ); + vips_error_exit( "%s: fd not closed after header read", + argv[1] ); /* We should be able to read a chunk near the top, then have the fd * closed again. @@ -67,7 +71,8 @@ main( int argc, char **argv ) vips_error_exit( NULL ); g_object_unref( x ); if( count_files( fd_dir ) != n_files ) - vips_error_exit( "fd not closed after first read" ); + vips_error_exit( "%s: fd not closed after first read", + argv[1] ); /* We should be able to read again, a little further down, and have * the input restarted and closed again. @@ -77,7 +82,8 @@ main( int argc, char **argv ) vips_error_exit( NULL ); g_object_unref( x ); if( count_files( fd_dir ) != n_files ) - vips_error_exit( "fd not closed after second read" ); + vips_error_exit( "%s: fd not closed after second read", + argv[1] ); /* Clean up, and we should still just have three open. */ @@ -85,7 +91,8 @@ main( int argc, char **argv ) vips_shutdown(); if( count_files( fd_dir ) != n_files ) - vips_error_exit( "fd not closed after shutdown" ); + vips_error_exit( "%s: fd not closed after shutdown", + argv[1] ); return( 0 ); } diff --git a/test/test_descriptors.sh b/test/test_descriptors.sh index 17f762bb..648d714e 100755 --- a/test/test_descriptors.sh +++ b/test/test_descriptors.sh @@ -10,3 +10,12 @@ set -e if test_supported jpegload; then ./test_descriptors $image fi + +if test_supported heifload; then + # ./test_descriptors $test_images/Example1.heic + echo +fi + +if test_supported gifload; then + ./test_descriptors $test_images/cogs.gif +fi diff --git a/test/variables.sh.in b/test/variables.sh.in index f33976ad..0e4c3136 100644 --- a/test/variables.sh.in +++ b/test/variables.sh.in @@ -11,3 +11,17 @@ vipsheader=$top_srcdir/tools/vipsheader # we need bc to use '.' for a decimal separator export LC_NUMERIC=C + +# test for file format supported +test_supported() { + format=$1 + + if $vips $format > /dev/null 2>&1; then + result=0 + else + echo "support for $format not configured, skipping test" + result=1 + fi + + return $result +}