]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Fix test in buck test (#7076)
authorsdong <siying.d@fb.com>
Fri, 3 Jul 2020 03:27:31 +0000 (20:27 -0700)
committerAndrew Kryczka <andrewkr@fb.com>
Tue, 7 Jul 2020 16:12:18 +0000 (09:12 -0700)
Summary:
This is to fix special logic to run tests inside FB.
Buck test is broken after moving to cpp_unittest(). Move c_test back to the previous approach.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/7076

Test Plan: Watch the Sandcastle run

Reviewed By: ajkr

Differential Revision: D22370096

fbshipit-source-id: 4a464d0903f2c76ae2de3a8ad373ffc9bedec64c

TARGETS
buckifier/buckify_rocksdb.py
buckifier/targets_builder.py

diff --git a/TARGETS b/TARGETS
index b20fa774b16759bb5b7fd5db99a7fae18276eaa7..a7f8a7306125c9e808b3842f7dd7ccb7a4f2f3a1 100644 (file)
--- a/TARGETS
+++ b/TARGETS
@@ -447,6 +447,25 @@ cpp_library(
     external_deps = ROCKSDB_EXTERNAL_DEPS,
 )
 
+cpp_binary(
+    name = "c_test_bin",
+    srcs = ["db/c_test.c"],
+    arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
+    os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS,
+    compiler_flags = ROCKSDB_COMPILER_FLAGS,
+    preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
+    deps = [":rocksdb_test_lib"],
+)
+
+custom_unittest(
+    "c_test",
+    command = [
+        native.package_name() + "/buckifier/rocks_test_runner.sh",
+        "$(location :{})".format("c_test_bin"),
+    ],
+    type = "simple",
+)
+
 cpp_library(
     name = "env_basic_test_lib",
     srcs = ["env/env_basic_test.cc"],
@@ -560,13 +579,6 @@ ROCKS_TESTS = [
         [],
         [],
     ],
-    [
-        "c_test",
-        "db/c_test.c",
-        "serial",
-        [],
-        [],
-    ],
     [
         "cache_simulator_test",
         "utilities/simulator_cache/cache_simulator_test.cc",
index b708173cf40432df83932a221aa170c0e29e1463..6072437ce5bd6c25aced612538ed2c4a2ce18771 100644 (file)
@@ -64,8 +64,6 @@ def get_cc_files(repo_path):
             continue
         for filename in fnmatch.filter(filenames, '*.cc'):
             cc_files.append(os.path.join(root, filename))
-        for filename in fnmatch.filter(filenames, '*.c'):
-            cc_files.append(os.path.join(root, filename))
     return cc_files
 
 
@@ -178,10 +176,18 @@ def generate_targets(repo_path, deps_map):
         + ["test_util/testutil.cc"])
 
     print("Extra dependencies:\n{0}".format(json.dumps(deps_map)))
-    # test for every test we found in the Makefile
+
+    # c_test.c is added through TARGETS.add_c_test(). If there
+    # are more than one .c test file, we need to extend
+    # TARGETS.add_c_test() to include other C tests too.
+    TARGETS.add_c_test()
+
+    # test for every .cc test we found in the Makefile
     for target_alias, deps in deps_map.items():
         for test in sorted(tests):
-            match_src = [src for src in cc_files if ("/%s.c" % test) in src]
+            if test == 'c_test':
+                continue
+            match_src = [src for src in cc_files if ("/%s.cc" % test) in src]
             if len(match_src) == 0:
                 print(ColorString.warning("Cannot find .cc file for %s" % test))
                 continue
index 980525adab0c28890c0a74fe5494e9e9768376a8..a86c0a40cc14392bfb34d127a13388b5a8819f07 100644 (file)
@@ -76,6 +76,28 @@ class TARGETSBuilder(object):
             pretty_list(deps)))
         self.total_bin = self.total_bin + 1
 
+    def add_c_test(self):
+        self.targets_file.write("""
+cpp_binary(
+    name = "c_test_bin",
+    srcs = ["db/c_test.c"],
+    arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
+    os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS,
+    compiler_flags = ROCKSDB_COMPILER_FLAGS,
+    preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
+    deps = [":rocksdb_test_lib"],
+)
+
+custom_unittest(
+    "c_test",
+    command = [
+        native.package_name() + "/buckifier/rocks_test_runner.sh",
+        "$(location :{})".format("c_test_bin"),
+    ],
+    type = "simple",
+)
+""")
+
     def register_test(self,
                       test_name,
                       src,