[libc-commits] [libc] 6344a58 - [libc] Add a macro to include/exclude subprocess tests.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Tue Jun 8 16:58:06 PDT 2021


Author: Siva Chandra Reddy
Date: 2021-06-08T23:30:21Z
New Revision: 6344a583ca8d1650def86d8effd1ad8a3a9598b1

URL: https://github.com/llvm/llvm-project/commit/6344a583ca8d1650def86d8effd1ad8a3a9598b1
DIFF: https://github.com/llvm/llvm-project/commit/6344a583ca8d1650def86d8effd1ad8a3a9598b1.diff

LOG: [libc] Add a macro to include/exclude subprocess tests.

This is useful when bringing up LLVM libc on a new OS on which we do not
yet have the subprocess related helper functions.

Added: 
    libc/utils/UnitTest/PlatformDefs.h

Modified: 
    libc/utils/UnitTest/LibcTest.cpp
    libc/utils/UnitTest/LibcTest.h

Removed: 
    


################################################################################
diff  --git a/libc/utils/UnitTest/LibcTest.cpp b/libc/utils/UnitTest/LibcTest.cpp
index a8e32d17dd7c..016a4e53759d 100644
--- a/libc/utils/UnitTest/LibcTest.cpp
+++ b/libc/utils/UnitTest/LibcTest.cpp
@@ -262,6 +262,8 @@ bool Test::testMatch(bool MatchResult, MatcherBase &Matcher, const char *LHSStr,
   return false;
 }
 
+#ifdef ENABLE_SUBPROCESS_TESTS
+
 bool Test::testProcessKilled(testutils::FunctionCaller *Func, int Signal,
                              const char *LHSStr, const char *RHSStr,
                              const char *File, unsigned long Line) {
@@ -344,6 +346,7 @@ bool Test::testProcessExits(testutils::FunctionCaller *Func, int ExitCode,
   return false;
 }
 
+#endif // ENABLE_SUBPROCESS_TESTS
 } // namespace testing
 } // namespace __llvm_libc
 

diff  --git a/libc/utils/UnitTest/LibcTest.h b/libc/utils/UnitTest/LibcTest.h
index 798acfe09ffe..d50f88d191a7 100644
--- a/libc/utils/UnitTest/LibcTest.h
+++ b/libc/utils/UnitTest/LibcTest.h
@@ -12,6 +12,8 @@
 // This file can only include headers from utils/CPP/ or utils/testutils. No
 // other headers should be included.
 
+#include "PlatformDefs.h"
+
 #include "utils/CPP/TypeTraits.h"
 #include "utils/testutils/ExecuteFunction.h"
 #include "utils/testutils/StreamWrapper.h"
@@ -360,6 +362,8 @@ template <typename... Types> using TypeList = internal::TypeList<Types...>;
   if (!EXPECT_FALSE(VAL))                                                      \
   return
 
+#ifdef ENABLE_SUBPROCESS_TESTS
+
 #define EXPECT_EXITS(FUNC, EXIT)                                               \
   this->testProcessExits(__llvm_libc::testing::Test::createCallable(FUNC),     \
                          EXIT, #FUNC, #EXIT, __FILE__, __LINE__)
@@ -380,6 +384,8 @@ template <typename... Types> using TypeList = internal::TypeList<Types...>;
 #define __CAT(a, b) __CAT1(a, b)
 #define UNIQUE_VAR(prefix) __CAT(prefix, __LINE__)
 
+#endif // ENABLE_SUBPROCESS_TESTS
+
 #define EXPECT_THAT(MATCH, MATCHER)                                            \
   do {                                                                         \
     auto UNIQUE_VAR(__matcher) = (MATCHER);                                    \

diff  --git a/libc/utils/UnitTest/PlatformDefs.h b/libc/utils/UnitTest/PlatformDefs.h
new file mode 100644
index 000000000000..319b73e91f5c
--- /dev/null
+++ b/libc/utils/UnitTest/PlatformDefs.h
@@ -0,0 +1,16 @@
+//===-- Platform specific defines for the unittest library ------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_UTILS_UNITTEST_PLATFORMDEFS_H
+#define LLVM_LIBC_UTILS_UNITTEST_PLATFORMDEFS_H
+
+#if !(defined(_WIN32) || defined(_WIN64))
+#define ENABLE_SUBPROCESS_TESTS
+#endif
+
+#endif // LLVM_LIBC_UTILS_UNITTEST_PLATFORMDEFS_H


        


More information about the libc-commits mailing list