[Flang] Promote FortranEvaluateTesting library (#124417)

The non-GTest library will be shared by unittests of Flang and Flang-RT.
Promote it as a regular library for use by both projects.

In the long term, we may want to convert these to regular GTest checks
to avoid having multiple testing frameworks.
This commit is contained in:
Michael Kruse 2025-02-06 21:45:51 +01:00 committed by GitHub
parent 624dc00e76
commit 02fa340711
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 87 additions and 44 deletions

View File

@ -1,5 +1,13 @@
#ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_ //===-- include/flang/Testing/fp-testing.h ----------------------*- C++ -*-===//
#define FORTRAN_TEST_EVALUATE_FP_TESTING_H_ //
// 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 FORTRAN_TESTING_FP_TESTING_H_
#define FORTRAN_TESTING_FP_TESTING_H_
#include "flang/Common/target-rounding.h" #include "flang/Common/target-rounding.h"
#include <fenv.h> #include <fenv.h>
@ -24,4 +32,4 @@ private:
#endif #endif
}; };
#endif // FORTRAN_TEST_EVALUATE_FP_TESTING_H_ #endif // FORTRAN_TESTING_FP_TESTING_H_

View File

@ -1,5 +1,13 @@
#ifndef FORTRAN_EVALUATE_TESTING_H_ //===-- include/flang/Testing/testing.h -------------------------*- C++ -*-===//
#define FORTRAN_EVALUATE_TESTING_H_ //
// 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 FORTRAN_TESTING_TESTING_H_
#define FORTRAN_TESTING_TESTING_H_
#include <cinttypes> #include <cinttypes>
#include <string> #include <string>
@ -33,4 +41,4 @@ FailureDetailPrinter Match(const char *file, int line, const std::string &want,
FailureDetailPrinter Compare(const char *file, int line, const char *xs, FailureDetailPrinter Compare(const char *file, int line, const char *xs,
const char *rel, const char *ys, std::uint64_t x, std::uint64_t y); const char *rel, const char *ys, std::uint64_t x, std::uint64_t y);
} // namespace testing } // namespace testing
#endif // FORTRAN_EVALUATE_TESTING_H_ #endif // FORTRAN_TESTING_TESTING_H_

View File

@ -8,3 +8,7 @@ add_subdirectory(Frontend)
add_subdirectory(FrontendTool) add_subdirectory(FrontendTool)
add_subdirectory(Optimizer) add_subdirectory(Optimizer)
if (FLANG_INCLUDE_TESTS)
add_subdirectory(Testing)
endif ()

View File

@ -0,0 +1,20 @@
#===-- lib/Testing/CMakeLists.txt ------------------------------------------===#
#
# 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
#
#===------------------------------------------------------------------------===#
add_library(NonGTestTesting EXCLUDE_FROM_ALL
testing.cpp
fp-testing.cpp
)
set_target_properties(NonGTestTesting PROPERTIES FOLDER "Flang/Tests")
if (LLVM_LINK_LLVM_DYLIB)
set(llvm_libs LLVM)
else()
llvm_map_components_to_libnames(llvm_libs Support)
endif()
target_link_libraries(NonGTestTesting ${llvm_libs})

View File

@ -1,4 +1,12 @@
#include "fp-testing.h" //===-- lib/Testing/fp-testing.cpp ------------------------------*- 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
//
//===----------------------------------------------------------------------===//
#include "flang/Testing/fp-testing.h"
#include "llvm/Support/Errno.h" #include "llvm/Support/Errno.h"
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>

View File

@ -1,4 +1,12 @@
#include "testing.h" //===-- lib/Testing/testing.cpp ---------------------------------*- 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
//
//===----------------------------------------------------------------------===//
#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>

View File

