test.cmake 17.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
##
## Copyright (c) 2017, Alliance for Open Media. All rights reserved
##
## This source code is subject to the terms of the BSD 2 Clause License and
## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
## was not distributed with this source code in the LICENSE file, you can
## obtain it at www.aomedia.org/license/software. If the Alliance for Open
## Media Patent License 1.0 was not distributed with this source code in the
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
##
11
12
13
if (NOT AOM_TEST_TEST_CMAKE_)
set(AOM_TEST_TEST_CMAKE_ 1)

14
include(FindPythonInterp)
15
16
include(ProcessorCount)

17
18
include("${AOM_ROOT}/test/test_data_util.cmake")

19
20
set(AOM_UNIT_TEST_DATA_LIST_FILE "${AOM_ROOT}/test/test-data.sha1")

21
22
23
24
25
26
27
28
set(AOM_UNIT_TEST_WRAPPER_SOURCES
    "${AOM_CONFIG_DIR}/usage_exit.c"
    "${AOM_ROOT}/test/test_libaom.cc")

set(AOM_UNIT_TEST_COMMON_SOURCES
    "${AOM_ROOT}/test/acm_random.h"
    "${AOM_ROOT}/test/clear_system_state.h"
    "${AOM_ROOT}/test/codec_factory.h"
29
30
    "${AOM_ROOT}/test/decode_test_driver.cc"
    "${AOM_ROOT}/test/decode_test_driver.h"
31
32
33
34
35
36
37
    "${AOM_ROOT}/test/function_equivalence_test.h"
    "${AOM_ROOT}/test/md5_helper.h"
    "${AOM_ROOT}/test/register_state_check.h"
    "${AOM_ROOT}/test/transform_test_base.h"
    "${AOM_ROOT}/test/util.h"
    "${AOM_ROOT}/test/video_source.h")

38
if (NOT BUILD_SHARED_LIBS)
39
40
  set(AOM_UNIT_TEST_COMMON_SOURCES
      ${AOM_UNIT_TEST_COMMON_SOURCES}
41
42
      "${AOM_ROOT}/test/convolve_test.cc"
      "${AOM_ROOT}/test/simd_impl.h")
43

Tom Finegan's avatar
Tom Finegan committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  if (HAVE_NEON)
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
        "${AOM_ROOT}/test/simd_neon_test.cc")
  endif ()
  if (HAVE_SSE2)
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
        "${AOM_ROOT}/test/simd_sse2_test.cc")
  endif ()
  if (HAVE_SSSE3)
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
        "${AOM_ROOT}/test/simd_ssse3_test.cc")
  endif ()
  if (HAVE_SSE4)
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
        "${AOM_ROOT}/test/simd_sse4_test.cc")
  endif ()
  if (HAVE_AVX2)
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
        "${AOM_ROOT}/test/simd_avx2_test.cc")
  endif ()

70
71
72
73
74
  if (CONFIG_ACCOUNTING)
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
        "${AOM_ROOT}/test/accounting_test.cc")
  endif ()
75

76
  if (CONFIG_ADAPT_SCAN)
77
78
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
79
80
81
        "${AOM_ROOT}/test/scan_test.cc")
  endif ()

82
83
84
85
86
87
  if (HAVE_SSE2)
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
        "${AOM_ROOT}/test/warp_filter_test.cc"
        "${AOM_ROOT}/test/warp_filter_test_util.cc"
        "${AOM_ROOT}/test/warp_filter_test_util.h")
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  endif ()
endif ()

set(AOM_UNIT_TEST_DECODER_SOURCES
    "${AOM_ROOT}/test/decode_api_test.cc"
    "${AOM_ROOT}/test/ivf_video_source.h")

set(AOM_UNIT_TEST_ENCODER_SOURCES
    "${AOM_ROOT}/test/altref_test.cc"
    "${AOM_ROOT}/test/aq_segment_test.cc"
    "${AOM_ROOT}/test/datarate_test.cc"
    "${AOM_ROOT}/test/encode_api_test.cc"
    "${AOM_ROOT}/test/encode_test_driver.cc"
    "${AOM_ROOT}/test/encode_test_driver.h"
    "${AOM_ROOT}/test/error_resilience_test.cc"
    "${AOM_ROOT}/test/i420_video_source.h"
James Zern's avatar
James Zern committed
104
    "${AOM_ROOT}/test/resize_test.cc"
105
106
107
108
    "${AOM_ROOT}/test/y4m_test.cc"
    "${AOM_ROOT}/test/y4m_video_source.h"
    "${AOM_ROOT}/test/yuv_video_source.h")

