interpreter_test.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include <limits.h>
  6. #include "gtest/gtest.h"
  7. #include "wasm_runtime_common.h"
  8. #include "bh_platform.h"
  9. // To use a test fixture, derive a class from testing::Test.
  10. class InterpreterTest : public testing::Test
  11. {
  12. protected:
  13. // You should make the members protected s.t. they can be
  14. // accessed from sub-classes.
  15. // virtual void SetUp() will be called before each test is run. You
  16. // should define it if you need to initialize the variables.
  17. // Otherwise, this can be skipped.
  18. virtual void SetUp()
  19. {
  20. memset(&init_args, 0, sizeof(RuntimeInitArgs));
  21. init_args.mem_alloc_type = Alloc_With_Pool;
  22. init_args.mem_alloc_option.pool.heap_buf = global_heap_buf;
  23. init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf);
  24. ASSERT_EQ(wasm_runtime_full_init(&init_args), true);
  25. }
  26. // virtual void TearDown() will be called after each test is run.
  27. // You should define it if there is cleanup work to do. Otherwise,
  28. // you don't have to provide it.
  29. //
  30. virtual void TearDown() { wasm_runtime_destroy(); }
  31. public:
  32. char global_heap_buf[512 * 1024];
  33. RuntimeInitArgs init_args;
  34. };
  35. TEST_F(InterpreterTest, wasm_runtime_is_built_in_module)
  36. {
  37. bool ret = wasm_runtime_is_built_in_module("env");
  38. ASSERT_TRUE(ret);
  39. ret = wasm_runtime_is_built_in_module("env1");
  40. ASSERT_FALSE(ret);
  41. }