blob: 13d96c3292685ec91f343b79ec7324a9e90a980c [file] [log] [blame]
Tom Finegan4f7e1042017-03-01 10:25:16 -08001##
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 Finegan0af27322017-08-30 09:13:17 -070012set(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 Finegan0af27322017-08-30 09:13:17 -070018 "park_joy_90p_12_420.y4m"
19 "park_joy_90p_12_422.y4m"
20 "park_joy_90p_12_444.y4m"
Tom Finegan0af27322017-08-30 09:13:17 -070021 "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 Finegan0af27322017-08-30 09:13:17 -070025 "desktop_credits.y4m"
26 "niklas_1280_720_30.y4m"
27 "rush_hour_444.y4m"
28 "screendata.y4m"
29 "niklas_640_480_30.yuv")
30
31if (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")
35endif ()
36
37if (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")
48endif ()
49
Tom Finegan4f7e1042017-03-01 10:25:16 -080050# Parses test/test-data.sha1 and writes captured file names and checksums to
51# $out_files and $out_checksums as lists.
Tom Finegane9d70c92017-05-10 11:31:05 -070052function (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 Finegan4f7e1042017-03-01 10:25:16 -080055 endif ()
56
Tom Finegane9d70c92017-05-10 11:31:05 -070057 # 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 Finegan4f7e1042017-03-01 10:25:16 -080060
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 Finegan0af27322017-08-30 09:13:17 -070069 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 Finegan4f7e1042017-03-01 10:25:16 -080075 endforeach ()
76
Tom Finegane9d70c92017-05-10 11:31:05 -070077 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 Finegan4f7e1042017-03-01 10:25:16 -080081 endif ()
82
83 set(${out_checksums} ${checksums} PARENT_SCOPE)
84 set(${out_files} ${filenames} PARENT_SCOPE)
85endfunction ()
86
87# Appends each file name in $test_files to $test_dir and adds the result path to
88# $out_path_list.
89function (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)
94endfunction ()
95
96function (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 Finegane9d70c92017-05-10 11:31:05 -0700108 return ()
Tom Finegan4f7e1042017-03-01 10:25:16 -0800109 endif ()
Tom Finegane9d70c92017-05-10 11:31:05 -0700110 message("${local_path} up to date.")
Tom Finegan4f7e1042017-03-01 10:25:16 -0800111endfunction ()
112
113# Downloads data from $file_url, confirms that $file_checksum matches, and
114# writes it to $local_path.
115function (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.")
121endfunction ()