From 99fe188e66f1df06c36406dc786ff4ad97d2b4fc Mon Sep 17 00:00:00 2001 From: Andi Drebes Date: Mon, 15 Nov 2021 10:40:32 +0100 Subject: [PATCH] fix(tests): Define defaultV0Constraints in a single place The variable `defaultV0Constraints` is defined in multiple source files for unit test, but missing in other tests. Put a single, extern declaration in `globals.h` and the definition in `globals.cc`. --- compiler/tests/unittest/CMakeLists.txt | 5 +++++ compiler/tests/unittest/end_to_end_jit_clear_tensor.cc | 2 -- compiler/tests/unittest/end_to_end_jit_test.cc | 2 -- compiler/tests/unittest/end_to_end_jit_test.h | 3 +-- compiler/tests/unittest/globals.cc | 3 +++ compiler/tests/unittest/globals.h | 3 +++ 6 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 compiler/tests/unittest/globals.cc create mode 100644 compiler/tests/unittest/globals.h diff --git a/compiler/tests/unittest/CMakeLists.txt b/compiler/tests/unittest/CMakeLists.txt index 3b455a405..8eb96e1e2 100644 --- a/compiler/tests/unittest/CMakeLists.txt +++ b/compiler/tests/unittest/CMakeLists.txt @@ -5,21 +5,25 @@ include_directories(${PROJECT_SOURCE_DIR}/include) add_executable( end_to_end_jit_test end_to_end_jit_test.cc + globals.cc ) add_executable( end_to_end_jit_clear_tensor end_to_end_jit_clear_tensor.cc + globals.cc ) add_executable( end_to_end_jit_encrypted_tensor end_to_end_jit_encrypted_tensor.cc + globals.cc ) add_executable( end_to_end_jit_hlfhelinalg end_to_end_jit_hlfhelinalg.cc + globals.cc ) set_source_files_properties( @@ -27,6 +31,7 @@ set_source_files_properties( end_to_end_jit_clear_tensor.cc end_to_end_jit_encrypted_tensor.cc end_to_end_jit_hlfhelinalg.cc + globals.cc PROPERTIES COMPILE_FLAGS "-fno-rtti" ) diff --git a/compiler/tests/unittest/end_to_end_jit_clear_tensor.cc b/compiler/tests/unittest/end_to_end_jit_clear_tensor.cc index 2cc78c1f0..4babd79d0 100644 --- a/compiler/tests/unittest/end_to_end_jit_clear_tensor.cc +++ b/compiler/tests/unittest/end_to_end_jit_clear_tensor.cc @@ -1,7 +1,5 @@ #include "end_to_end_jit_test.h" -const mlir::zamalang::V0FHEConstraint defaultV0Constraints{10, 7}; - /////////////////////////////////////////////////////////////////////////////// // 1D tensor ////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// diff --git a/compiler/tests/unittest/end_to_end_jit_test.cc b/compiler/tests/unittest/end_to_end_jit_test.cc index d27abbc62..5512479ce 100644 --- a/compiler/tests/unittest/end_to_end_jit_test.cc +++ b/compiler/tests/unittest/end_to_end_jit_test.cc @@ -5,8 +5,6 @@ #include "end_to_end_jit_test.h" -const mlir::zamalang::V0FHEConstraint defaultV0Constraints{10, 7}; - TEST(CompileAndRunHLFHE, add_eint) { mlir::zamalang::JitCompilerEngine::Lambda lambda = checkedJit(R"XXX( func @main(%arg0: !HLFHE.eint<7>, %arg1: !HLFHE.eint<7>) -> !HLFHE.eint<7> { diff --git a/compiler/tests/unittest/end_to_end_jit_test.h b/compiler/tests/unittest/end_to_end_jit_test.h index 69f6f01ca..e3695d5ae 100644 --- a/compiler/tests/unittest/end_to_end_jit_test.h +++ b/compiler/tests/unittest/end_to_end_jit_test.h @@ -5,8 +5,7 @@ #include "zamalang/Support/CompilerEngine.h" #include "zamalang/Support/JitCompilerEngine.h" - -extern const mlir::zamalang::V0FHEConstraint defaultV0Constraints; +#include "globals.h" #define ASSERT_LLVM_ERROR(err) \ if (err) { \ diff --git a/compiler/tests/unittest/globals.cc b/compiler/tests/unittest/globals.cc new file mode 100644 index 000000000..d1bc1c5e2 --- /dev/null +++ b/compiler/tests/unittest/globals.cc @@ -0,0 +1,3 @@ +#include "globals.h" + +const mlir::zamalang::V0FHEConstraint defaultV0Constraints{10, 7}; diff --git a/compiler/tests/unittest/globals.h b/compiler/tests/unittest/globals.h new file mode 100644 index 000000000..2d7735951 --- /dev/null +++ b/compiler/tests/unittest/globals.h @@ -0,0 +1,3 @@ +#include + +extern const mlir::zamalang::V0FHEConstraint defaultV0Constraints;