Tom Finegan | 4f7e104 | 2017-03-01 10:25:16 -0800 | [diff] [blame] | 1 | ## |
| 2 | ## Copyright (c) 2017, Alliance for Open Media. All rights reserved |
| 3 | ## |
| 4 | ## This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | ## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | ## was not distributed with this source code in the LICENSE file, you can |
| 7 | ## obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | ## Media Patent License 1.0 was not distributed with this source code in the |
| 9 | ## PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
| 10 | ## |
| 11 | |
Tom Finegan | 0af2732 | 2017-08-30 09:13:17 -0700 | [diff] [blame] | 12 | set(AOM_TEST_DATA_FILE_NAMES |
| 13 | "hantro_collage_w352h288.yuv" |
| 14 | "hantro_odd.yuv" |
| 15 | "park_joy_90p_10_420.y4m" |
| 16 | "park_joy_90p_10_422.y4m" |
| 17 | "park_joy_90p_10_444.y4m" |
Tom Finegan | 0af2732 | 2017-08-30 09:13:17 -0700 | [diff] [blame] | 18 | "park_joy_90p_12_420.y4m" |
| 19 | "park_joy_90p_12_422.y4m" |
| 20 | "park_joy_90p_12_444.y4m" |
Tom Finegan | 0af2732 | 2017-08-30 09:13:17 -0700 | [diff] [blame] | 21 | "park_joy_90p_8_420_a10-1.y4m" |
| 22 | "park_joy_90p_8_420.y4m" |
| 23 | "park_joy_90p_8_422.y4m" |
| 24 | "park_joy_90p_8_444.y4m" |
Tom Finegan | 0af2732 | 2017-08-30 09:13:17 -0700 | [diff] [blame] | 25 | "desktop_credits.y4m" |
| 26 | "niklas_1280_720_30.y4m" |
| 27 | "rush_hour_444.y4m" |
| 28 | "screendata.y4m" |
| 29 | "niklas_640_480_30.yuv") |
| 30 | |
| 31 | if (CONFIG_DECODE_PERF_TESTS AND CONFIG_AV1_ENCODER) |
| 32 | set(AOM_TEST_DATA_FILE_NAMES |
| 33 | ${AOM_TEST_DATA_FILE_NAMES} |
| 34 | "niklas_1280_720_30.yuv") |
| 35 | endif () |
| 36 | |
| 37 | if (CONFIG_ENCODE_PERF_TESTS AND CONFIG_AV1_ENCODER) |
| 38 | set(AOM_TEST_DATA_FILE_NAMES |
| 39 | ${AOM_TEST_DATA_FILE_NAMES} |
| 40 | "desktop_640_360_30.yuv" |
| 41 | "kirland_640_480_30.yuv" |
| 42 | "macmarcomoving_640_480_30.yuv" |
| 43 | "macmarcostationary_640_480_30.yuv" |
| 44 | "niklas_1280_720_30.yuv" |
| 45 | "tacomanarrows_640_480_30.yuv" |
| 46 | "tacomasmallcameramovement_640_480_30.yuv" |
| 47 | "thaloundeskmtg_640_480_30.yuv") |
| 48 | endif () |
| 49 | |
Tom Finegan | 4f7e104 | 2017-03-01 10:25:16 -0800 | [diff] [blame] | 50 | # Parses test/test-data.sha1 and writes captured file names and checksums to |
| 51 | # $out_files and $out_checksums as lists. |
Tom Finegan | e9d70c9 | 2017-05-10 11:31:05 -0700 | [diff] [blame] | 52 | function (make_test_data_lists test_data_file out_files out_checksums) |
| 53 | if (NOT test_data_file OR NOT EXISTS "${test_data_file}") |
| 54 | message(FATAL_ERROR "Test info file missing or empty (${test_data_file})") |
Tom Finegan | 4f7e104 | 2017-03-01 10:25:16 -0800 | [diff] [blame] | 55 | endif () |
| 56 | |
Tom Finegan | e9d70c9 | 2017-05-10 11:31:05 -0700 | [diff] [blame] | 57 | # Read $test_data_file into $files_and_checksums. $files_and_checksums becomes |
| 58 | # a list with an entry for each line from $test_data_file. |
| 59 | file(STRINGS "${test_data_file}" files_and_checksums) |
Tom Finegan | 4f7e104 | 2017-03-01 10:25:16 -0800 | [diff] [blame] | 60 | |
| 61 | # Iterate over the list of lines and split it into $checksums and $filenames. |
| 62 | foreach (line ${files_and_checksums}) |
| 63 | string(FIND "${line}" " *" delim_pos) |
| 64 | |
| 65 | math(EXPR filename_pos "${delim_pos} + 2") |
| 66 | string(SUBSTRING "${line}" 0 ${delim_pos} checksum) |
| 67 | string(SUBSTRING "${line}" ${filename_pos} -1 filename) |
| 68 | |
Tom Finegan | 0af2732 | 2017-08-30 09:13:17 -0700 | [diff] [blame] | 69 | list(FIND AOM_TEST_DATA_FILE_NAMES ${filename} list_index) |
| 70 | if (NOT ${list_index} EQUAL -1) |
| 71 | # Include the name and checksum in output only when the file is needed. |
| 72 | set(checksums ${checksums} ${checksum}) |
| 73 | set(filenames ${filenames} ${filename}) |
| 74 | endif () |
Tom Finegan | 4f7e104 | 2017-03-01 10:25:16 -0800 | [diff] [blame] | 75 | endforeach () |
| 76 | |
Tom Finegan | e9d70c9 | 2017-05-10 11:31:05 -0700 | [diff] [blame] | 77 | list(LENGTH filenames num_files) |
| 78 | list(LENGTH checksums num_checksums) |
| 79 | if (NOT checksums OR NOT filenames OR NOT num_files EQUAL num_checksums) |
| 80 | message(FATAL_ERROR "Parsing of ${test_data_file} failed.") |
Tom Finegan | 4f7e104 | 2017-03-01 10:25:16 -0800 | [diff] [blame] | 81 | endif () |
| 82 | |
| 83 | set(${out_checksums} ${checksums} PARENT_SCOPE) |
| 84 | set(${out_files} ${filenames} PARENT_SCOPE) |
| 85 | endfunction () |
| 86 | |
| 87 | # Appends each file name in $test_files to $test_dir and adds the result path to |
| 88 | # $out_path_list. |
| 89 | function (expand_test_file_paths test_files test_dir out_path_list) |
| 90 | foreach (filename ${${test_files}}) |
| 91 | set(path_list ${path_list} "${test_dir}/${filename}") |
| 92 | endforeach () |
| 93 | set(${out_path_list} ${path_list} PARENT_SCOPE) |
| 94 | endfunction () |
| 95 | |
| 96 | function (check_file local_path expected_checksum out_needs_update) |
| 97 | if (EXISTS "${local_path}") |
| 98 | file(SHA1 "${local_path}" file_checksum) |
| 99 | else () |
| 100 | set(${out_needs_update} 1 PARENT_SCOPE) |
| 101 | return () |
| 102 | endif () |
| 103 | |
| 104 | if ("${file_checksum}" STREQUAL "${expected_checksum}") |
| 105 | unset(${out_needs_update} PARENT_SCOPE) |
| 106 | else () |
| 107 | set(${out_needs_update} 1 PARENT_SCOPE) |
Tom Finegan | e9d70c9 | 2017-05-10 11:31:05 -0700 | [diff] [blame] | 108 | return () |
Tom Finegan | 4f7e104 | 2017-03-01 10:25:16 -0800 | [diff] [blame] | 109 | endif () |
Tom Finegan | e9d70c9 | 2017-05-10 11:31:05 -0700 | [diff] [blame] | 110 | message("${local_path} up to date.") |
Tom Finegan | 4f7e104 | 2017-03-01 10:25:16 -0800 | [diff] [blame] | 111 | endfunction () |
| 112 | |
| 113 | # Downloads data from $file_url, confirms that $file_checksum matches, and |
| 114 | # writes it to $local_path. |
| 115 | function (download_test_file file_url file_checksum local_path) |
| 116 | message("Downloading ${file_url} ...") |
| 117 | file(DOWNLOAD "${file_url}" "${local_path}" |
| 118 | SHOW_PROGRESS |
| 119 | EXPECTED_HASH SHA1=${file_checksum}) |
| 120 | message("Download of ${file_url} complete.") |
| 121 | endfunction () |