109
110
111
112
113
114
115
116
if (NOT BUILD_SHARED_LIBS)
  set(AOM_UNIT_TEST_ENCODER_SOURCES
      ${AOM_UNIT_TEST_ENCODER_SOURCES}
      "${AOM_ROOT}/test/dct16x16_test.cc"
      "${AOM_ROOT}/test/dct32x32_test.cc"
      "${AOM_ROOT}/test/sad_test.cc")
endif ()

117
118
119
120
121
122
123
124
set(AOM_DECODE_PERF_TEST_SOURCES "${AOM_ROOT}/test/decode_perf_test.cc")
set(AOM_ENCODE_PERF_TEST_SOURCES "${AOM_ROOT}/test/encode_perf_test.cc")
set(AOM_UNIT_TEST_WEBM_SOURCES "${AOM_ROOT}/test/webm_video_source.h")

set(AOM_TEST_INTRA_PRED_SPEED_SOURCES
    "${AOM_CONFIG_DIR}/usage_exit.c"
    "${AOM_ROOT}/test/test_intra_pred_speed.cc")

125
126
if (NOT BUILD_SHARED_LIBS)
  if (CONFIG_AV1_DECODER OR CONFIG_AV1_ENCODER)
127
128
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
129
130
131
        "${AOM_ROOT}/test/av1_convolve_optimz_test.cc"
        "${AOM_ROOT}/test/av1_convolve_test.cc"
        "${AOM_ROOT}/test/intrapred_test.cc"
132
        "${AOM_ROOT}/test/lpf_test.cc"
133
134
        "${AOM_ROOT}/test/simd_cmp_impl.h")

135
136
137
138
    set(AOM_UNIT_TEST_ENCODER_SOURCES
        ${AOM_UNIT_TEST_ENCODER_SOURCES}
        "${AOM_ROOT}/test/motion_vector_test.cc")

139
140
141
142
143
144
145
146
147
    if (CONFIG_CDEF_SINGLEPASS)
      set(AOM_UNIT_TEST_COMMON_SOURCES
          ${AOM_UNIT_TEST_COMMON_SOURCES}
          "${AOM_ROOT}/test/cdef_test.cc")
    else ()
      set(AOM_UNIT_TEST_COMMON_SOURCES
          ${AOM_UNIT_TEST_COMMON_SOURCES}
          "${AOM_ROOT}/test/clpf_test.cc"
          "${AOM_ROOT}/test/dering_test.cc")
148
149
150
151
152
153
154
155
156
    endif ()

    if (CONFIG_INTRABC)
        set(AOM_UNIT_TEST_COMMON_SOURCES
            ${AOM_UNIT_TEST_COMMON_SOURCES}
            "${AOM_ROOT}/test/intrabc_test.cc")
    endif ()

    if (CONFIG_LOOP_RESTORATION)
157
158
      set(AOM_UNIT_TEST_COMMON_SOURCES
          ${AOM_UNIT_TEST_COMMON_SOURCES}
159
160
161
162
163
164
          "${AOM_ROOT}/test/selfguided_filter_test.cc")

      if (HAVE_SSE2)
        set(AOM_UNIT_TEST_COMMON_SOURCES
            ${AOM_UNIT_TEST_COMMON_SOURCES}
            "${AOM_ROOT}/test/hiprec_convolve_test.cc"
165
            "${AOM_ROOT}/test/hiprec_convolve_test_util.cc"
166
167
            "${AOM_ROOT}/test/hiprec_convolve_test_util.h")
      endif ()
168
169
    endif ()

170
171
172
173
174
175
    if (CONFIG_LV_MAP)
      set(AOM_UNIT_TEST_COMMON_SOURCES
          ${AOM_UNIT_TEST_COMMON_SOURCES}
          "${AOM_ROOT}/test/txb_test.cc")
    endif ()

176
177
    set(AOM_UNIT_TEST_COMMON_INTRIN_NEON
        ${AOM_UNIT_TEST_COMMON_INTRIN_NEON}
178
        "${AOM_ROOT}/test/simd_cmp_neon.cc")
