Skip to content

Commit

Permalink
Added a few more failure tests to improve test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfandrich committed Nov 4, 2018
1 parent 8639de6 commit 0543e1b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
6 changes: 6 additions & 0 deletions test/check-add-tags.sh
Expand Up @@ -142,6 +142,12 @@ $EXIFEXE --no-fixup --ifd=0 --tag=XResolution --set-value='12 2 3' -o "$dstimg"
check_result
append_image

echo Create invalid ASCII--too large
$EXIFEXE --no-fixup --ifd=0 --tag=ImageDescription --set-value="`printf '%66000s' foo`" -o "$dstimg" "$srcimg" >/dev/null
test "$?" -eq 1
check_result
append_image

# Check the resulting EXIF file
$EXIFEXE -m -i "$srcimg" >"$tmpfile"
"$DIFFEXE" - "$tmpfile" <<EOF
Expand Down
25 changes: 18 additions & 7 deletions test/check-show-description.sh
Expand Up @@ -10,55 +10,66 @@ LANG=C; export LANG
LANGUAGE=C; export LANGUAGE

echo Test tag 1 using text name
$EXIFEXE --ifd=Interoperability --tag=InteroperabilityIndex --show-description > "$tmpfile"
$EXIFEXE --ifd=Interoperability --tag=InteroperabilityIndex --show-description > "$tmpfile" 2>&1
test $? -eq 0 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
Tag 'Interoperability Index' (0x0001, 'InteroperabilityIndex'): Indicates the identification of the Interoperability rule. Use "R98" for stating ExifR98 Rules. Four bytes used including the termination code (NULL). see the separate volume of Recommended Exif Interoperability Rules (ExifR98) for other tags used for ExifR98.
EOF
test $? -eq 0 || exit 1

echo Test tag with same number but different IFD using short option names
$EXIFEXE --ifd GPS -t1 -s > "$tmpfile"
$EXIFEXE --ifd GPS -t1 -s > "$tmpfile" 2>&1
test $? -eq 0 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
Tag 'North or South Latitude' (0x0001, 'GPSLatitudeRef'): Indicates whether the latitude is north or south latitude. The ASCII value 'N' indicates north latitude, and 'S' is south latitude.
EOF
test $? -eq 0 || exit 1

echo Test tag of 0
$EXIFEXE --ifd=GPS --tag=0 --show-description > "$tmpfile"
$EXIFEXE --ifd=GPS --tag=0 --show-description > "$tmpfile" 2>&1
test $? -eq 0 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
Tag 'GPS Tag Version' (0x0000, 'GPSVersionID'): Indicates the version of <GPSInfoIFD>. The version is given as 2.0.0.0. This tag is mandatory when <GPSInfo> tag is present. (Note: The <GPSVersionID> tag is given in bytes, unlike the <ExifVersion> tag. When the version is 2.0.0.0, the tag value is 02000000.H).
EOF
test $? -eq 0 || exit 1

echo Test --machine-readable using hexadecimal tag
$EXIFEXE --ifd=1 --tag=0x103 --show-description --machine-readable > "$tmpfile"
$EXIFEXE --ifd=1 --tag=0x103 --show-description --machine-readable > "$tmpfile" 2>&1
test $? -eq 0 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
0x0103 Compression Compression The compression scheme used for the image data. When a primary image is JPEG compressed, this designation is not necessary and is omitted. When thumbnails use JPEG compression, this tag value is set to 6.
EOF
test $? -eq 0 || exit 1

echo Test tag with number not in IFD
$EXIFEXE --ifd=EXIF --tag=1 --show-description > "$tmpfile"
$EXIFEXE --ifd=EXIF --tag=1 --show-description > "$tmpfile" 2>&1
test $? -eq 1 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
Unknown Tag
EOF
test $? -eq 0 || exit 1

echo Test tag with number > 65535
$EXIFEXE --ifd=GPS --tag=65537 --show-description > "$tmpfile"
$EXIFEXE --ifd=GPS --tag=65537 --show-description > "$tmpfile" 2>&1
test $? -eq 1 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
Unknown Tag
EOF
test $? -eq 0 || exit 1

echo Test invalid tag name
$EXIFEXE --ifd=0 --tag=Xyzzy --show-description > "$tmpfile" 2>&1
test $? -eq 1 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
Invalid tag 'Xyzzy'!
EOF
test $? -eq 0 || exit 1

echo Test tag with invalid IFD
$EXIFEXE --ifd=XYZZY --tag=0x100 --show-description > "$tmpfile"
$EXIFEXE --ifd=XYZZY --tag=0x100 --show-description > "$tmpfile" 2>&1
test $? -eq 1 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
Invalid IFD 'XYZZY'. Valid IFDs are '0', '1', 'EXIF', 'GPS', and 'Interoperability'.
EOF
test $? -eq 0 || exit 1

Expand Down
8 changes: 8 additions & 0 deletions test/check-thumbnail.sh
Expand Up @@ -135,6 +135,14 @@ Pixel Y Dimension |0
EOF
test $? -eq 0 || exit 1

echo Extract thumbnail from file without thumbnail
$EXIFEXE --extract-thumbnail --output="$tmpimg" "$tmpimg2" > "$tmpfile" 2>&1
test $? -eq 1 || { echo Incorrect return code; exit 1; }
$DIFFEXE - "$tmpfile" <<EOF
'check-thumbnail-image2.jpg' does not contain a thumbnail!
EOF
test $? -eq 0 || exit 1

echo Remove thumbnail on file without thumbnail
$EXIFEXE --remove-thumbnail --output="$tmpimg" "$tmpimg2" 2>&1 | sed -e "/Date and Time/s/|.*$/|/" > "$tmpfile"
test $? -eq 0 || { echo Incorrect return code; exit 1; }
Expand Down

0 comments on commit 0543e1b

Please sign in to comment.