poulpy/poulpy-hal/src/test_suite/mod.rs
poulpy-hal/src/test_suite/mod.rsRaw
1pub mod serialization;
2pub mod svp;
3pub mod vec_znx;
4pub mod vec_znx_big;
5pub mod vec_znx_dft;
6pub mod vmp;
7
8#[macro_export]
9macro_rules! backend_test_suite {
10 (
11 mod $modname:ident,
12 backend = $backend:ty,
13 size = $size:expr,
14 tests = {
15 $( $(#[$attr:meta])* $test_name:ident => $impl:path ),+ $(,)?
16 }
17 ) => {
18 mod $modname {
19 use poulpy_hal::{api::ModuleNew, layouts::Module};
20
21 use once_cell::sync::Lazy;
22
23 static MODULE: Lazy<Module<$backend>> =
24 Lazy::new(|| Module::<$backend>::new($size));
25
26 $(
27 $(#[$attr])*
28 #[test]
29 fn $test_name() {
30 ($impl)(&*MODULE);
31 }
32 )+
33 }
34 };
35}
36
37#[macro_export]
38macro_rules! cross_backend_test_suite {
39 (
40 mod $modname:ident,
41 backend_ref = $backend_ref:ty,
42 backend_test = $backend_test:ty,
43 size = $size:expr,
44 basek = $basek:expr,
45 tests = {
46 $( $(#[$attr:meta])* $test_name:ident => $impl:path ),+ $(,)?
47 }
48 ) => {
49 mod $modname {
50 use poulpy_hal::{api::ModuleNew, layouts::Module};
51
52 use once_cell::sync::Lazy;
53
54 static MODULE_REF: Lazy<Module<$backend_ref>> =
55 Lazy::new(|| Module::<$backend_ref>::new($size));
56 static MODULE_TEST: Lazy<Module<$backend_test>> =
57 Lazy::new(|| Module::<$backend_test>::new($size));
58
59 $(
60 $(#[$attr])*
61 #[test]
62 fn $test_name() {
63 ($impl)($basek, &*MODULE_REF, &*MODULE_TEST);
64 }
65 )+
66 }
67 };
68}