179
180
181
182
183
184
185
186
187
188
189
190
191
    set(AOM_UNIT_TEST_COMMON_INTRIN_SSE2
        ${AOM_UNIT_TEST_COMMON_INTRIN_SSE2}
        "${AOM_ROOT}/test/simd_cmp_sse2.cc")
    set(AOM_UNIT_TEST_COMMON_INTRIN_SSSE3
        ${AOM_UNIT_TEST_COMMON_INTRIN_SSSE3}
        "${AOM_ROOT}/test/simd_cmp_ssse3.cc")
    set(AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1
        ${AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1}
        "${AOM_ROOT}/test/simd_cmp_sse4.cc")
    set(AOM_UNIT_TEST_COMMON_INTRIN_AVX2
        ${AOM_UNIT_TEST_COMMON_INTRIN_AVX2}
        "${AOM_ROOT}/test/simd_cmp_avx2.cc")
  endif ()
192
193
194
195
196
197
endif ()

if (CONFIG_AV1_ENCODER)
  set(AOM_UNIT_TEST_ENCODER_SOURCES
      ${AOM_UNIT_TEST_ENCODER_SOURCES}
      "${AOM_ROOT}/test/active_map_test.cc"
Urvang Joshi's avatar
Urvang Joshi committed
198
199
      "${AOM_ROOT}/test/av1_txfm_test.cc"
      "${AOM_ROOT}/test/av1_txfm_test.h"
200
201
202
203
      "${AOM_ROOT}/test/borders_test.cc"
      "${AOM_ROOT}/test/cpu_speed_test.cc"
      "${AOM_ROOT}/test/end_to_end_test.cc"
      "${AOM_ROOT}/test/frame_size_tests.cc"
204
      "${AOM_ROOT}/test/lossless_test.cc")
205

206
  if (NOT BUILD_SHARED_LIBS)
207
208
    set(AOM_UNIT_TEST_ENCODER_SOURCES
        ${AOM_UNIT_TEST_ENCODER_SOURCES}
209
210
211
212
213
214
215
216
217
        "${AOM_ROOT}/test/arf_freq_test.cc"
        "${AOM_ROOT}/test/av1_dct_test.cc"
        "${AOM_ROOT}/test/av1_fht16x16_test.cc"
        "${AOM_ROOT}/test/av1_fht32x32_test.cc"
        "${AOM_ROOT}/test/av1_fht8x8_test.cc"
        "${AOM_ROOT}/test/av1_fwd_txfm1d_test.cc"
        "${AOM_ROOT}/test/av1_fwd_txfm2d_test.cc"
        "${AOM_ROOT}/test/av1_inv_txfm1d_test.cc"
        "${AOM_ROOT}/test/av1_inv_txfm2d_test.cc"
218
219
        "${AOM_ROOT}/test/av1_inv_txfm_test.cc"
        "${AOM_ROOT}/test/av1_wedge_utils_test.cc"
220
221
222
223
224
225
226
        "${AOM_ROOT}/test/avg_test.cc"
        "${AOM_ROOT}/test/blend_a64_mask_1d_test.cc"
        "${AOM_ROOT}/test/blend_a64_mask_test.cc"
        "${AOM_ROOT}/test/error_block_test.cc"
        "${AOM_ROOT}/test/fdct4x4_test.cc"
        "${AOM_ROOT}/test/fdct8x8_test.cc"
        "${AOM_ROOT}/test/hadamard_test.cc"
227
228
        "${AOM_ROOT}/test/masked_sad_test.cc"
        "${AOM_ROOT}/test/masked_variance_test.cc"
229
230
231
232
233
        "${AOM_ROOT}/test/minmax_test.cc"
        "${AOM_ROOT}/test/subtract_test.cc"
        "${AOM_ROOT}/test/sum_squares_test.cc"
        "${AOM_ROOT}/test/variance_test.cc")

234
235
236
237
238
239
    if (NOT CONFIG_AOM_QM AND NOT CONFIG_NEW_QUANT)
      set(AOM_UNIT_TEST_ENCODER_SOURCES
          ${AOM_UNIT_TEST_ENCODER_SOURCES}
          "${AOM_ROOT}/test/quantize_func_test.cc")
    endif ()

240
241
242
243
    set(AOM_UNIT_TEST_ENCODER_SOURCES
        ${AOM_UNIT_TEST_ENCODER_SOURCES}
        "${AOM_ROOT}/test/convolve_round_test.cc")
    if (HAVE_SSE2)