@ -1,47 +1,34 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_library(FortranEvaluateTesting
testing.cpp
fp-testing.cpp
)
set_target_properties(FortranEvaluateTesting PROPERTIES FOLDER "Flang/Tests")
if (LLVM_LINK_LLVM_DYLIB)
set(llvm_libs LLVM)
else()
llvm_map_components_to_libnames(llvm_libs Support)
endif()
target_link_libraries(FortranEvaluateTesting
${llvm_libs})
add_flang_nongtest_unittest(leading-zero-bit-count add_flang_nongtest_unittest(leading-zero-bit-count
FortranEvaluateTesting NonGTestTesting
) )
add_flang_nongtest_unittest(bit-population-count add_flang_nongtest_unittest(bit-population-count
FortranEvaluateTesting NonGTestTesting
) )
add_flang_nongtest_unittest(uint128 add_flang_nongtest_unittest(uint128
FortranEvaluateTesting NonGTestTesting
) )
add_flang_nongtest_unittest(expression add_flang_nongtest_unittest(expression
FortranSupport FortranSupport
FortranEvaluateTesting NonGTestTesting
FortranEvaluate FortranEvaluate
FortranSemantics FortranSemantics
FortranParser FortranParser
) )
add_flang_nongtest_unittest(integer add_flang_nongtest_unittest(integer
FortranEvaluateTesting NonGTestTesting
FortranEvaluate FortranEvaluate
FortranSemantics FortranSemantics
) )
add_flang_nongtest_unittest(intrinsics add_flang_nongtest_unittest(intrinsics
FortranSupport FortranSupport
FortranEvaluateTesting NonGTestTesting
FortranEvaluate FortranEvaluate
FortranDecimal FortranDecimal
FortranSemantics FortranSemantics
@ -50,7 +37,7 @@ add_flang_nongtest_unittest(intrinsics
) )
add_flang_nongtest_unittest(logical add_flang_nongtest_unittest(logical
FortranEvaluateTesting NonGTestTesting
FortranEvaluate FortranEvaluate
FortranSemantics FortranSemantics
) )
@ -62,7 +49,7 @@ add_flang_nongtest_unittest(logical
set(LLVM_REQUIRES_EH ON) set(LLVM_REQUIRES_EH ON)
set(LLVM_REQUIRES_RTTI ON) set(LLVM_REQUIRES_RTTI ON)
add_flang_nongtest_unittest(real add_flang_nongtest_unittest(real
FortranEvaluateTesting NonGTestTesting
FortranEvaluate FortranEvaluate
FortranDecimal FortranDecimal
FortranSemantics FortranSemantics
@ -70,14 +57,14 @@ add_flang_nongtest_unittest(real
llvm_update_compile_flags(real.test) llvm_update_compile_flags(real.test)
add_flang_nongtest_unittest(reshape add_flang_nongtest_unittest(reshape
FortranEvaluateTesting NonGTestTesting
FortranSemantics FortranSemantics
FortranEvaluate FortranEvaluate
FortranRuntime FortranRuntime
) )
add_flang_nongtest_unittest(ISO-Fortran-binding add_flang_nongtest_unittest(ISO-Fortran-binding
FortranEvaluateTesting NonGTestTesting
FortranEvaluate FortranEvaluate
FortranSemantics FortranSemantics
FortranRuntime FortranRuntime
@ -85,7 +72,7 @@ add_flang_nongtest_unittest(ISO-Fortran-binding
add_flang_nongtest_unittest(folding add_flang_nongtest_unittest(folding
FortranSupport FortranSupport
FortranEvaluateTesting NonGTestTesting
FortranEvaluate FortranEvaluate
FortranSemantics FortranSemantics
) )

View File

@ -1,6 +1,6 @@
#include "testing.h"
#include "flang/Common/ISO_Fortran_binding_wrapper.h" #include "flang/Common/ISO_Fortran_binding_wrapper.h"
#include "flang/Runtime/descriptor.h" #include "flang/Runtime/descriptor.h"
#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <type_traits> #include <type_traits>

View File

@ -1,5 +1,5 @@
#include "flang/Common/bit-population-count.h" #include "flang/Common/bit-population-count.h"
#include "testing.h" #include "flang/Testing/testing.h"
using Fortran::common::BitPopulationCount; using Fortran::common::BitPopulationCount;
using Fortran::common::Parity; using Fortran::common::Parity;

View File

@ -1,10 +1,10 @@
#include "flang/Evaluate/expression.h" #include "flang/Evaluate/expression.h"
#include "testing.h"
#include "flang/Evaluate/fold.h" #include "flang/Evaluate/fold.h"
#include "flang/Evaluate/intrinsics.h" #include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h" #include "flang/Evaluate/target.h"
#include "flang/Evaluate/tools.h" #include "flang/Evaluate/tools.h"
#include "flang/Parser/message.h" #include "flang/Parser/message.h"
#include "flang/Testing/testing.h"
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>

View File

@ -1,4 +1,3 @@
#include "testing.h"
#include "../../lib/Evaluate/host.h" #include "../../lib/Evaluate/host.h"
#include "flang/Evaluate/call.h" #include "flang/Evaluate/call.h"
#include "flang/Evaluate/expression.h" #include "flang/Evaluate/expression.h"
@ -7,6 +6,7 @@
#include "flang/Evaluate/intrinsics.h" #include "flang/Evaluate/intrinsics.h"
#include "flang/Evaluate/target.h" #include "flang/Evaluate/target.h"
#include "flang/Evaluate/tools.h" #include "flang/Evaluate/tools.h"
#include "flang/Testing/testing.h"
#include <tuple> #include <tuple>
using namespace Fortran::evaluate; using namespace Fortran::evaluate;

View File

@ -1,5 +1,5 @@
#include "flang/Evaluate/integer.h" #include "flang/Evaluate/integer.h"
#include "testing.h" #include "flang/Testing/testing.h"
#include <cstdio> #include <cstdio>
#include <string> #include <string>

View File

@ -1,10 +1,10 @@
#include "flang/Evaluate/intrinsics.h" #include "flang/Evaluate/intrinsics.h"
#include "testing.h"
#include "flang/Evaluate/common.h" #include "flang/Evaluate/common.h"
#include "flang/Evaluate/expression.h" #include "flang/Evaluate/expression.h"
#include "flang/Evaluate/target.h" #include "flang/Evaluate/target.h"
#include "flang/Evaluate/tools.h" #include "flang/Evaluate/tools.h"
#include "flang/Parser/provenance.h" #include "flang/Parser/provenance.h"
#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <initializer_list> #include <initializer_list>
#include <map> #include <map>

View File

@ -1,5 +1,5 @@
#include "flang/Common/leading-zero-bit-count.h" #include "flang/Common/leading-zero-bit-count.h"
#include "testing.h" #include "flang/Testing/testing.h"
using Fortran::common::LeadingZeroBitCount; using Fortran::common::LeadingZeroBitCount;

View File

@ -1,5 +1,5 @@
#include "testing.h"
#include "flang/Evaluate/type.h" #include "flang/Evaluate/type.h"
#include "flang/Testing/testing.h"
#include <cstdio> #include <cstdio>
template <int KIND> void testKind() { template <int KIND> void testKind() {

View File

@ -1,6 +1,6 @@
#include "fp-testing.h"
#include "testing.h"
#include "flang/Evaluate/type.h" #include "flang/Evaluate/type.h"
#include "flang/Testing/fp-testing.h"
#include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>

View File

@ -1,6 +1,6 @@
#include "testing.h"
#include "flang/Runtime/descriptor.h" #include "flang/Runtime/descriptor.h"
#include "flang/Runtime/transformational.h" #include "flang/Runtime/transformational.h"
#include "flang/Testing/testing.h"
#include <cinttypes> #include <cinttypes>
using namespace Fortran::common; using namespace Fortran::common;

View File

@ -1,6 +1,6 @@
#define AVOID_NATIVE_UINT128_T 1 #define AVOID_NATIVE_UINT128_T 1
#include "flang/Common/uint128.h" #include "flang/Common/uint128.h"
#include "testing.h" #include "flang/Testing/testing.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <cinttypes> #include <cinttypes>