Move libpldm test cases into libpldm directory

The test cases for different libraries in this repo are put in the same
test directory.
As a follow up of building libpldm only, move the test cases of libpldm
into libpldm/tests, so that the test cases could be built and run by
libpldm-only option.

Tested: Verify the libpldm tests are built and run by libpldm-only
        option.
        Verify all the tests are built and run without libpldm-only
        option.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I097000bef316f787ef1894f1a3feec5089ea081a
diff --git a/libpldm/tests/meson.build b/libpldm/tests/meson.build
new file mode 100644
index 0000000..08d2d19
--- /dev/null
+++ b/libpldm/tests/meson.build
@@ -0,0 +1,45 @@
+if get_option('oe-sdk').enabled()
+  # Setup OE SYSROOT
+  OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
+  if OECORE_TARGET_SYSROOT == ''
+      error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
+  endif
+  message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
+  rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
+  ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
+  dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
+else
+  dynamic_linker = []
+endif
+
+gtest = dependency('gtest', main: true, disabler: true, required: true)
+gmock = dependency('gmock', disabler: true, required: true)
+
+tests = [
+  'libpldm_base_test',
+  'libpldm_platform_test',
+  'libpldm_bios_test',
+  'libpldm_bios_table_test',
+  'libpldm_fru_test',
+  'libpldm_utils_test',
+  'libpldm_pdr_test'
+]
+
+if get_option('oem-ibm').enabled()
+  tests += [
+    '../../oem/ibm/test/libpldm_fileio_test',
+  ]
+endif
+
+foreach t : tests
+  test(t, executable(t.underscorify(), t + '.cpp',
+                     implicit_include_directories: false,
+                     link_args: dynamic_linker,
+                     build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
+                     dependencies: [
+                         libpldm,
+                         gtest,
+                         gmock]),
+       workdir: meson.current_source_dir())
+endforeach
+