meson: Add meson build

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I711ec60fe2ab459db1d31c7dedfb9d3ba64061ae
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..34f8c32
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,41 @@
+gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
+gmock_dep = dependency('gmock', disabler: true, required: false)
+if not gtest_dep.found() or not gmock_dep.found()
+    gtest_proj = import('cmake').subproject('googletest', required: false)
+    if gtest_proj.found()
+        gtest_dep = declare_dependency(
+            dependencies: [
+                dependency('threads'),
+                gtest_proj.dependency('gtest'),
+                gtest_proj.dependency('gtest_main'),
+            ]
+        )
+        gmock_dep = gtest_proj.dependency('gmock')
+  else
+        assert(
+            not get_option('tests').enabled(),
+            'Googletest is required if tests are enabled'
+        )
+  endif
+endif
+
+test_sources = [
+  '../integrity_algo.cpp',
+  '../crypt_algo.cpp',
+]
+
+tests = [
+  'cipher.cpp',
+]
+
+foreach t : tests
+  test(t, executable(t.underscorify(), t,
+                     test_sources,
+                     include_directories: ['..'],
+                     dependencies: [
+                         gtest_dep,
+                         gmock_dep,
+                         libcrypto_dep,
+                         ]),
+       workdir: meson.current_source_dir())
+endforeach
\ No newline at end of file