244
245
      set(AOM_UNIT_TEST_ENCODER_SOURCES
          ${AOM_UNIT_TEST_ENCODER_SOURCES}
246
247
248
249
250
251
252
253
254
          "${AOM_ROOT}/test/av1_convolve_2d_test.cc"
          "${AOM_ROOT}/test/av1_convolve_2d_test_util.cc"
          "${AOM_ROOT}/test/av1_convolve_2d_test_util.h")
    endif ()

    if (HAVE_SSE4_1)
      set(AOM_UNIT_TEST_ENCODER_SOURCES
          ${AOM_UNIT_TEST_ENCODER_SOURCES}
          "${AOM_ROOT}/test/av1_convolve_scale_test.cc")
255
    endif ()
256

257
258
259
260
261
262
263
264
265
    set(AOM_UNIT_TEST_ENCODER_SOURCES
        ${AOM_UNIT_TEST_ENCODER_SOURCES}
        "${AOM_ROOT}/test/av1_fht16x32_test.cc"
        "${AOM_ROOT}/test/av1_fht16x8_test.cc"
        "${AOM_ROOT}/test/av1_fht32x16_test.cc"
        "${AOM_ROOT}/test/av1_fht4x4_test.cc"
        "${AOM_ROOT}/test/av1_fht4x8_test.cc"
        "${AOM_ROOT}/test/av1_fht8x16_test.cc"
        "${AOM_ROOT}/test/av1_fht8x4_test.cc")
Urvang Joshi's avatar
Urvang Joshi committed
266

267
268
269
    set(AOM_UNIT_TEST_ENCODER_INTRIN_SSE4_1
        ${AOM_UNIT_TEST_ENCODER_INTRIN_SSE4_1}
        "${AOM_ROOT}/test/corner_match_test.cc")
270

271
272
273
274
    set(AOM_UNIT_TEST_ENCODER_SOURCES
        ${AOM_UNIT_TEST_ENCODER_SOURCES}
        "${AOM_ROOT}/test/obmc_sad_test.cc"
        "${AOM_ROOT}/test/obmc_variance_test.cc")
275
276
277
278
279
280

    if (CONFIG_TX64X64)
      set(AOM_UNIT_TEST_ENCODER_SOURCES
          ${AOM_UNIT_TEST_ENCODER_SOURCES}
          "${AOM_ROOT}/test/av1_fht64x64_test.cc")
    endif ()
Urvang Joshi's avatar
Urvang Joshi committed
281
  endif ()
282
283
endif ()

284
285
if (NOT BUILD_SHARED_LIBS)
  if (CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
286
287
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
288
289
        "${AOM_ROOT}/test/divu_small_test.cc"
        "${AOM_ROOT}/test/ethread_test.cc"
290
        "${AOM_ROOT}/test/coding_path_sync.cc"
291
292
293
294
295
        "${AOM_ROOT}/test/idct8x8_test.cc"
        "${AOM_ROOT}/test/partial_idct_test.cc"
        "${AOM_ROOT}/test/superframe_test.cc"
        "${AOM_ROOT}/test/tile_independence_test.cc")

Sebastien Alaiwan's avatar
Sebastien Alaiwan committed
296
297
298
299
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
        "${AOM_ROOT}/test/binary_codes_test.cc"
        "${AOM_ROOT}/test/boolcoder_test.cc")
300

301
302
303
304
305
    if (CONFIG_EXT_TILE)
      set(AOM_UNIT_TEST_COMMON_SOURCES
          ${AOM_UNIT_TEST_COMMON_SOURCES}
          "${AOM_ROOT}/test/av1_ext_tile_test.cc")
    endif ()
306
307
308
  endif ()
endif ()

309
if (CONFIG_HIGHBITDEPTH)
310
  if (CONFIG_AV1_ENCODER AND NOT BUILD_SHARED_LIBS)
311
312
313
314
315
316
317
318
319
320
321
322
323
324
    set(AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1
        ${AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1}
        "${AOM_ROOT}/test/av1_highbd_iht_test.cc"
        "${AOM_ROOT}/test/av1_quantize_test.cc")
  endif ()

  if (CONFIG_INTERNAL_STATS)
    set(AOM_UNIT_TEST_COMMON_SOURCES
        ${AOM_UNIT_TEST_COMMON_SOURCES}
        "${AOM_ROOT}/test/hbd_metrics_test.cc")
  endif ()
endif ()

if (CONFIG_UNIT_TESTS)
325
326
327
328
329
330
  find_package(PythonInterp)
  if (NOT PYTHONINTERP_FOUND)
    message(WARNING "--- Unit tests disabled: Python not found.")
    set(CONFIG_UNIT_TESTS 0)
  endif ()

