diff options
author | Elliott Hughes <enh@google.com> | 2020-11-04 16:42:54 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-11-04 16:42:54 +0000 |
commit | 52b05fe0a06124d07797256feb8f885d3c7c2a63 (patch) | |
tree | 7b3bdaffba2d72c710d76139ca6922aa19948376 | |
parent | 1b7aec46cee49adf992e83155d19b255e9890a2c (diff) | |
parent | c2c29c472b1a421cf756f44fce25eef6ac868666 (diff) | |
download | fmtlib-52b05fe0a06124d07797256feb8f885d3c7c2a63.tar.gz |
Merge "fmtlib: build and run the tests."
-rw-r--r-- | Android.bp | 72 | ||||
-rw-r--r-- | TEST_MAPPING | 10 |
2 files changed, 73 insertions, 9 deletions
@@ -1,25 +1,26 @@ cc_defaults { - name: "fmtlib-defaults", - srcs: ["src/format.cc"], + name: "fmtlib-non-test-defaults", cflags: [ "-fno-exceptions", - "-Wall", - "-Werror", // If built without exceptions, libfmt uses assert. + // The tests *require* exceptions, so we can't win here. + // (This is also why we have two cc_defaults in this file.) + // Unless proven to be a bad idea, let's at least have some run-time + // checking. "-UNDEBUG", ], - sanitize: { - misc_undefined: ["integer"], - }, + srcs: ["src/format.cc"], local_include_dirs: ["include"], export_include_dirs: ["include"], + visibility: ["//system/libbase"], min_sdk_version: "29", } // This is built into libbase. If you want to use this library, link to libbase instead. cc_library_static { name: "fmtlib", - defaults: ["fmtlib-defaults"], + defaults: ["fmtlib-non-test-defaults"], + vendor_available: true, ramdisk_available: true, vendor_ramdisk_available: true, @@ -42,7 +43,60 @@ cc_library_static { cc_library_static { name: "fmtlib_ndk", - defaults: ["fmtlib-defaults"], + defaults: ["fmtlib-non-test-defaults"], sdk_version: "current", stl: "c++_static", } + +cc_defaults { + name: "fmtlib-test-defaults", + srcs: [ + "src/format.cc", + "src/os.cc", + "test/gtest-extra.cc", + "test/util.cc", + ], + local_include_dirs: ["include"], + host_supported: true, + test_suites: ["general-tests"], + // The tests require exceptions and RTTI. + cflags: ["-fexceptions"], + rtti: true, + // The usual "gtest *and* gmock, please" dance... + gtest: false, + include_dirs: [ + "external/googletest/googlemock/include/gmock", + "external/googletest/googletest/include/gtest", + ], + static_libs: [ + "libgmock", + "libgtest", + "libgtest_main", + ], +} + +// Most of the fmtlib tests. +cc_test { + name: "fmtlib_test", + defaults: ["fmtlib-test-defaults"], + srcs: [ + "test/chrono-test.cc", + "test/color-test.cc", + "test/core-test.cc", + "test/format-test.cc", + // Some of the os-test tests deliberately try to do bad things with + // file descriptors, but Android's fdsan won't let them. + // "test/os-test.cc", + "test/printf-test.cc", + "test/ranges-test.cc", + "test/scan-test.cc", + ], +} + +// This one needs to be separate because some of the test names overlap with +// other tests. +cc_test { + name: "fmtlib_ostream_test", + defaults: ["fmtlib-test-defaults"], + srcs: ["test/ostream-test.cc"], +} diff --git a/TEST_MAPPING b/TEST_MAPPING new file mode 100644 index 00000000..caeecd64 --- /dev/null +++ b/TEST_MAPPING @@ -0,0 +1,10 @@ +{ + "presubmit": [ + { + "name": "fmtlib_test" + }, + { + "name": "fmtlib_ostream_test" + } + ] +} |