Skip to content

Commit 02fa340

Browse files
authored
[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.
1 parent 624dc00 commit 02fa340

18 files changed

+87
-44
lines changed

flang/unittests/Evaluate/fp-testing.h flang/include/flang/Testing/fp-testing.h

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
#ifndef FORTRAN_TEST_EVALUATE_FP_TESTING_H_
2-
#define FORTRAN_TEST_EVALUATE_FP_TESTING_H_
1+
//===-- include/flang/Testing/fp-testing.h ----------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef FORTRAN_TESTING_FP_TESTING_H_
10+
#define FORTRAN_TESTING_FP_TESTING_H_
311

412
#include "flang/Common/target-rounding.h"
513
#include <fenv.h>
@@ -24,4 +32,4 @@ class ScopedHostFloatingPointEnvironment {
2432
#endif
2533
};
2634

27-
#endif // FORTRAN_TEST_EVALUATE_FP_TESTING_H_
35+
#endif // FORTRAN_TESTING_FP_TESTING_H_

flang/unittests/Evaluate/testing.h flang/include/flang/Testing/testing.h

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
#ifndef FORTRAN_EVALUATE_TESTING_H_
2-
#define FORTRAN_EVALUATE_TESTING_H_
1+
//===-- include/flang/Testing/testing.h -------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef FORTRAN_TESTING_TESTING_H_
10+
#define FORTRAN_TESTING_TESTING_H_
311

412
#include <cinttypes>
513
#include <string>
@@ -33,4 +41,4 @@ FailureDetailPrinter Match(const char *file, int line, const std::string &want,
3341
FailureDetailPrinter Compare(const char *file, int line, const char *xs,
3442
const char *rel, const char *ys, std::uint64_t x, std::uint64_t y);
3543
} // namespace testing
36-
#endif // FORTRAN_EVALUATE_TESTING_H_
44+
#endif // FORTRAN_TESTING_TESTING_H_

flang/lib/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ add_subdirectory(Frontend)
88
add_subdirectory(FrontendTool)
99

1010
add_subdirectory(Optimizer)
11+
12+
if (FLANG_INCLUDE_TESTS)
13+
add_subdirectory(Testing)
14+
endif ()

flang/lib/Testing/CMakeLists.txt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#===-- lib/Testing/CMakeLists.txt ------------------------------------------===#
2+
#
3+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
# See https://llvm.org/LICENSE.txt for license information.
5+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
#
7+
#===------------------------------------------------------------------------===#
8+
9+
add_library(NonGTestTesting EXCLUDE_FROM_ALL
10+
testing.cpp
11+
fp-testing.cpp
12+
)
13+
set_target_properties(NonGTestTesting PROPERTIES FOLDER "Flang/Tests")
14+
15+
if (LLVM_LINK_LLVM_DYLIB)
16+
set(llvm_libs LLVM)
17+
else()
18+
llvm_map_components_to_libnames(llvm_libs Support)
19+
endif()
20+
target_link_libraries(NonGTestTesting ${llvm_libs})

flang/unittests/Evaluate/fp-testing.cpp flang/lib/Testing/fp-testing.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
#include "fp-testing.h"
1+
//===-- lib/Testing/fp-testing.cpp ------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "flang/Testing/fp-testing.h"
210
#include "llvm/Support/Errno.h"
311
#include <cstdio>
412
#include <cstdlib>

flang/unittests/Evaluate/testing.cpp flang/lib/Testing/testing.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
#include "testing.h"
1+
//===-- lib/Testing/testing.cpp ---------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "flang/Testing/testing.h"
210
#include "llvm/Support/raw_ostream.h"
311
#include <cstdarg>
412
#include <cstdio>
+11-24
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,34 @@
11
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
2-
add_library(FortranEvaluateTesting
3-
testing.cpp
4-
fp-testing.cpp
5-
)
6-
set_target_properties(FortranEvaluateTesting PROPERTIES FOLDER "Flang/Tests")
7-
if (LLVM_LINK_LLVM_DYLIB)
8-
set(llvm_libs LLVM)
9-
else()
10-
llvm_map_components_to_libnames(llvm_libs Support)
11-
endif()
12-
13-
target_link_libraries(FortranEvaluateTesting
14-
${llvm_libs})
152

163
add_flang_nongtest_unittest(leading-zero-bit-count
17-
FortranEvaluateTesting
4+
NonGTestTesting
185
)
196

207
add_flang_nongtest_unittest(bit-population-count
21-
FortranEvaluateTesting
8+
NonGTestTesting
229
)
2310

2411
add_flang_nongtest_unittest(uint128
25-
FortranEvaluateTesting
12+
NonGTestTesting
2613
)
2714

2815
add_flang_nongtest_unittest(expression
2916
FortranSupport
30-
FortranEvaluateTesting
17+
NonGTestTesting
3118
FortranEvaluate
3219
FortranSemantics
3320
FortranParser
3421
)
3522

3623
add_flang_nongtest_unittest(integer
37-
FortranEvaluateTesting
24+
NonGTestTesting
3825
FortranEvaluate
3926
FortranSemantics
4027
)
4128

4229
add_flang_nongtest_unittest(intrinsics
4330
FortranSupport
44-
FortranEvaluateTesting
31+
NonGTestTesting
4532
FortranEvaluate
4633
FortranDecimal
4734
FortranSemantics
@@ -50,7 +37,7 @@ add_flang_nongtest_unittest(intrinsics
5037
)
5138

5239
add_flang_nongtest_unittest(logical
53-
FortranEvaluateTesting
40+
NonGTestTesting
5441
FortranEvaluate
5542
FortranSemantics
5643
)
@@ -62,30 +49,30 @@ add_flang_nongtest_unittest(logical
6249
set(LLVM_REQUIRES_EH ON)
6350
set(LLVM_REQUIRES_RTTI ON)
6451
add_flang_nongtest_unittest(real
65-
FortranEvaluateTesting
52+
NonGTestTesting
6653
FortranEvaluate
6754
FortranDecimal
6855
FortranSemantics
6956
)
7057
llvm_update_compile_flags(real.test)
7158

7259
add_flang_nongtest_unittest(reshape
73-
FortranEvaluateTesting
60+
NonGTestTesting
7461
FortranSemantics
7562
FortranEvaluate
7663
FortranRuntime
7764
)
7865

7966
add_flang_nongtest_unittest(ISO-Fortran-binding
80-
FortranEvaluateTesting
67+
NonGTestTesting
8168
FortranEvaluate
8269
FortranSemantics
8370
FortranRuntime
8471
)
8572

8673
add_flang_nongtest_unittest(folding
8774
FortranSupport
88-
FortranEvaluateTesting
75+
NonGTestTesting
8976
FortranEvaluate
9077
FortranSemantics
9178
)

flang/unittests/Evaluate/ISO-Fortran-binding.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "testing.h"
21
#include "flang/Common/ISO_Fortran_binding_wrapper.h"
32
#include "flang/Runtime/descriptor.h"
3+
#include "flang/Testing/testing.h"
44
#include "llvm/Support/raw_ostream.h"
55
#include <type_traits>
66

flang/unittests/Evaluate/bit-population-count.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "flang/Common/bit-population-count.h"
2-
#include "testing.h"
2+
#include "flang/Testing/testing.h"
33

44
using Fortran::common::BitPopulationCount;
55
using Fortran::common::Parity;

flang/unittests/Evaluate/expression.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "flang/Evaluate/expression.h"
2-
#include "testing.h"
32
#include "flang/Evaluate/fold.h"
43
#include "flang/Evaluate/intrinsics.h"
54
#include "flang/Evaluate/target.h"
65
#include "flang/Evaluate/tools.h"
76
#include "flang/Parser/message.h"
7+
#include "flang/Testing/testing.h"
88
#include <cstdio>
99
#include <cstdlib>
1010
#include <string>

flang/unittests/Evaluate/folding.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include "testing.h"
21
#include "../../lib/Evaluate/host.h"
32
#include "flang/Evaluate/call.h"
43
#include "flang/Evaluate/expression.h"
@@ -7,6 +6,7 @@
76
#include "flang/Evaluate/intrinsics.h"
87
#include "flang/Evaluate/target.h"
98
#include "flang/Evaluate/tools.h"
9+
#include "flang/Testing/testing.h"
1010
#include <tuple>
1111

1212
using namespace Fortran::evaluate;

flang/unittests/Evaluate/integer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "flang/Evaluate/integer.h"
2-
#include "testing.h"
2+
#include "flang/Testing/testing.h"
33
#include <cstdio>
44
#include <string>
55

flang/unittests/Evaluate/intrinsics.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "flang/Evaluate/intrinsics.h"
2-
#include "testing.h"
32
#include "flang/Evaluate/common.h"
43
#include "flang/Evaluate/expression.h"
54
#include "flang/Evaluate/target.h"
65
#include "flang/Evaluate/tools.h"
76
#include "flang/Parser/provenance.h"
7+
#include "flang/Testing/testing.h"
88
#include "llvm/Support/raw_ostream.h"
99
#include <initializer_list>
1010
#include <map>

flang/unittests/Evaluate/leading-zero-bit-count.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "flang/Common/leading-zero-bit-count.h"
2-
#include "testing.h"
2+
#include "flang/Testing/testing.h"
33

44
using Fortran::common::LeadingZeroBitCount;
55

flang/unittests/Evaluate/logical.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "testing.h"
21
#include "flang/Evaluate/type.h"
2+
#include "flang/Testing/testing.h"
33
#include <cstdio>
44

55
template <int KIND> void testKind() {

flang/unittests/Evaluate/real.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "fp-testing.h"
2-
#include "testing.h"
31
#include "flang/Evaluate/type.h"
2+
#include "flang/Testing/fp-testing.h"
3+
#include "flang/Testing/testing.h"
44
#include "llvm/Support/raw_ostream.h"
55
#include <cmath>
66
#include <cstdio>

flang/unittests/Evaluate/reshape.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "testing.h"
21
#include "flang/Runtime/descriptor.h"
32
#include "flang/Runtime/transformational.h"
3+
#include "flang/Testing/testing.h"
44
#include <cinttypes>
55

66
using namespace Fortran::common;

flang/unittests/Evaluate/uint128.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define AVOID_NATIVE_UINT128_T 1
22
#include "flang/Common/uint128.h"
3-
#include "testing.h"
3+
#include "flang/Testing/testing.h"
44
#include "llvm/Support/raw_ostream.h"
55
#include <cinttypes>
66

0 commit comments

Comments
 (0)