331
332
333
334
  if (MSVC)
    # Force static run time to avoid collisions with googletest.
    include("${AOM_ROOT}/build/cmake/msvc_runtime.cmake")
  endif ()
335
336
337
338
339

  if (BUILD_SHARED_LIBS AND APPLE)
    # Silence an RPATH warning.
    set(CMAKE_MACOSX_RPATH 1)
  endif ()
340
341
342
343
344
345
346
347
348
349
350
351
352

  include_directories(
    "${AOM_ROOT}/third_party/googletest/src/googletest/src"
    "${AOM_ROOT}/third_party/googletest/src/googletest/include")

  if (AOM_DISABLE_GTEST_CMAKE)
    include_directories("${AOM_ROOT}/third_party/googletest/src/googletest")
    add_library(gtest STATIC
      "${AOM_ROOT}/third_party/googletest/src/googletest/src/gtest-all.cc")
  else ()
    add_subdirectory("${AOM_ROOT}/third_party/googletest/src/googletest"
                     EXCLUDE_FROM_ALL)
  endif ()
353
354
355
356
357
358
359

endif ()

# Setup the targets for CONFIG_UNIT_TESTS. The libaom and app util targets must
# exist before this function is called.
function (setup_aom_test_targets)
  add_library(test_aom_common OBJECT ${AOM_UNIT_TEST_COMMON_SOURCES})
360
  add_dependencies(test_aom_common aom)
361
362
363

  if (CONFIG_AV1_DECODER)
    add_library(test_aom_decoder OBJECT ${AOM_UNIT_TEST_DECODER_SOURCES})
364
    add_dependencies(test_aom_decoder aom)
365
366
367
368
  endif ()

  if (CONFIG_AV1_ENCODER)
    add_library(test_aom_encoder OBJECT ${AOM_UNIT_TEST_ENCODER_SOURCES})
369
    add_dependencies(test_aom_encoder aom)
370
  endif ()
371
372
373
374

  add_executable(test_libaom ${AOM_UNIT_TEST_WRAPPER_SOURCES}
                 $<TARGET_OBJECTS:aom_common_app_util>
                 $<TARGET_OBJECTS:test_aom_common>)
375
  set(AOM_APP_TARGETS ${AOM_APP_TARGETS} test_libaom)
376

377
  if (CONFIG_AV1_DECODER)
378
    target_sources(test_libaom PRIVATE
379
380
381
382
                   $<TARGET_OBJECTS:aom_decoder_app_util>
                   $<TARGET_OBJECTS:test_aom_decoder>)

    if (CONFIG_DECODE_PERF_TESTS AND CONFIG_WEBM_IO)
383
      target_sources(test_libaom PRIVATE ${AOM_DECODE_PERF_TEST_SOURCES})
384
385
386
    endif ()
  endif ()

387
  if (CONFIG_AV1_ENCODER)
388
    target_sources(test_libaom PRIVATE
389
390
391
392
                   $<TARGET_OBJECTS:test_aom_encoder>
                   $<TARGET_OBJECTS:aom_encoder_app_util>)

    if (CONFIG_ENCODE_PERF_TESTS)
393
      target_sources(test_libaom PRIVATE ${AOM_ENCODE_PERF_TEST_SOURCES})
394
    endif ()
395

396
397
398
399
400
401
    if (NOT BUILD_SHARED_LIBS)
      add_executable(test_intra_pred_speed
                     ${AOM_TEST_INTRA_PRED_SPEED_SOURCES}
                     $<TARGET_OBJECTS:aom_common_app_util>)
      target_link_libraries(test_intra_pred_speed ${AOM_LIB_LINK_TYPE}
                            aom gtest)
402
      set(AOM_APP_TARGETS ${AOM_APP_TARGETS} test_intra_pred_speed)
403
    endif ()
404
405
  endif ()

406
  target_link_libraries(test_libaom ${AOM_LIB_LINK_TYPE} aom gtest)
407
408

  if (CONFIG_LIBYUV)
409
    target_sources(test_libaom PRIVATE $<TARGET_OBJECTS:yuv>)
410
411
  endif ()
  if (CONFIG_WEBM_IO)
412
    target_sources(test_libaom PRIVATE $<TARGET_OBJECTS:webm>)
