Lines Matching +full:test +full:- +full:cl
2 # SPDX-License-Identifier: Apache-2.0
3 # -----------------------------------------------------------------------------
4 # Copyright 2020-2023 Arm Limited
10 # http://www.apache.org/licenses/LICENSE-2.0
17 # -----------------------------------------------------------------------------
19 The functional test runner is a set of tests that validate the ``astcenc``
24 Due to the need to validate pixel colors in test images for both LDR and HDR
25 images, these tests rely on an HDRI-enabled build of ImageMagic being available
26 on the system path. To test if the version of ImageMagic on your system is
27 HDRI-enabled run:
29 convert --version
33 Test Tiles
36 Some basic test images, each 8x8 texels and built up from 4 no. 4x4 texel
40 LDR Test Pattern
41 ----------------
51 HDR Test Pattern
52 ----------------
81 # Enable these to always write out, irrespective of test result
93 # LDR test pattern
101 # HDR test pattern
109 LDR_RGB_PSNR_PATTERN = re.compile(r"\s*PSNR \(LDR-RGB\): (.*) dB")
117 These tests are designed to test the command line is handled correctly.
130 Set up a test case.
138 Tear down a test case.
156 str: The path to the test image file on disk.
177 fileName = "%s-%s-1x1.%s" % (profile, image, nameMux[profile][mode])
184 Temporary files are automatically cleaned up when the test tearDown
194 str: The path to the test image file on disk.
236 These tests are designed to test the command line is handled correctly.
272 self.assertEqual(sum(alphaHist[:-1]), 0)
280 sad = numpy.sum(numpy.abs(dat1 - dat2))
290 Get the channel-by-channel root mean square error.
316 self.assertEqual(sum(alphaHist[:-1]), 0)
332 sad = numpy.sum(numpy.square(dat1 - dat2))
346 corners (str or list): The corner or list of corners -- named TL,
347 TR, BL, and BR -- to return.
365 Test if a color is the similar to a reference.
367 Will trigger a test failure if the colors are not within threshold.
405 Execute a positive test.
407 Will trigger a test failure if the subprocess return code is any value
414 test will fail if no pattern match is found.
441 msg = "Exec died with signal %s" % signal.Signals(-rcode).name
458 Test basic LDR compression.
464 command = [self.binary, "-cl", imIn, imOut, "6x6", "-exhaustive"]
470 Test basic LDR sRGB compression.
476 command = [self.binary, "-cs", imIn, imOut, "6x6", "-exhaustive"]
482 Test basic HDR + LDR alpha compression.
488 command = [self.binary, "-ch", imIn, imOut, "6x6", "-exhaustive"]
494 Test basic HDR + HDR alpha compression.
500 command = [self.binary, "-cH", imIn, imOut, "6x6", "-exhaustive"]
506 Test basic LDR decompression.
512 command = [self.binary, "-dl", imIn, imOut]
518 Test basic LDR sRGB decompression.
524 command = [self.binary, "-ds", imIn, imOut]
530 Test basic HDR + LDR alpha decompression.
536 command = [self.binary, "-dh", imIn, imOut]
545 Test basic HDR + HDR alpha decompression.
551 command = [self.binary, "-dH", imIn, imOut]
560 Test basic LDR round-trip
565 command = [self.binary, "-tl", imIn, imOut, "6x6", "-exhaustive"]
571 Test basic LDR sRGB round-trip
576 command = [self.binary, "-ts", imIn, imOut, "6x6", "-exhaustive"]
582 Test basic HDR + LDR alpha round-trip.
587 command = [self.binary, "-th", imIn, imOut, "6x6", "-exhaustive"]
595 Test basic HDR + HDR alpha round-trip.
600 command = [self.binary, "-tH", imIn, imOut, "6x6", "-exhaustive"]
608 Test all valid block sizes are accepted (2D images).
620 command = [self.binary, "-tl", imIn, imOut, blk, "-exhaustive"]
628 Test all valid block sizes are accepted (3D images).
642 command = [self.binary, "-tl", imIn, imOut, blk, "-exhaustive"]
650 Test all valid presets are accepted
652 presets = ["-fastest", "-fast", "-medium",
653 "-thorough", "-verythorough", "-exhaustive"]
660 command = [self.binary, "-tl", imIn, imOut, "4x4", preset]
668 Test valid LDR input file formats.
674 imIn = "./Test/Data/Tiles/ldr.%s" % imgFormat
677 command = [self.binary, "-tl", imIn, imOut, "4x4", "-fast"]
701 Test valid uncompressed LDR output file formats.
710 command = [self.binary, "-tl", imIn, imOut, "4x4", "-fast"]
721 Test valid compressed LDR output file formats.
731 command = [self.binary, "-cl", imIn, imOut, "4x4", "-fast"]
734 command = [self.binary, "-dl", imOut, imOut2]
745 Test valid HDR input file formats.
751 imIn = "./Test/Data/Tiles/hdr.%s" % imgFormat
754 command = [self.binary, "-th", imIn, imOut, "4x4", "-fast"]
765 Test valid uncompressed HDR output file formats.
774 command = [self.binary, "-th", imIn, imOut, "4x4", "-fast"]
785 Test valid compressed HDR output file formats.
795 command = [self.binary, "-ch", imIn, imOut, "4x4", "-fast"]
798 command = [self.binary, "-dh", imOut, imOut2]
809 Test compression of normal textures using PSNR error metrics.
814 self.binary, "-tl",
815 "./Test/Images/Small/LDR-XY/ldr-xy-00.png",
816 decompFile, "5x5", "-exhaustive"]
820 command.append("-normal")
823 # Note that this test simply asserts that the "-normal_psnr" is
824 # connected and affects the output. We don't test it does something
825 # useful; that it outside the scope of this test case.
830 Test compression of normal textures using perceptual error metrics.
835 self.binary, "-tl",
836 "./Test/Images/Small/LDR-XY/ldr-xy-00.png",
837 decompFile, "4x4", "-exhaustive"]
841 command.append("-normal")
842 command.append("-perceptual")
845 # Note that this test simply asserts that the "-normal -percep" is
846 # connected and affects the output. We don't test it does something
847 # useful; that it outside the scope of this test case.
852 Test compression swizzles.
854 # The swizzles to test
863 self.binary, "-tl",
864 "./Test/Data/Tiles/ldr.png",
865 decompFile, "4x4", "-exhaustive",
866 "-esw", swizzle]
878 Test decompression swizzles.
880 # The swizzles to test
889 self.binary, "-tl",
890 "./Test/Data/Tiles/ldr.png",
891 decompFile, "4x4", "-exhaustive",
892 "-dsw", swizzle]
904 Test compression and decompression swizzles
910 self.binary, "-tl",
911 "./Test/Data/Tiles/ldr.png",
912 decompFile, "4x4", "-exhaustive",
913 "-esw", "gbar", "-dsw", "argb"]
925 Test LDR image flip on compression.
931 self.binary, "-cl",
932 "./Test/Data/Tiles/ldr.png",
933 compFile, "4x4", "-fast", "-yflip"]
937 # Decompress a non-flipped image
941 self.binary, "-dl",
947 # Compare TL (0, 0) with BL - should match
956 Test LDR image flip on decompression.
958 # Compress a non-flipped image
962 self.binary, "-cl",
963 "./Test/Data/Tiles/ldr.png",
964 compFile, "4x4", "-fast"]
972 self.binary, "-dl",
974 decompFile, "-yflip"]
978 # Compare TL (0, 0) with BL - should match
987 Test LDR image flip on roundtrip (no flip should occur).
993 self.binary, "-tl",
994 "./Test/Data/Tiles/ldr.png",
995 decompFile, "4x4", "-fast", "-yflip"]
999 # Compare TL (0, 0) with TL - should match - i.e. no flip
1009 Test channel weighting.
1011 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1016 self.binary, "-tl",
1017 inputFile, decompFile, "4x4", "-medium"]
1022 # Note: Using -cw can result in a worse result than not using -cw,
1023 # with regressions in RMSE for the high-weighted channel. This is
1026 # selected test image and these settings, but might start to fail in
1029 # Test each channel with a high weight
1033 command2 = command + ["-cw"] + cwArg
1040 Test partition count limit.
1042 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1047 self.binary, "-tl",
1048 inputFile, decompFile, "4x4", "-medium"]
1053 command += ["-partitioncountlimit", "1"]
1062 Test partition index limit.
1064 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1069 self.binary, "-tl",
1070 inputFile, decompFile, "4x4", "-medium"]
1075 command += ["-2partitionindexlimit", "1"]
1084 Test partition index limit.
1086 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1091 self.binary, "-tl",
1092 inputFile, decompFile, "4x4", "-medium"]
1097 command += ["-3partitionindexlimit", "1"]
1106 Test partition index limit.
1108 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1113 self.binary, "-tl",
1114 inputFile, decompFile, "4x4", "-medium"]
1119 command += ["-4partitionindexlimit", "1"]
1128 Test block mode limit.
1130 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1135 self.binary, "-tl",
1136 inputFile, decompFile, "4x4", "-medium"]
1141 command += ["-blockmodelimit", "25"]
1150 Test refinement limit.
1152 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1156 self.binary, "-tl",
1157 inputFile, decompFile, "4x4", "-medium"]
1162 command += ["-refinementlimit", "1"]
1171 Test candidate limit.
1173 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1177 self.binary, "-tl",
1178 inputFile, decompFile, "4x4", "-medium"]
1183 command += ["-candidatelimit", "1"]
1192 Test db cutoff limit.
1194 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1199 self.binary, "-tl",
1200 inputFile, decompFile, "4x4", "-medium"]
1205 command += ["-dblimit", "10"]
1214 Test 2 partition early limit.
1216 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1221 self.binary, "-tl",
1222 inputFile, decompFile, "4x4", "-medium"]
1227 command += ["-2partitionlimitfactor", "1.0"]
1236 Test 3 partition early limit.
1238 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1243 self.binary, "-tl",
1244 inputFile, decompFile, "4x4", "-medium"]
1249 command += ["-3partitionlimitfactor", "1.0"]
1258 Test 2 plane correlation limit.
1260 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1265 self.binary, "-tl",
1266 inputFile, decompFile, "4x4", "-medium"]
1271 command += ["-2planelimitcorrelation", "0.1"]
1280 Test 2 partition partitioning candidate limit.
1282 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1287 self.binary, "-tl",
1288 inputFile, decompFile, "4x4", "-medium"]
1293 command += ["-2partitioncandidatelimit", "1"]
1302 Test 3 partition partitioning candidate limit.
1304 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1309 self.binary, "-tl",
1310 inputFile, decompFile, "4x4", "-medium"]
1315 command += ["-3partitioncandidatelimit", "1"]
1324 Test 4 partition partitioning candidate limit.
1326 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1331 self.binary, "-tl",
1332 inputFile, decompFile, "4x4", "-medium"]
1337 command += ["-4partitioncandidatelimit", "1"]
1342 # even for -exhaustive, BUT command line option must be accepted and
1346 @unittest.skipIf(os.cpu_count() == 1, "Cannot test on single core host")
1349 Test codec thread count.
1351 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1356 self.binary, "-tl",
1357 inputFile, decompFile, "4x4", "-medium"]
1361 refTime = time.time() - start
1363 command += ["-j", "1"]
1366 testTime = time.time() - start
1368 # Test time should get slower with fewer threads
1373 Test silent
1375 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1380 self.binary, "-tl",
1381 inputFile, decompFile, "4x4", "-medium"]
1384 command += ["-silent"]
1394 Test that a round-trip and a file-based round-trip give same result.
1396 inputFile = "./Test/Images/Small/LDR-RGBA/ldr-rgba-00.png"
1401 # Compute the first image using a direct round-trip
1402 command = [self.binary, "-tl", inputFile, p1DecFile, "4x4", "-medium"]
1405 # Compute the first image using a file-based round-trip
1406 command = [self.binary, "-cl", inputFile, p2CompFile, "4x4", "-medium",
1407 "-decode_unorm8"]
1409 command = [self.binary, "-dl", p2CompFile, p2DecFile]
1422 These tests are designed to test that bad inputs to the command line are
1425 Note that many tests are mutations of a valid positive test command line,
1427 of these tests include a *positive test* to ensure that the starting point
1434 Execute a negative test.
1436 Test will automatically fail if:
1439 * The subprocess correctly returned non-zero, but without any error
1454 # test log verbosity on failure by avoiding nested exceptions
1480 msg = "Exec died with signal %s" % signal.Signals(-rcode).name
1490 Execute a negative test with command line argument omission.
1495 the test case is a valid test).
1497 Test will automatically fail if:
1505 omit = len(command) - subLen
1513 Test -cl with missing arguments.
1517 self.binary, "-cl",
1520 "4x4", "-fast"]
1526 Test -cl with a missing input file.
1530 self.binary, "-cl",
1531 "./Test/Data/missing.png",
1533 "4x4", "-fast"]
1539 Test -cl with a missing input file in an array slice.
1543 self.binary, "-cl",
1544 "./Test/Data/Tiles/ldr.png",
1546 "3x3x3", "-fast", "-zdim", "3"]
1552 Test -cl with an unknown input file extension.
1554 # Build an otherwise valid command with the test flaw
1556 self.binary, "-cl",
1557 "./Test/Data/empty.unk",
1559 "4x4", "-fast"]
1565 Test -cl with a missing output directory.
1567 # Build an otherwise valid command with the test flaw
1569 self.binary, "-cl",
1571 "./DoesNotExist/test.astc",
1572 "4x4", "-fast"]
1578 Test -cl with an unknown output file extension.
1580 # Build an otherwise valid command with the test flaw
1582 self.binary, "-cl",
1584 "./test.aastc",
1585 "4x4", "-fast"]
1591 Test -cl with an invalid block size.
1599 "4x4x4x", # Over-long 3D block size
1600 "4xe", # Illegal non-numeric character
1601 "4x4e" # Additional non-numeric character
1604 # Build an otherwise valid command with the test flaw
1606 self.binary, "-cl",
1609 "4x4", "-fast"]
1611 # Test that the underlying command is valid
1622 Test -cl with an invalid encoding preset.
1624 # Build an otherwise valid command with the test flaw
1626 self.binary, "-cl",
1629 "4x4", "-fastt"]
1635 Test -cl with an unknown additional argument.
1637 # Build an otherwise valid command with the test flaw
1639 self.binary, "-cl",
1642 "4x4", "-fast", "-unknown"]
1648 Test -cl with a 2D block size and 3D input data.
1650 # Build an otherwise valid command with the test flaw
1656 self.binary, "-cl",
1657 "./Test/Data/Tiles/ldr.png",
1659 "4x4", "-fast", "-zdim", "2"]
1665 Test -cl with a 2D block size and 3D input data.
1669 self.binary, "-cl",
1670 "./Test/Data/Tiles/ldr.png",
1672 "4x4x4", "-fast", "-zdim", "2"]
1679 Test -tl with missing arguments.
1683 self.binary, "-tl",
1686 "4x4", "-fast"]
1693 Test -tl with a missing input file.
1697 self.binary, "-tl",
1698 "./Test/Data/missing.png",
1700 "4x4", "-fast"]
1706 Test -tl with an unknown input file extension.
1708 # Build an otherwise valid command with the test flaw
1710 self.binary, "-tl",
1711 "./Test/Data/empty.unk",
1713 "4x4", "-fast"]
1719 Test -tl with a missing output directory.
1721 # Build an otherwise valid command with the test flaw
1723 self.binary, "-tl",
1725 "./DoesNotExist/test.png",
1726 "4x4", "-fast"]
1732 Test -tl with an invalid block size.
1740 "4x4x4x", # Over-long 3D block size
1741 "4xe", # Illegal non-numeric character
1742 "4x4e" # Additional non-numeric character
1745 # Build an otherwise valid command with the test flaw
1747 self.binary, "-tl",
1750 "4x4", "-fast"]
1752 # Test that the underlying command is valid
1763 Test -tl with an invalid encoding preset.
1765 # Build an otherwise valid command with the test flaw
1767 self.binary, "-tl",
1770 "4x4", "-fastt"]
1776 Test -tl with an unknown additional argument.
1778 # Build an otherwise valid command with the test flaw
1780 self.binary, "-tl",
1783 "4x4", "-fast", "-unknown"]
1789 Test -dl with missing arguments.
1793 self.binary, "-dl",
1802 Test -dl with a missing output directory.
1804 # Build an otherwise valid command with the test flaw
1806 self.binary, "-dl",
1808 "./DoesNotExist/test.png"]
1814 Test -cl with -a and missing arguments.
1818 self.binary, "-cl",
1821 "4x4", "-fast",
1822 "-a", "2"]
1829 Test -cl with -cw and missing arguments.
1833 self.binary, "-cl",
1836 "4x4", "-fast",
1837 "-cw", "0", "1", "2", "3"]
1844 Test -cl with -2partitionindexlimit and missing arguments.
1848 self.binary, "-cl",
1851 "4x4", "-fast",
1852 "-2partitionindexlimit", "3"]
1859 Test -cl with -3partitionindexlimit and missing arguments.
1863 self.binary, "-cl",
1866 "4x4", "-fast",
1867 "-3partitionindexlimit", "3"]
1874 Test -cl with -4partitionindexlimit and missing arguments.
1878 self.binary, "-cl",
1881 "4x4", "-fast",
1882 "-4partitionindexlimit", "3"]
1889 Test -cl with -2partitioncandidatelimit and missing arguments.
1893 self.binary, "-cl",
1896 "4x4", "-fast",
1897 "-2partitioncandidatelimit", "1"]
1904 Test -cl with -3partitioncandidatelimit and missing arguments.
1908 self.binary, "-cl",
1911 "4x4", "-fast",
1912 "-3partitioncandidatelimit", "3"]
1920 Test -cl with -4partitioncandidatelimit and missing arguments.
1924 self.binary, "-cl",
1927 "4x4", "-fast",
1928 "-4partitioncandidatelimit", "3"]
1935 Test -cl with -blockmodelimit and missing arguments.
1939 self.binary, "-cl",
1942 "4x4", "-fast",
1943 "-blockmodelimit", "3"]
1950 Test -cl with -refinementlimit and missing arguments.
1954 self.binary, "-cl",
1957 "4x4", "-fast",
1958 "-refinementlimit", "3"]
1965 Test -cl with -dblimit and missing arguments.
1969 self.binary, "-cl",
1972 "4x4", "-fast",
1973 "-dblimit", "3"]
1980 Test -cl with -2partitionlimitfactor and missing arguments.
1984 self.binary, "-cl",
1987 "4x4", "-fast",
1988 "-2partitionlimitfactor", "3"]
1995 Test -cl with -3partitionlimitfactor and missing arguments.
1999 self.binary, "-cl",
2002 "4x4", "-fast",
2003 "-3partitionlimitfactor", "3"]
2010 Test -cl with -2planelimitcorrelation and missing arguments.
2014 self.binary, "-cl",
2017 "4x4", "-fast",
2018 "-2planelimitcorrelation", "0.66"]
2025 Test -cl with -esw and missing arguments.
2029 self.binary, "-cl",
2032 "4x4", "-fast",
2033 "-esw", "rgb1"]
2040 Test -cl with -esw and invalid swizzles.
2058 self.binary, "-cl",
2061 "4x4", "-fast",
2062 "-esw", "rgba"]
2072 Test -cl with -ssw and missing arguments.
2076 self.binary, "-cl",
2079 "4x4", "-fast",
2080 "-ssw", "rgba"]
2087 Test -cl with -ssw and invalid swizzles.
2102 self.binary, "-cl",
2105 "4x4", "-fast",
2106 "-ssw", "rgba"]
2116 Test -dl with -dsw and missing arguments.
2120 self.binary, "-dl",
2123 "-dsw", "rgb1"]
2130 Test -dl with -dsw and invalid swizzles.
2148 self.binary, "-dl",
2151 "-dsw", "rgba"]
2161 Test -ch with -mpsnr and missing arguments.
2165 self.binary, "-ch",
2168 "4x4", "-fast",
2169 "-mpsnr", "-5", "5"]
2187 parser.add_argument("--encoder", dest="encoder", default="avx2",
2188 choices=coders, help="test encoder variant")
2191 # Set the encoder for this test run