Index: third_party/opus/BUILD.gn |
diff --git a/third_party/opus/BUILD.gn b/third_party/opus/BUILD.gn |
index 2905a4922b30a1a882f4a379c2794ebb642b5932..244ddcd6927fbb64850c40c665e05804c18d9384 100644 |
--- a/third_party/opus/BUILD.gn |
+++ b/third_party/opus/BUILD.gn |
@@ -3,6 +3,7 @@ |
# found in the LICENSE file. |
import("//build/config/arm.gni") |
+import("//testing/test.gni") |
# If fixed point implementation shall be used (otherwise float). |
use_opus_fixed_point = cpu_arch == "arm" || cpu_arch == "arm64" |
@@ -19,6 +20,23 @@ config("opus_config") { |
include_dirs = [ "src/include" ] |
} |
+config("opus_test_config") { |
+ include_dirs = [ |
+ "src/celt", |
+ "src/silk", |
+ ] |
+ |
+ if (is_win) { |
+ defines = [ "inline=__inline" ] |
+ } |
+ if (is_android) { |
+ libs = [ "log" ] |
+ } |
+ if (is_clang) { |
+ cflags = [ "-Wno-absolute-value" ] |
+ } |
+} |
+ |
if (use_opus_rtcd) { |
action("convert_rtcd_assembler") { |
script = "convert_rtcd_assembler.py" |
@@ -143,23 +161,11 @@ executable("opus_compare") { |
] |
configs -= [ "//build/config/compiler:chromium_code" ] |
- configs += [ "//build/config/compiler:no_chromium_code" ] |
- |
- include_dirs = [ |
- "src/celt", |
- "src/silk", |
+ configs += [ |
+ "//build/config/compiler:no_chromium_code", |
+ ":opus_test_config", |
] |
- if (is_win) { |
- defines = [ "inline=__inline" ] |
- } |
- if (is_android) { |
- libs = [ "log" ] |
- } |
- if (is_clang) { |
- cflags = [ "-Wno-absolute-value" ] |
- } |
- |
deps = [ |
":opus", |
] |
@@ -171,24 +177,84 @@ executable("opus_demo") { |
] |
configs -= [ "//build/config/compiler:chromium_code" ] |
- configs += [ "//build/config/compiler:no_chromium_code" ] |
+ configs += [ |
+ "//build/config/compiler:no_chromium_code", |
+ ":opus_test_config", |
+ ] |
- include_dirs = [ |
- "src/celt", |
- "src/silk", |
+ deps = [ |
+ ":opus", |
] |
+} |
- if (is_win) { |
- defines = [ "inline=__inline" ] |
- } |
- if (is_android) { |
- libs = [ "log" ] |
- } |
- if (is_clang) { |
- cflags = [ "-Wno-absolute-value" ] |
+test("test_opus_api") { |
+ sources = [ |
+ "src/tests/test_opus_api.c", |
+ ] |
+ |
+ configs -= [ "//build/config/compiler:chromium_code" ] |
+ configs += [ |
+ "//build/config/compiler:no_chromium_code", |
+ ":opus_test_config", |
+ ] |
+ |
+ deps = [ |
+ ":opus", |
+ ] |
+} |
+ |
+test("test_opus_encode") { |
+ sources = [ |
+ "src/tests/test_opus_encode.c", |
+ ] |
+ |
+ configs -= [ "//build/config/compiler:chromium_code" ] |
+ configs += [ |
+ "//build/config/compiler:no_chromium_code", |
+ ":opus_test_config", |
+ ] |
+ |
+ deps = [ |
+ ":opus", |
+ ] |
+} |
+ |
+test("test_opus_decode") { |
+ sources = [ |
+ "src/tests/test_opus_decode.c", |
+ ] |
+ |
+ configs -= [ "//build/config/compiler:chromium_code" ] |
+ configs += [ |
+ "//build/config/compiler:no_chromium_code", |
+ ":opus_test_config", |
+ ] |
+ |
+ # test_opus_decode passes a null pointer to opus_decode() for an argument |
+ # marked as requiring a non-null value by the nonnull function attribute, |
+ # and expects opus_decode() to fail. Disable the -Wnonnull option to avoid |
+ # a compilation error if -Werror is specified. |
+ if (is_posix) { |
+ cflags = [ "-Wno-nonnull" ] |
} |
deps = [ |
":opus", |
] |
} |
+ |
+test("test_opus_padding") { |
+ sources = [ |
+ "src/tests/test_opus_padding.c", |
+ ] |
+ |
+ configs -= [ "//build/config/compiler:chromium_code" ] |
+ configs += [ |
+ "//build/config/compiler:no_chromium_code", |
+ ":opus_test_config", |
+ ] |
+ |
+ deps = [ |
+ ":opus", |
+ ] |
+} |