aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-11-04 18:23:11 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-11-04 18:23:11 +0000
commitf6e6dceea8eacf42fba1ed5c6b303feca1c738e8 (patch)
tree7b3bdaffba2d72c710d76139ca6922aa19948376
parent24998cecccd3ca33dc7d29b4972215837e8b0709 (diff)
parent8fcbd9b81780536460f883a90b20f0ccc30fc469 (diff)
downloadfmtlib-f6e6dceea8eacf42fba1ed5c6b303feca1c738e8.tar.gz
Merge "fmtlib: build and run the tests." am: 52b05fe0a0 am: 9dee828d17 am: 8fcbd9b817
Original change: https://android-review.googlesource.com/c/platform/external/fmtlib/+/1486343 Change-Id: I01959de46a06e4d2b8e33f88347bd104873bb1ce
-rw-r--r--Android.bp72
-rw-r--r--TEST_MAPPING10
2 files changed, 73 insertions, 9 deletions
diff --git a/Android.bp b/Android.bp
index d7a6dec3..42cf8c90 100644
--- a/Android.bp
+++ b/Android.bp
@@ -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"
+ }
+ ]
+}