413
414
415
416
417
418
419
420
421
422
423
424
  endif ()
  if (HAVE_SSE2)
    add_intrinsics_source_to_target("-msse2" "test_libaom"
                                    "AOM_UNIT_TEST_COMMON_INTRIN_SSE2")
  endif ()
  if (HAVE_SSSE3)
    add_intrinsics_source_to_target("-mssse3" "test_libaom"
                                    "AOM_UNIT_TEST_COMMON_INTRIN_SSSE3")
  endif ()
  if (HAVE_SSE4_1)
    add_intrinsics_source_to_target("-msse4.1" "test_libaom"
                                    "AOM_UNIT_TEST_COMMON_INTRIN_SSE4_1")
425
    if (CONFIG_AV1_ENCODER)
426
427
428
429
430
      if (AOM_UNIT_TEST_ENCODER_INTRIN_SSE4_1)
        add_intrinsics_source_to_target("-msse4.1" "test_libaom"
                                        "AOM_UNIT_TEST_ENCODER_INTRIN_SSE4_1")
      endif ()
    endif ()
431
  endif ()
432
433
434
435
  if (HAVE_AVX2)
    add_intrinsics_source_to_target("-mavx2" "test_libaom"
                                    "AOM_UNIT_TEST_COMMON_INTRIN_AVX2")
  endif ()
436
437
438
439
  if (HAVE_NEON)
    add_intrinsics_source_to_target("${AOM_NEON_INTRIN_FLAG}" "test_libaom"
                                    "AOM_UNIT_TEST_COMMON_INTRIN_NEON")
  endif ()
440

Tom Finegan's avatar
Tom Finegan committed
441
442
443
444
445
446
447
448
449
450
451
  if (NOT ENABLE_IDE_TEST_HOSTING)
    if (MSVC OR XCODE)
      # Skip creation of test data download and test run targets when generating
      # for Visual Studio and Xcode unless the user explicitly requests IDE test
      # hosting. This is done to make build cycles in the IDE tolerable when the
      # IDE command for build project is used to build AOM. Default behavior in
      # IDEs is to build all targets, and the test run takes hours.
      return ()
    endif ()
  endif ()

452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
  make_test_data_lists("${AOM_UNIT_TEST_DATA_LIST_FILE}"
                       test_files test_file_checksums)
  list(LENGTH test_files num_test_files)
  list(LENGTH test_file_checksums num_test_file_checksums)

  math(EXPR max_file_index "${num_test_files} - 1")
  foreach (test_index RANGE ${max_file_index})
    list(GET test_files ${test_index} test_file)
    list(GET test_file_checksums ${test_index} test_file_checksum)
    add_custom_target(testdata_${test_index}
                      COMMAND ${CMAKE_COMMAND}
                        -DAOM_CONFIG_DIR="${AOM_CONFIG_DIR}"
                        -DAOM_ROOT="${AOM_ROOT}"
                        -DAOM_TEST_FILE="${test_file}"
                        -DAOM_TEST_CHECKSUM=${test_file_checksum}
                        -P "${AOM_ROOT}/test/test_data_download_worker.cmake")
    set(testdata_targets ${testdata_targets} testdata_${test_index})
  endforeach ()

  # Create a custom build target for running each test data download target.
  add_custom_target(testdata)
  add_dependencies(testdata ${testdata_targets})

  # Pick a reasonable number of targets (this controls parallelization).
  ProcessorCount(num_test_targets)
  if (num_test_targets EQUAL 0)
    # Just default to 10 targets when there's no processor count available.
    set(num_test_targets 10)
  endif ()

  math(EXPR max_shard_index "${num_test_targets} - 1")
  foreach (shard_index RANGE ${max_shard_index})
    set(test_name "test_${shard_index}")
    add_custom_target(${test_name}
                      COMMAND ${CMAKE_COMMAND}
                      -DGTEST_SHARD_INDEX=${shard_index}
                      -DGTEST_TOTAL_SHARDS=${num_test_targets}
489
                      -DTEST_LIBAOM=$<TARGET_FILE:test_libaom>
490
491
492
493
494
495
                      -P "${AOM_ROOT}/test/test_runner.cmake"
                      DEPENDS testdata test_libaom)
    set(test_targets ${test_targets} ${test_name})
  endforeach ()
  add_custom_target(runtests)
  add_dependencies(runtests ${test_targets})
496
497

  set(AOM_APP_TARGETS ${AOM_APP_TARGETS} PARENT_SCOPE)
498
endfunction ()
499
500

endif ()  # AOM_TEST_TEST_CMAKE_