|
| 1 | +# Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | +# Use of this source code is governed by a BSD-style license that can be |
| 3 | +# found in the LICENSE file. |
| 4 | + |
| 5 | +import("//build/config/arm.gni") |
| 6 | +import("//testing/libfuzzer/fuzzer_test.gni") |
| 7 | +import("//testing/test.gni") |
| 8 | + |
| 9 | +config("common_config") { |
| 10 | + if (is_win) { |
| 11 | + defines = [ |
| 12 | + # Required to use math constants from math.h. |
| 13 | + "_USE_MATH_DEFINES", |
| 14 | + ] |
| 15 | + } |
| 16 | + |
| 17 | + # PFFFT doesn't support SIMD on some cpus, so build a scalar version. |
| 18 | + if ((current_cpu == "arm" && !arm_use_neon) || current_cpu == "mipsel" || |
| 19 | + current_cpu == "mips64el" || current_cpu == "ppc64" || |
| 20 | + current_cpu == "s390x") { |
| 21 | + defines = [ "PFFFT_SIMD_DISABLE" ] |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +static_library("pffft") { |
| 26 | + configs += [ ":common_config" ] |
| 27 | + sources = [ |
| 28 | + "src/pffft.c", |
| 29 | + "src/pffft.h", |
| 30 | + ] |
| 31 | +} |
| 32 | + |
| 33 | +# Fuzzing. |
| 34 | + |
| 35 | +group("fuzzers") { |
| 36 | + testonly = true |
| 37 | + deps = [ |
| 38 | + ":pffft_complex_fuzzer", |
| 39 | + ":pffft_real_fuzzer", |
| 40 | + ] |
| 41 | +} |
| 42 | + |
| 43 | +fuzzer_testdata_dir = "$target_gen_dir/testdata" |
| 44 | + |
| 45 | +action("generate_pffft_fuzzer_corpus") { |
| 46 | + script = "generate_seed_corpus.py" |
| 47 | + sources = [ "generate_seed_corpus.py" ] |
| 48 | + args = [ rebase_path(fuzzer_testdata_dir, root_build_dir) ] |
| 49 | + outputs = [ fuzzer_testdata_dir ] |
| 50 | +} |
| 51 | + |
| 52 | +fuzzer_test("pffft_complex_fuzzer") { |
| 53 | + sources = [ "pffft_fuzzer.cc" ] |
| 54 | + cflags = [ "-DTRANSFORM_COMPLEX" ] |
| 55 | + deps = [ ":pffft" ] |
| 56 | + seed_corpus = fuzzer_testdata_dir |
| 57 | + seed_corpus_deps = [ ":generate_pffft_fuzzer_corpus" ] |
| 58 | +} |
| 59 | + |
| 60 | +fuzzer_test("pffft_real_fuzzer") { |
| 61 | + sources = [ "pffft_fuzzer.cc" ] |
| 62 | + cflags = [ "-DTRANSFORM_REAL" ] |
| 63 | + deps = [ ":pffft" ] |
| 64 | + seed_corpus = fuzzer_testdata_dir |
| 65 | + seed_corpus_deps = [ ":generate_pffft_fuzzer_corpus" ] |
| 66 | +} |
| 67 | + |
| 68 | +# Unit tests and benchmark. |
| 69 | + |
| 70 | +# This target must be used only for testing and benchmark purposes. |
| 71 | +static_library("fftpack") { |
| 72 | + testonly = true |
| 73 | + configs += [ ":common_config" ] |
| 74 | + sources = [ |
| 75 | + "src/fftpack.c", |
| 76 | + "src/fftpack.h", |
| 77 | + ] |
| 78 | + visibility = [ ":*" ] |
| 79 | +} |
| 80 | + |
| 81 | +config("pffft_benchmark_internal_config") { |
| 82 | + cflags = [ |
| 83 | + # test_pffft.c contains an `exit(1)` following a `break` statement. |
| 84 | + "-Wno-unreachable-code", |
| 85 | + ] |
| 86 | +} |
| 87 | + |
| 88 | +executable("pffft_benchmark") { |
| 89 | + testonly = true |
| 90 | + configs += [ |
| 91 | + ":common_config", |
| 92 | + ":pffft_benchmark_internal_config", |
| 93 | + ] |
| 94 | + sources = [ "src/test_pffft.c" ] |
| 95 | + deps = [ |
| 96 | + ":fftpack", |
| 97 | + ":pffft", |
| 98 | + ] |
| 99 | +} |
| 100 | + |
| 101 | +test("pffft_unittest") { |
| 102 | + testonly = true |
| 103 | + sources = [ "pffft_unittest.cc" ] |
| 104 | + deps = [ |
| 105 | + ":fftpack", |
| 106 | + ":pffft", |
| 107 | + "//testing/gtest", |
| 108 | + "//testing/gtest:gtest_main", |
| 109 | + ] |
| 110 | +} |
0 commit comments