summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test')
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/README.md56
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/__init__.py11
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/__init__.py11
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/case_base.py29
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/engine.py39
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/framework.py288
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/suite.py40
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/test_api.py99
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/test_utils.py71
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/harness/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/harness/harness_api.py150
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/host-clients/src/host_app_sample.c301
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/host-clients/src/makefile44
-rwxr-xr-xsrc/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/set_dev_env.sh7
-rwxr-xr-xsrc/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/start.py152
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/01-install/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/01-install/case.py94
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/02-request/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/02-request/case.py73
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/03-event/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/03-event/case.py67
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/case.py80
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/case.py70
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/06-timer/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/06-timer/case.py70
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/case.py65
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/case.py78
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/suite_setup.py56
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/01_install.c19
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/02_request.c68
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/03_event.c59
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_req.c74
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_resp.c57
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_provider.c59
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_subscriber.c56
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/06_timer.c80
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/07_sensor.c74
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/08_on_destroy.c70
-rwxr-xr-xsrc/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/build.sh39
-rwxr-xr-xsrc/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/tools/product/start.sh10
-rwxr-xr-xsrc/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/tools/product/stop.sh9
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/__init__.py0
-rw-r--r--src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/readme.txt19
49 files changed, 2644 insertions, 0 deletions
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/README.md b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/README.md
new file mode 100644
index 000000000..c72d0fcb8
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/README.md
@@ -0,0 +1,56 @@
+# Component Test
+
+The purpose of this test suite is to verify the basic components of WAMR work well in combination. It is highly recommended to run pass all suites before each commitment.
+
+Prerequisites
+==============
+- clang is available to build wasm application.
+- python is installed to run test script.
+
+
+Run the test
+=============
+```
+start.py [-h] [-s SUITE_ID [SUITE_ID ...]] [-t CASE_ID [CASE_ID ...]]
+ [-n REPEAT_TIME] [--shuffle_all]
+ [--cases_list CASES_LIST_FILE_PATH] [--skip_proc]
+ [-b BINARIES] [-d] [--rebuild]
+```
+It builds out the simple project binary including WAMR runtime binary ```simple``` and the testing tool ```host_tool``` before running the test suites.
+
+Test output is like:
+```
+Test Execution Summary:
+ Success: 8
+ Cases fails: 0
+ Setup fails: 0
+ Case load fails: 0
+
+
+------------------------------------------------------------
+The run folder is [run-03-23-16-29]
+that's all. bye
+kill to quit..
+Killed
+```
+
+The detailed report and log is generated in ```run``` folder. The binaries copy is also put in that folder.
+
+Usage samples
+==============
+
+Run default test suite:
+</br>
+```python start.py```
+
+Rebuild all test apps and then run default test suite:
+</br>
+```python start.py --rebuild```
+
+Run a specified test suite:
+</br>
+```python start.py -s 01-life-cycle```
+
+Run a specified test case:
+</br>
+```python start.py -t 01-install``` \ No newline at end of file
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/__init__.py
new file mode 100644
index 000000000..fd734d561
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/__init__.py
@@ -0,0 +1,11 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+__all__ = [
+ "net_manager", "wifi_daemon_utils"
+]
+
+__author__ = ""
+__package__ = "model"
+__version__ = "1.0"
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/__init__.py
new file mode 100644
index 000000000..fd734d561
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/__init__.py
@@ -0,0 +1,11 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+__all__ = [
+ "net_manager", "wifi_daemon_utils"
+]
+
+__author__ = ""
+__package__ = "model"
+__version__ = "1.0"
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/case_base.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/case_base.py
new file mode 100644
index 000000000..311de5eaa
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/case_base.py
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import os
+import json
+from test.test_support import _run_suite
+
+class CTestCaseBase(object):
+ def __init__(self, suite):
+ self.m_suite = suite
+ return
+ def on_get_case_description(self):
+ return "Undefined"
+
+ def on_setup_case(self):
+ return True, ''
+
+ def on_cleanup_case(self):
+ return True, ''
+
+ # called by the framework
+ def on_run_case(self):
+ return True, ''
+
+ def get_suite(self):
+ return self.m_suite
+
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/engine.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/engine.py
new file mode 100644
index 000000000..6c68a1eb1
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/engine.py
@@ -0,0 +1,39 @@
+from __future__ import print_function
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import datetime
+import os
+import pprint
+import random
+import re
+import shlex
+import subprocess
+import signal
+import sys
+import time
+
+from .test_utils import *
+from .test_api import *
+
+
+
+
+def read_cases_from_file(file_path):
+ if not os.path.exists(file_path):
+ return False, None
+
+ with open(file_path, 'r') as f:
+ content = f.readlines()
+
+ content = [x.strip() for x in content]
+ print(content)
+ if len(content) == 0:
+ return False, None
+
+ return True, content
+
+
+
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/framework.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/framework.py
new file mode 100644
index 000000000..99f0b0772
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/framework.py
@@ -0,0 +1,288 @@
+from __future__ import print_function
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import datetime
+import os
+import pprint
+import random
+import re
+import shlex
+import subprocess
+import signal
+import sys
+import time
+import shutil
+
+from .test_api import *
+import this
+
+
+'''
+The run evironment dir structure:
+
+ run/
+ run{date-time}/
+ suites/
+ {suite name}/
+ -- target/ (the target software being tested)
+ -- tools/ (the tools for testing the target software)
+'''
+
+
+framework=None
+
+def get_framework():
+ global framework
+ return framework
+
+def my_import(name):
+ mod = __import__(name)
+ components = name.split('.')
+ for comp in components[1:]:
+ mod = getattr(mod, comp)
+ return mod
+
+
+# we maintain a root path apart from framework location
+# so the suites can be located in anywhere
+class CTestFramework(object):
+
+ def __init__(self, path):
+ self.running_case = ''
+ self.running_suite = ''
+ self.target_suites = {}
+ self.target_cases = {}
+ self.root_path = path
+ self.running_folder=''
+ self.report = None
+ self.sucess_cases = 0
+ self.failed_cases = 0
+ self.setup_fails = 0
+ self.load_fails = 0;
+ global framework
+ framework = self
+
+ api_set_root_path(path)
+
+ print("root_path is " + self.root_path)
+
+ def gen_execution_stats(self):
+ return '\nTest Execution Summary: ' \
+ '\n\tSuccess: {}' \
+ '\n\tCases fails: {}' \
+ '\n\tSetup fails: {}' \
+ '\n\tCase load fails: {}'.format(
+ self.sucess_cases, self.failed_cases, self.setup_fails, self.load_fails)
+
+ def report_result(self, success, message, case_description):
+ if self.report is None:
+ return
+
+ case_pass = "pass"
+ if not success:
+ case_pass = "fail"
+
+ self.report.write(case_pass + ": [" + self.running_case + "]\n\treason: " + \
+ message + "\n\tcase: " + case_description + "\n")
+ return
+
+ def get_running_path(self):
+ return self.root_path + "/run/" + self.running_folder
+
+ def load_suites(self):
+ self.target_suites = os.listdir(self.root_path + "/suites")
+ return
+
+ def run_case(self, suite_instance, case):
+ # load the test case module
+ case_description = ''
+ suite = suite_instance.m_name
+ api_log("\n>>start run [" + case + "] >>")
+ module_name = 'suites.' + suite + ".cases." + case + ".case"
+ try:
+ module = my_import(module_name)
+ except Exception as e:
+ report_fail("load case fail: " + str(e))
+ api_log_error("load case fail: " + str(e))
+ self.load_fails = self.load_fails +1
+ print(traceback.format_exc())
+ return False
+
+ try:
+ case = module.CTestCase(suite_instance)
+ except Exception as e:
+ report_fail("initialize case fail: " + str(e))
+ api_log_error("initialize case fail: " + str(e))
+ self.load_fails = self.load_fails +1
+ return False
+
+ # call the case on setup callback
+ try:
+ case_description = case.on_get_case_description()
+ result, message = case.on_setup_case()
+ except Exception as e:
+ result = False
+ message = str(e);
+ if not result:
+ api_log_error(message)
+ report_fail (message, case_description)
+ self.failed_cases = self.failed_cases+1
+ return False
+
+ # call the case execution callaback
+ try:
+ result, message = case.on_run_case()
+ except Exception as e:
+ result = False
+ message = str(e);
+ if not result:
+ report_fail (message, case_description)
+ api_log_error(message)
+ self.failed_cases = self.failed_cases+1
+ else:
+ report_success(case_description)
+ self.sucess_cases = self.sucess_cases +1
+
+ # call the case cleanup callback
+ try:
+ clean_result, message = case.on_cleanup_case()
+ except Exception as e:
+ clean_result = False
+ message = str(e)
+
+ if not clean_result:
+ api_log(message)
+
+ return result
+
+ def run_suite(self, suite, cases):
+ # suite setup
+ message = ''
+ api_log("\n>>> Suite [" + suite + "] starting >>>")
+ running_folder = self.get_running_path()+ "/suites/" + suite;
+
+ module_name = 'suites.' + suite + ".suite_setup"
+ try:
+ module = my_import(module_name)
+ except Exception as e:
+ report_fail("load suite [" + suite +"] fail: " + str(e))
+ self.load_fails = self.load_fails +1
+ return False
+
+ try:
+ suite_instance = module.CTestSuite(suite, \
+ self.root_path + '/suites/' + suite, running_folder)
+ except Exception as e:
+ report_fail("initialize suite fail: " + str(e))
+ self.load_fails = self.load_fails +1
+ return False
+
+ result, message = suite_instance.load_settings()
+ if not result:
+ report_fail("load settings fail: " + str(e))
+ self.load_fails = self.load_fails +1
+ return False
+
+ try:
+ result, message = suite_instance.on_suite_setup()
+ except Exception as e:
+ result = False
+ message = str(e);
+ if not result:
+ api_log_error(message)
+ report_fail (message)
+ self.setup_fails = self.setup_fails + 1
+ return False
+
+ self.running_suite = suite
+
+ cases.sort()
+
+ # run cases
+ for case in cases:
+ if not os.path.isdir(self.root_path + '/suites/' + suite + '/cases/' + case):
+ continue
+
+ self.running_case = case
+ self.run_case(suite_instance, case)
+ self.running_case = ''
+
+ # suites cleanup
+ self.running_suite = ''
+ try:
+ result, message = suite_instance.on_suite_cleanup()
+ except Exception as e:
+ result = False
+ message = str(e);
+ if not result:
+ api_log_error(message)
+ report_fail (message)
+ self.setup_fails = self.setup_fails + 1
+ return
+
+ def start_run(self):
+ if self.target_suites is None:
+ print("\n\nstart run: no target suites, exit..")
+ return
+
+ cur_time = time.localtime()
+ time_prefix = "{:02}-{:02}-{:02}-{:02}".format(
+ cur_time.tm_mon, cur_time.tm_mday, cur_time.tm_hour, cur_time.tm_min)
+
+ debug = api_get_value('debug', False)
+ if debug:
+ self.running_folder = 'debug'
+ else:
+ self.running_folder = 'run-' + time_prefix
+
+ folder = self.root_path + "/run/" +self.running_folder;
+
+ if os.path.exists(folder):
+ shutil.rmtree(folder, ignore_errors=True)
+
+ if not os.path.exists(folder):
+ os.makedirs(folder )
+ os.makedirs(folder + "/suites")
+
+ api_init_log(folder + "/test.log")
+
+ self.report = open(folder + "/report.txt", 'a')
+
+ self.target_suites.sort()
+
+ for suite in self.target_suites:
+ if not os.path.isdir(self.root_path + '/suites/' + suite):
+ continue
+ self.report.write("suite " + suite + " cases:\n")
+ if self.target_cases is None:
+ cases = os.listdir(self.root_path + "/suites/" + suite + "/cases")
+ self.run_suite(suite, cases)
+ else:
+ self.run_suite(suite, self.target_cases)
+ self.report.write("\n")
+
+ self.report.write("\n\n")
+ summary = self.gen_execution_stats()
+ self.report.write(summary);
+ self.report.flush()
+ self.report.close()
+ print(summary)
+
+
+def report_fail(message, case_description=''):
+ global framework
+ if framework is not None:
+ framework.report_result(False, message, case_description)
+
+ api_log_error(message)
+
+ return
+
+def report_success(case_description=''):
+ global framework
+ if framework is not None:
+ framework.report_result(True , "OK", case_description)
+ return
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/suite.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/suite.py
new file mode 100644
index 000000000..2b690b08f
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/suite.py
@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import os
+import json
+
+class CTestSuiteBase(object):
+ def __init__(self, name, suite_path, run_path):
+ self.suite_path=suite_path
+ self.run_path=run_path
+ self.m_name = name
+ self.settings = {}
+
+ def get_settings_item(self, item):
+ if item in self.settings:
+ return self.settings[item]
+ else:
+ return None
+
+ def load_settings(self):
+ path = self.suite_path + "/settings.cfg"
+ if os.path.isfile(path):
+ try:
+ fp = open(path, 'r')
+ self.settings = json.load(fp)
+ fp.close()
+ except Exception, e:
+ return False, 'Load settings fail: ' + e.message
+ return True, 'OK'
+ else:
+ return True, 'No file'
+
+ def on_suite_setup(self):
+ return True, 'OK'
+
+ def on_suite_cleanup(self):
+ return True, 'OK'
+
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/test_api.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/test_api.py
new file mode 100644
index 000000000..82a7e6dd0
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/test_api.py
@@ -0,0 +1,99 @@
+from __future__ import print_function
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import logging
+import threading
+from .test_utils import *
+
+global logger
+logger = None
+
+def api_init_log(log_path):
+ global logger
+ print("api_init_log: " + log_path)
+ logger = logging.getLogger(__name__)
+
+ logger.setLevel(level = logging.INFO)
+ handler = logging.FileHandler(log_path)
+ handler.setLevel(logging.INFO)
+ formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
+ handler.setFormatter(formatter)
+
+ console = logging.StreamHandler()
+ console.setLevel(logging.INFO)
+
+ logger.addHandler(handler)
+ logger.addHandler(console)
+
+ return
+
+def api_log(message):
+ global logger
+ if logger is None:
+ print(message)
+ else:
+ logger.info (message)
+ return
+
+def api_log_error(message):
+ global logger
+ if logger is None:
+ print(message)
+ else:
+ logger.error (message)
+ return
+
+def api_logv(message):
+ global logger
+ if logger is None:
+ print(message)
+ else:
+ logger.info(message)
+ return
+
+#####################################3
+global g_case_runner_event
+def api_wait_case_event(timeout):
+ global g_case_runner_event
+ g_case_runner_event.clear()
+ g_case_runner_event.wait(timeout)
+
+def api_notify_case_runner():
+ global g_case_runner_event
+ g_case_runner_event.set()
+
+def api_create_case_event():
+ global g_case_runner_event
+ g_case_runner_event = threading.Event()
+
+#######################################
+
+def api_init_globals():
+ global _global_dict
+ _global_dict = {}
+
+def api_set_value(name, value):
+ _global_dict[name] = value
+
+def api_get_value(name, defValue=None):
+ try:
+ return _global_dict[name]
+ except KeyError:
+ return defValue
+
+
+#########################################
+global root_path
+def api_set_root_path(root):
+ global root_path
+ root_path = root
+
+def api_get_root_path():
+ global root_path
+ return root_path;
+
+
+
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/test_utils.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/test_utils.py
new file mode 100644
index 000000000..e3eb645ae
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/framework/test_utils.py
@@ -0,0 +1,71 @@
+from __future__ import print_function
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import datetime
+import os
+import random
+import re
+import shlex
+import subprocess
+import sys
+import time
+import shutil
+from subprocess import check_output, CalledProcessError
+
+def t_getPIDs(process):
+ try:
+ pidlist = map(int, check_output(["pidof", process]).split())
+ except CalledProcessError:
+ pidlist = []
+ #print process + ':list of PIDs = ' + ', '.join(str(e) for e in pidlist)
+ return pidlist
+
+
+def t_kill_process_by_name(p_keywords):
+ pid_list = []
+ ps_info = subprocess.check_output(shlex.split("ps aux")).split("\n")
+ for p in ps_info:
+ if p_keywords in p:
+ tmp = p.split(" ")
+ tmp = [x for x in tmp if len(x) > 0]
+ pid_list.append(tmp[1])
+
+ for pid in pid_list:
+ cmd = "kill -9 {}".format(pid)
+ subprocess.call(shlex.split(cmd))
+
+ return pid_list
+
+
+
+#proc -> name of the process
+#kill = 1 -> search for pid for kill
+#kill = 0 -> search for name (default)
+
+def t_process_exists(proc, kill = 0):
+ ret = False
+ processes = t_getPIDs(proc)
+
+ for pid in processes:
+ if kill == 0:
+ return True
+ else:
+ print("kill [" + proc + "], pid=" + str(pid))
+ os.kill((pid), 9)
+ ret = True
+ return ret
+
+def t_copy_files(source_dir, pattern, dest_dir):
+ files = os.listdir(source_dir)
+ for file in files:
+ if file in ('/', '.', '..'):
+ continue
+
+ if pattern in ('*', '') or files.endswith(pattern):
+ shutil.copy(source_dir+"/"+ file, dest_dir)
+
+
+
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/harness/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/harness/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/harness/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/harness/harness_api.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/harness/harness_api.py
new file mode 100644
index 000000000..e35aa6b4c
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/harness/harness_api.py
@@ -0,0 +1,150 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import os
+import shutil
+import subprocess
+import json
+import time
+
+from framework import test_api
+from framework.test_utils import *
+
+output = "output.txt"
+
+def start_env():
+ os.system("./start.sh")
+
+def stop_env():
+ os.system("./stop.sh")
+ time.sleep(0.5)
+ os.chdir("../") #reset path for other cases in the same suite
+
+def check_is_timeout():
+ line_num = 0
+ ft = open(output, 'r')
+ lines = ft.readlines()
+
+ for line in reversed(lines):
+ if (line[0:36] == "--------one operation begin.--------"):
+ break
+ line_num = line_num + 1
+
+ ft.close()
+ if (lines[-(line_num)] == "operation timeout"):
+ return True
+ else:
+ return False
+
+def parse_ret(file):
+ ft = open(file, 'a')
+ ft.writelines("\n")
+ ft.writelines("--------one operation finish.--------")
+ ft.writelines("\n")
+ ft.close()
+
+ ft = open(file, 'r')
+ for line in reversed(ft.readlines()):
+ if (line[0:16] == "response status "):
+ ret = line[16:]
+ ft.close()
+ return int(ret)
+
+def run_host_tool(cmd, file):
+ ft = open(file, 'a')
+ ft.writelines("--------one operation begin.--------")
+ ft.writelines("\n")
+ ft.close()
+ os.system(cmd + " -o" + file)
+ if (check_is_timeout() == True):
+ return -1
+ return parse_ret(file)
+
+def install_app(app_name, file_name):
+ return run_host_tool("./host_tool -i " + app_name + " -f ../test-app/" + file_name, output)
+
+def uninstall_app(app_name):
+ return run_host_tool("./host_tool -u " + app_name, output)
+
+def query_app():
+ return run_host_tool("./host_tool -q ", output)
+
+def send_request(url, action, payload):
+ if (payload is None):
+ return run_host_tool("./host_tool -r " + url + " -A " + action, output)
+ else:
+ return run_host_tool("./host_tool -r " + url + " -A " + action + " -p " + payload, output)
+
+def register(url, timeout, alive_time):
+ return run_host_tool("./host_tool -s " + url + " -t " + str(timeout) + " -a " + str(alive_time), output)
+
+def deregister(url):
+ return run_host_tool("./host_tool -d " + url, output)
+
+def get_response_payload():
+ line_num = 0
+ ft = open(output, 'r')
+ lines = ft.readlines()
+
+ for line in reversed(lines):
+ if (line[0:16] == "response status "):
+ break
+ line_num = line_num + 1
+
+ payload_lines = lines[-(line_num):-1]
+ ft.close()
+
+ return payload_lines
+
+def check_query_apps(expected_app_list):
+ if (check_is_timeout() == True):
+ return False
+ json_lines = get_response_payload()
+ json_str = " ".join(json_lines)
+ json_dict = json.loads(json_str)
+ app_list = []
+
+ for key, value in json_dict.items():
+ if key[0:6] == "applet":
+ app_list.append(value)
+
+ if (sorted(app_list) == sorted(expected_app_list)):
+ return True
+ else:
+ return False
+
+def check_response_payload(expected_payload):
+ if (check_is_timeout() == True):
+ return False
+ json_lines = get_response_payload()
+ json_str = " ".join(json_lines)
+
+ if (json_str.strip() != ""):
+ json_dict = json.loads(json_str)
+ else:
+ json_dict = {}
+
+ if (json_dict == expected_payload):
+ return True
+ else:
+ return False
+
+def check_get_event():
+ line_num = 0
+ ft = open(output, 'r')
+ lines = ft.readlines()
+
+ for line in reversed(lines):
+ if (line[0:16] == "response status "):
+ break
+ line_num = line_num + 1
+
+ payload_lines = lines[-(line_num):-1]
+ ft.close()
+
+ if (payload_lines[1][0:17] == "received an event"):
+ return True
+ else:
+ return False
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/host-clients/src/host_app_sample.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/host-clients/src/host_app_sample.c
new file mode 100644
index 000000000..c4010de6a
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/host-clients/src/host_app_sample.c
@@ -0,0 +1,301 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <unistd.h>
+#include "host_api.h"
+#include "bi-inc/attr_container.h"
+#include "er-coap-constants.h"
+
+static char *
+read_file_to_buffer(const char *filename, int *ret_size);
+int send_request_to_applet_success = 0;
+const char *label_for_request = "request1";
+int event_listener_counter = 0;
+char *applet_buf[1024 * 1024];
+const char *host_agent_ip = "127.0.0.1";
+void
+f_aee_response_handler(void *usr_ctx, aee_response_t *response)
+{
+ if (response == NULL) {
+ printf("########## request timeout!!! \n");
+ }
+ else {
+ char *str = (char *)usr_ctx;
+ printf("#### dump response ####\n");
+ printf("#### user data: %s \n", str);
+ printf("#### status: %d \n", response->status);
+ if (response->payload != NULL)
+ attr_container_dump((attr_container_t *)response->payload);
+ }
+}
+
+void
+f_aee_event_listener(const char *url, void *event, int fmt)
+{
+ printf("######## event is received. url: %s, fmt:%d ############\n", url,
+ fmt);
+
+ attr_container_t *attr_obj = (attr_container_t *)event;
+
+ attr_container_dump(attr_obj);
+ /*
+ if (0 == strcmp(url, "alert/overheat"))
+ {
+ event_listener_counter++;
+ printf("event :%d \n", event_listener_counter);
+ }
+ */
+}
+
+static int
+print_menu_and_select(void)
+{
+ char s[256];
+ int choice;
+ do {
+ printf("\n");
+ printf("1. Install TestApplet1\n");
+ printf("2. Install TestApplet2\n");
+ printf("3. Install TestApplet3\n");
+ printf("4. Uninstall TestApplet1\n");
+ printf("5. Uninstall TestApplet2\n");
+ printf("6. Uninstall TestApplet3\n");
+ printf("7. Send Request to TestApplet1\n");
+ printf("8. Register Event to TestApplet1\n");
+ printf("9. UnRegister Event to TestApplet1\n");
+ printf("a. Query Applets\n");
+ printf("t. Auto Test\n");
+ printf("q. Exit\n");
+ printf("Please Select: ");
+
+ if (fgets(s, sizeof(s), stdin)) {
+ if (!strncmp(s, "q", 1))
+ return 0;
+ if (!strncmp(s, "a", 1))
+ return 10;
+ if (!strncmp(s, "t", 1))
+ return 20;
+ choice = atoi(s);
+ if (choice >= 1 && choice <= 9)
+ return choice;
+ }
+ } while (1);
+ return 0;
+}
+
+static void
+install_applet(int index)
+{
+ char applet_name[64];
+ char applet_file_name[64];
+ char *buf;
+ int size;
+ int ret;
+
+ printf("Installing TestApplet%d...\n", index);
+ snprintf(applet_name, sizeof(applet_name), "TestApplet%d", index);
+ snprintf(applet_file_name, sizeof(applet_file_name), "./TestApplet%d.wasm",
+ index);
+ buf = read_file_to_buffer(applet_file_name, &size);
+ if (!buf) {
+ printf("Install Applet failed: read file %s error.\n",
+ applet_file_name);
+ return;
+ }
+
+ // step2. install applet
+ ret = aee_applet_install(buf, "wasm", size, applet_name, 5000);
+ if (ret) {
+ printf("%s install success\n", applet_name);
+ }
+ free(buf);
+}
+
+static void
+uninstall_applet(int index)
+{
+ int ret;
+ char applet_name[64];
+ snprintf(applet_name, sizeof(applet_name), "TestApplet%d", index);
+ ret = aee_applet_uninstall(applet_name, "wasm", 5000);
+ if (ret) {
+ printf("uninstall %s success\n", applet_name);
+ }
+ else {
+ printf("uninstall %s failed\n", applet_name);
+ }
+}
+
+static void
+send_request(int index)
+{
+ char url[64];
+ int ret;
+ aee_request_t req;
+ const char *user_context = "label for request";
+ attr_container_t *attr_obj =
+ attr_container_create("Send Request to Applet");
+ attr_container_set_string(&attr_obj, "String key", "Hello");
+ attr_container_set_int(&attr_obj, "Int key", 1000);
+ attr_container_set_int64(&attr_obj, "Int64 key", 0x77BBCCDD11223344LL);
+
+ // specify the target wasm app
+ snprintf(url, sizeof(url), "/app/TestApplet%d/url1", index);
+
+ // not specify the target wasm app
+ // snprintf(url, sizeof(url), "url1");
+ aee_request_init(&req, url, COAP_PUT);
+ aee_request_set_payload(&req, attr_obj,
+ attr_container_get_serialize_length(attr_obj),
+ PAYLOAD_FORMAT_ATTRIBUTE_OBJECT);
+ ret = aee_request_send(&req, f_aee_response_handler, (void *)user_context,
+ 10000);
+
+ if (ret) {
+ printf("send request to TestApplet1 success\n");
+ }
+}
+
+static void
+register_event(const char *event_path)
+{
+ hostclient_register_event(event_path, f_aee_event_listener);
+}
+
+static void
+unregister_event(const char *event_path)
+{
+ hostclient_unregister_event(event_path);
+}
+
+static void
+query_applets()
+{
+ aee_applet_list_t applet_lst;
+ aee_applet_list_init(&applet_lst);
+ aee_applet_list(5000, &applet_lst);
+ aee_applet_list_clean(&applet_lst);
+}
+
+static char *
+read_file_to_buffer(const char *filename, int *ret_size)
+{
+ FILE *fl = NULL;
+ char *buffer = NULL;
+ int file_size = 0;
+ if (!(fl = fopen(filename, "rb"))) {
+ printf("file open failed\n");
+ return NULL;
+ }
+
+ fseek(fl, 0, SEEK_END);
+ file_size = ftell(fl);
+
+ if (file_size == 0) {
+ printf("file length 0\n");
+ return NULL;
+ }
+
+ if (!(buffer = (char *)malloc(file_size))) {
+ fclose(fl);
+ return NULL;
+ }
+
+ fseek(fl, 0, SEEK_SET);
+
+ if (!fread(buffer, 1, file_size, fl)) {
+ printf("file read failed\n");
+ return NULL;
+ }
+
+ fclose(fl);
+ *ret_size = file_size;
+ return buffer;
+}
+
+static void
+auto_test()
+{
+ int i;
+ int interval = 1000; /* ms */
+ while (1) {
+ uninstall_applet(1);
+ uninstall_applet(2);
+ uninstall_applet(3);
+ install_applet(1);
+ install_applet(2);
+ install_applet(3);
+
+ for (i = 0; i < 60 * 1000 / interval; i++) {
+ query_applets();
+ send_request(1);
+ send_request(2);
+ send_request(3);
+ usleep(interval * 1000);
+ }
+ }
+}
+
+void
+exit_program()
+{
+ hostclient_shutdown();
+ exit(0);
+}
+
+int
+
+main()
+{
+ bool ret;
+
+ // step1. host client init
+ ret = hostclient_initialize(host_agent_ip, 3456);
+
+ if (!ret) {
+ printf("host client initialize failed\n");
+ return -1;
+ }
+
+ do {
+ int choice = print_menu_and_select();
+ printf("\n");
+
+ if (choice == 0)
+ exit_program();
+ if (choice <= 3)
+ install_applet(choice);
+ else if (choice <= 6)
+ uninstall_applet(choice - 3);
+ else if (choice <= 7)
+ send_request(1);
+ else if (choice <= 8)
+ register_event("alert/overheat");
+ else if (choice <= 9)
+ unregister_event("alert/overheat");
+ else if (choice == 10)
+ query_applets();
+ else if (choice == 20)
+ auto_test();
+ } while (1);
+
+ return 0;
+}
+
+// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
+// Debug program: F5 or Debug > Start Debugging menu
+
+// Tips for Getting Started:
+// 1. Use the Solution Explorer window to add/manage files
+// 2. Use the Team Explorer window to connect to source control
+// 3. Use the Output window to see build output and other messages
+// 4. Use the Error List window to view errors
+// 5. Go to Project > Add New Item to create new code files, or
+// Project > Add Existing Item to add existing code files to the project
+// 6. In the future, to open this project again, go to File > Open > Project
+// and select the .sln file
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/host-clients/src/makefile b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/host-clients/src/makefile
new file mode 100644
index 000000000..763a60c38
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/host-clients/src/makefile
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+CC = gcc
+CFLAGS := -Wall -g
+
+# Add this to make compiler happy
+CFLAGS += -DWASM_ENABLE_INTERP=1
+
+host_api_c=../../../../host-agent/host-api-c
+attr_container_dir=../../../../wamr/core/app-framework/app-native-shared
+coap_dir=../../../../host-agent/coap
+shared_dir=../../../../wamr/core/shared
+
+# core
+INCLUDE_PATH = -I$(host_api_c)/src -I$(attr_container_dir)/ \
+ -I$(coap_dir)/er-coap -I$(coap_dir)/er-coap/extension \
+ -I$(shared_dir)/include \
+ -I$(shared_dir)/utils \
+ -I$(shared_dir)/platform/include/ \
+ -I$(shared_dir)/platform/linux/
+
+LIB := $(host_api_c)/src/libhostapi.a
+EXE := ./hostapp
+
+App_C_Files := host_app_sample.c
+
+OBJS := $(App_C_Files:.c=.o)
+
+all: $(EXE)
+
+%.o: %.c
+ @$(CC) $(CFLAGS) -c $< -o $@ $(INCLUDE_PATH)
+
+$(EXE): $(OBJS)
+ @rm -f $(EXE)
+ @$(CC) $(OBJS) -o $(EXE) $(LIB) -lpthread -lrt
+ @rm -f $(OBJS)
+
+.PHONY: clean
+clean:
+ rm -f $(OBJS) $(EXE)
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/set_dev_env.sh b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/set_dev_env.sh
new file mode 100755
index 000000000..1abe23b80
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/set_dev_env.sh
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+#!/bin/sh
+
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/start.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/start.py
new file mode 100755
index 000000000..2cbc4fe63
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/start.py
@@ -0,0 +1,152 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+#!/usr/bin/env python
+
+# -*- coding: utf-8 -*-
+"""
+It is the entrance of the iagent test framework.
+
+"""
+from __future__ import print_function
+
+import argparse
+import datetime
+import os
+import pprint
+import random
+import re
+import shlex
+import subprocess
+import signal
+import sys
+import time
+
+sys.path.append('../../../app-sdk/python')
+from framework.test_utils import *
+from framework.framework import *
+
+
+def signal_handler(signal, frame):
+ print('Pressed Ctrl+C!')
+ sys.exit(0)
+
+def Register_signal_handler():
+ signal.signal(signal.SIGINT, signal_handler)
+# signal.pause()
+
+
+def flatten_args_list(l):
+ if l is None:
+ return None
+
+ return [x for y in l for x in y]
+
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description = "to run specific case(s) "\
+ "in specific suite(s) with FC test framework")
+ parser.add_argument('-s', dest = 'suite_id', action = 'append',
+ nargs = '+',
+ help = 'one or multiple suite ids, which are also setup ids.'\
+ 'by default if it isn\'t passed from argument, all '\
+ 'suites are going to be run.')
+ parser.add_argument('-t', dest = 'case_id', action = 'append',
+ nargs = '+',
+ help = 'one or multiple cases ids.'\
+ 'by default if it isn\'t passed from argument, all '\
+ 'cases in specific suites are going to be run.')
+ parser.add_argument('-n', dest = 'repeat_time', action = 'store',
+ default = 1,
+ help = 'how many times do you want to run. there is 40s '\
+ 'break time between two rounds. each round includs '\
+ 'init_setup, run_test_case and deinit_setup.')
+ parser.add_argument('--shuffle_all', dest = 'shuffle_all',
+ default = False, action = 'store_true',
+ help = 'shuffle_all test cases in per test suite '\
+ 'by default, all cases under per suite should '\
+ 'be executed by input order.')
+ parser.add_argument('--cases_list', dest='cases_list_file_path',
+ default=None,
+ action='store',
+ help="read cases list from a flie ")
+ parser.add_argument('--skip_proc', dest='skip_proc',
+ default = False, action = 'store_true',
+ help='do not start the test process.'\
+ 'sometimes the gw_broker process will be started in eclipse for debug purpose')
+ parser.add_argument('-b', dest = 'binaries', action = 'store',
+ help = 'The path of target folder ')
+ parser.add_argument('-d', dest = 'debug', action = 'store_true',
+ help = 'wait user to attach the target process after launch processes ')
+ parser.add_argument('--rebuild', dest = 'rebuild', action = 'store_true',
+ help = 'rebuild all test binaries')
+ args = parser.parse_args()
+
+ print("------------------------------------------------------------")
+ print("parsing arguments ... ...")
+ print(args)
+
+ '''
+ logger = logging.getLogger('coapthon.server.coap')
+ logger.setLevel(logging.DEBUG)
+ console = logging.StreamHandler()
+ console.setLevel(logging.DEBUG)
+ logger.addHandler(console)
+ '''
+ print("------------------------------------------------------------")
+ print("preparing wamr binary and test tools ... ...")
+ os.system("cd ../../samples/simple/ && bash build.sh -p host-interp")
+
+ Register_signal_handler()
+
+ api_init_globals();
+
+ api_create_case_event();
+
+ suites_list = flatten_args_list(args.suite_id)
+ cases_list = flatten_args_list(args.case_id)
+
+ dirname, filename = os.path.split(os.path.abspath(sys.argv[0]))
+ api_set_root_path(dirname);
+
+ framework = CTestFramework(dirname);
+ framework.repeat_time = int(args.repeat_time)
+ framework.shuffle_all = args.shuffle_all
+ framework.skip_proc=args.skip_proc
+
+ api_set_value('keep_env', args.skip_proc)
+ api_set_value('debug', args.debug)
+ api_set_value('rebuild', args.rebuild)
+
+ binary_path = args.binaries
+ if binary_path is None:
+ binary_path = os.path.abspath(dirname + '/../..')
+
+ print("checking execution binary path: " + binary_path)
+ if not os.path.exists(binary_path):
+ print("The execution binary path was not available. quit...")
+ os._exit(0)
+ api_set_value('binary_path', binary_path)
+
+ if suites_list is not None:
+ framework.target_suites = suites_list
+ else:
+ framework.load_suites()
+
+ framework.target_cases = cases_list
+ framework.start_run()
+
+ print("\n\n------------------------------------------------------------")
+ print("The run folder is [" + framework.running_folder +"]")
+ print("that's all. bye")
+
+ print("kill to quit..")
+ t_kill_process_by_name("start.py")
+
+ sys.exit(0)
+ os._exit()
+
+
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/01-install/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/01-install/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/01-install/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/01-install/case.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/01-install/case.py
new file mode 100644
index 000000000..b8d2c38b8
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/01-install/case.py
@@ -0,0 +1,94 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import sys
+import time
+import random
+import logging
+import json
+
+from framework.case_base import *
+from framework.test_api import *
+from harness.harness_api import *
+
+class CTestCase(CTestCaseBase):
+ def __init__(self, suite):
+ CTestCaseBase.__init__(self, suite)
+
+ def get_case_name(self):
+ case_path = os.path.dirname(os.path.abspath( __file__ ))
+ return os.path.split(case_path)[1]
+
+ def on_get_case_description(self):
+ return "startup the executables"
+
+ def on_setup_case(self):
+ os.chdir(self.get_case_name())
+ start_env()
+ api_log_error("on_setup_case OK")
+ return True, ''
+
+ def on_cleanup_case(self):
+ stop_env()
+ api_log_error("on_cleanup_case OK")
+ return True, ''
+
+ # called by the framework
+ def on_run_case(self):
+ time.sleep(0.5)
+
+ #uninstall inexistent App1
+ ret = uninstall_app("App1")
+ if (ret != 160):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps([])
+ if (ret == False):
+ return False, ''
+
+ #install App1
+ ret = install_app("App1", "01_install.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps(["App1"])
+ if (ret == False):
+ return False, ''
+
+ #install App2
+ ret = install_app("App2", "01_install.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps(["App1","App2"])
+ if (ret == False):
+ return False, ''
+
+ #uninstall App2
+ ret = uninstall_app("App2")
+ if (ret != 66):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps(["App1"])
+ if (ret == False):
+ return False, ''
+
+ return True, ''
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/02-request/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/02-request/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/02-request/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/02-request/case.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/02-request/case.py
new file mode 100644
index 000000000..e2192d5fa
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/02-request/case.py
@@ -0,0 +1,73 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import sys
+import time
+import random
+import logging
+import json
+
+from framework.case_base import *
+from framework.test_api import *
+from harness.harness_api import *
+
+class CTestCase(CTestCaseBase):
+ def __init__(self, suite):
+ CTestCaseBase.__init__(self, suite)
+
+ def get_case_name(self):
+ case_path = os.path.dirname(os.path.abspath( __file__ ))
+ return os.path.split(case_path)[1]
+
+ def on_get_case_description(self):
+ return "startup the executables"
+
+ def on_setup_case(self):
+ os.chdir(self.get_case_name())
+ start_env()
+ api_log_error("on_setup_case OK")
+ return True, ''
+
+ def on_cleanup_case(self):
+ stop_env()
+ api_log_error("on_cleanup_case OK")
+ return True, ''
+
+ # called by the framework
+ def on_run_case(self):
+ time.sleep(0.5)
+
+ #install App1
+ ret = install_app("App1", "02_request.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps(["App1"])
+ if (ret == False):
+ return False, ''
+
+ #send request to App1
+ ret = send_request("/res1", "GET", None)
+ if (ret != 69):
+ return False, ''
+ expect_response_payload = {"key1":"value1","key2":"value2"}
+ ret = check_response_payload(expect_response_payload)
+ if (ret == False):
+ return False, ''
+
+ #send request to App1
+ ret = send_request("/res2", "DELETE", None)
+ if (ret != 66):
+ return False, ''
+ expect_response_payload = {}
+ ret = check_response_payload(expect_response_payload)
+ if (ret == False):
+ return False, ''
+
+ return True, ''
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/03-event/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/03-event/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/03-event/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/03-event/case.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/03-event/case.py
new file mode 100644
index 000000000..3886cb820
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/03-event/case.py
@@ -0,0 +1,67 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+import sys
+import time
+import random
+import logging
+import json
+
+from framework.case_base import *
+from framework.test_api import *
+from harness.harness_api import *
+
+class CTestCase(CTestCaseBase):
+ def __init__(self, suite):
+ CTestCaseBase.__init__(self, suite)
+
+ def get_case_name(self):
+ case_path = os.path.dirname(os.path.abspath( __file__ ))
+ return os.path.split(case_path)[1]
+
+ def on_get_case_description(self):
+ return "startup the executables"
+
+ def on_setup_case(self):
+ os.chdir(self.get_case_name())
+ start_env()
+ api_log_error("on_setup_case OK")
+ return True, ''
+
+ def on_cleanup_case(self):
+ stop_env()
+ api_log_error("on_cleanup_case OK")
+ return True, ''
+
+ # called by the framework
+ def on_run_case(self):
+ time.sleep(0.5)
+
+ #install App1
+ ret = install_app("App1", "03_event.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps(["App1"])
+ if (ret == False):
+ return False, ''
+
+ #register event
+ ret = register("/alert/overheat", 2000, 5000)
+ if (ret != 69):
+ return False, ''
+ ret = check_get_event()
+ if (ret == False):
+ return False, ''
+
+ #deregister event
+ ret = deregister("/alert/overheat")
+ if (ret != 69):
+ return False, ''
+
+ return True, ''
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/case.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/case.py
new file mode 100644
index 000000000..bf395f58b
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/case.py
@@ -0,0 +1,80 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import sys
+import time
+import random
+import logging
+import json
+
+from framework.case_base import *
+from framework.test_api import *
+from harness.harness_api import *
+
+class CTestCase(CTestCaseBase):
+ def __init__(self, suite):
+ CTestCaseBase.__init__(self, suite)
+
+ def get_case_name(self):
+ case_path = os.path.dirname(os.path.abspath( __file__ ))
+ return os.path.split(case_path)[1]
+
+ def on_get_case_description(self):
+ return "startup the executables"
+
+ def on_setup_case(self):
+ os.chdir(self.get_case_name())
+ start_env()
+ api_log_error("on_setup_case OK")
+ return True, ''
+
+ def on_cleanup_case(self):
+ stop_env()
+ api_log_error("on_cleanup_case OK")
+ return True, ''
+
+ # called by the framework
+ def on_run_case(self):
+ time.sleep(0.5)
+
+ #install App1
+ ret = install_app("App1", "04_request_internal_resp.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #install App2
+ ret = install_app("App2", "04_request_internal_req.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps(["App1","App2"])
+ if (ret == False):
+ return False, ''
+
+ #send request to App2
+ ret = send_request("/res1", "GET", None)
+ if (ret != 69):
+ return False, ''
+ time.sleep(2)
+ expect_response_payload = {"key1":"value1","key2":"value2"}
+ ret = check_response_payload(expect_response_payload)
+ if (ret == False):
+ return False, ''
+
+ #send request to App2
+ ret = send_request("/res2", "GET", None)
+ if (ret != 69):
+ return False, ''
+ time.sleep(2)
+ expect_response_payload = {"key1":"value1","key2":"value2"}
+ ret = check_response_payload(expect_response_payload)
+ if (ret == False):
+ return False, ''
+
+ return True, ''
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/case.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/case.py
new file mode 100644
index 000000000..79c328749
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/case.py
@@ -0,0 +1,70 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import sys
+import time
+import random
+import logging
+import json
+
+from framework.case_base import *
+from framework.test_api import *
+from harness.harness_api import *
+
+class CTestCase(CTestCaseBase):
+ def __init__(self, suite):
+ CTestCaseBase.__init__(self, suite)
+
+ def get_case_name(self):
+ case_path = os.path.dirname(os.path.abspath( __file__ ))
+ return os.path.split(case_path)[1]
+
+ def on_get_case_description(self):
+ return "startup the executables"
+
+ def on_setup_case(self):
+ os.chdir(self.get_case_name())
+ start_env()
+ api_log_error("on_setup_case OK")
+ return True, ''
+
+ def on_cleanup_case(self):
+ stop_env()
+ api_log_error("on_cleanup_case OK")
+ return True, ''
+
+ # called by the framework
+ def on_run_case(self):
+ time.sleep(0.5)
+
+ #install App1
+ ret = install_app("App1", "05_event_internal_provider.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #install App2
+ ret = install_app("App2", "05_event_internal_subscriber.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps(["App1","App2"])
+ if (ret == False):
+ return False, ''
+
+ #send request to App2
+ ret = send_request("/res1", "GET", None)
+ if (ret != 69):
+ return False, ''
+ time.sleep(2)
+ expect_response_payload = {"key1":"value1","key2":"value2"}
+ ret = check_response_payload(expect_response_payload)
+ if (ret == False):
+ return False, ''
+
+ return True, ''
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/06-timer/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/06-timer/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/06-timer/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/06-timer/case.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/06-timer/case.py
new file mode 100644
index 000000000..90af4d5d9
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/06-timer/case.py
@@ -0,0 +1,70 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import sys
+import time
+import random
+import logging
+import json
+
+from framework.case_base import *
+from framework.test_api import *
+from harness.harness_api import *
+
+class CTestCase(CTestCaseBase):
+ def __init__(self, suite):
+ CTestCaseBase.__init__(self, suite)
+
+ def get_case_name(self):
+ case_path = os.path.dirname(os.path.abspath( __file__ ))
+ return os.path.split(case_path)[1]
+
+ def on_get_case_description(self):
+ return "startup the executables"
+
+ def on_setup_case(self):
+ os.chdir(self.get_case_name())
+ start_env()
+ api_log_error("on_setup_case OK")
+ return True, ''
+
+ def on_cleanup_case(self):
+ stop_env()
+ api_log_error("on_cleanup_case OK")
+ return True, ''
+
+ # called by the framework
+ def on_run_case(self):
+ time.sleep(0.5)
+
+ #install App1
+ ret = install_app("App1", "06_timer.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps(["App1"])
+ if (ret == False):
+ return False, ''
+
+ #send request to App1
+ ret = send_request("/res1", "GET", None)
+ if (ret != 69):
+ return False, ''
+
+ time.sleep(3)
+
+ ret = send_request("/check_timer", "GET", None)
+ if (ret != 69):
+ return False, ''
+ expect_response_payload = {"num":2}
+ ret = check_response_payload(expect_response_payload)
+ if (ret == False):
+ return False, ''
+
+ return True, ''
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/case.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/case.py
new file mode 100644
index 000000000..2bb756203
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/case.py
@@ -0,0 +1,65 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import sys
+import time
+import random
+import logging
+import json
+
+from framework.case_base import *
+from framework.test_api import *
+from harness.harness_api import *
+
+class CTestCase(CTestCaseBase):
+ def __init__(self, suite):
+ CTestCaseBase.__init__(self, suite)
+
+ def get_case_name(self):
+ case_path = os.path.dirname(os.path.abspath( __file__ ))
+ return os.path.split(case_path)[1]
+
+ def on_get_case_description(self):
+ return "startup the executables"
+
+ def on_setup_case(self):
+ os.chdir(self.get_case_name())
+ start_env()
+ api_log_error("on_setup_case OK")
+ return True, ''
+
+ def on_cleanup_case(self):
+ stop_env()
+ api_log_error("on_cleanup_case OK")
+ return True, ''
+
+ # called by the framework
+ def on_run_case(self):
+ time.sleep(0.5)
+
+ #install App1
+ ret = install_app("App1", "07_sensor.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps(["App1"])
+ if (ret == False):
+ return False, ''
+
+ #send request to App1
+ ret = send_request("/res1", "GET", None)
+ if (ret != 69):
+ return False, ''
+ time.sleep(2)
+ expect_response_payload = {"key1":"value1","key2":"value2"}
+ ret = check_response_payload(expect_response_payload)
+ if (ret == False):
+ return False, ''
+
+ return True, ''
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/case.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/case.py
new file mode 100644
index 000000000..99a4512ee
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/case.py
@@ -0,0 +1,78 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import sys
+import time
+import random
+import logging
+import json
+
+from framework.case_base import *
+from framework.test_api import *
+from harness.harness_api import *
+
+class CTestCase(CTestCaseBase):
+ def __init__(self, suite):
+ CTestCaseBase.__init__(self, suite)
+
+ def get_case_name(self):
+ case_path = os.path.dirname(os.path.abspath( __file__ ))
+ return os.path.split(case_path)[1]
+
+ def on_get_case_description(self):
+ return "startup the executables"
+
+ def on_setup_case(self):
+ os.chdir(self.get_case_name())
+ start_env()
+ api_log_error("on_setup_case OK")
+ return True, ''
+
+ def on_cleanup_case(self):
+ stop_env()
+ api_log_error("on_cleanup_case OK")
+ return True, ''
+
+ # called by the framework
+ def on_run_case(self):
+ time.sleep(0.5)
+
+ #install App1
+ ret = install_app("App1", "08_on_destroy.wasm")
+ if (ret != 65):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps(["App1"])
+ if (ret == False):
+ return False, ''
+
+ #send request to App1
+ ret = send_request("/res1", "GET", None)
+ if (ret != 69):
+ return False, ''
+ time.sleep(2)
+ expect_response_payload = {"key1":"value1"}
+ ret = check_response_payload(expect_response_payload)
+ if (ret == False):
+ return False, ''
+
+ #uninstall App1
+ ret = uninstall_app("App1")
+ if (ret != 66):
+ return False, ''
+
+ #query Apps
+ ret = query_app()
+ if (ret != 69):
+ return False, ''
+ ret = check_query_apps([])
+ if (ret == False):
+ return False, ''
+
+ return True, ''
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/cases/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/suite_setup.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/suite_setup.py
new file mode 100644
index 000000000..2307186f7
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/suite_setup.py
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+import os
+import shutil
+import types
+import time
+import glob
+
+from framework.test_api import *
+from framework.test_utils import *
+from harness.harness_api import *
+from framework.suite import *
+
+class CTestSuite(CTestSuiteBase):
+ setup_path = ""
+ def __init__(self, name, suite_path, run_path):
+ CTestSuiteBase.__init__(self, name, suite_path, run_path)
+
+ def on_suite_setup(self):
+ global setup_path
+ setup_path = os.getcwd()
+ cases = os.listdir(self.suite_path + "/cases/")
+ cases.sort()
+
+ if api_get_value("rebuild", False):
+ path_tmp = os.getcwd()
+ os.chdir(self.suite_path + "/test-app")
+ os.system(self.suite_path + "/test-app" + "/build.sh")
+ os.chdir(path_tmp)
+
+ os.makedirs(self.run_path + "/test-app")
+
+ for case in cases:
+ if case != "__init__.pyc" and case != "__init__.py":
+ os.makedirs(self.run_path + "/" + case)
+ #copy each case's host_tool, simple, wasm files, start/stop scripts to the run directory,
+ shutil.copy(setup_path + "/../../samples/simple/out/simple", self.run_path + "/" + case)
+ shutil.copy(setup_path + "/../../samples/simple/out/host_tool", self.run_path + "/" + case)
+ for file in glob.glob(self.suite_path + "/test-app/" + "/*.wasm"):
+ shutil.copy(file, self.run_path + "/test-app")
+ shutil.copy(self.suite_path + "/tools/product/start.sh", self.run_path + "/" + case)
+ shutil.copy(self.suite_path + "/tools/product/stop.sh", self.run_path + "/" + case)
+
+ os.chdir(self.run_path)
+
+ return True, 'OK'
+
+ def on_suite_cleanup(self):
+ global setup_path
+ os.chdir(setup_path)
+ api_log("stopping env..")
+
+ return True, 'OK'
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/01_install.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/01_install.c
new file mode 100644
index 000000000..5c7153588
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/01_install.c
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include "wasm_app.h"
+
+void
+on_init()
+{
+ printf("Hello, I was installed.\n");
+}
+
+void
+on_destroy()
+{
+ /* real destroy work including killing timer and closing sensor is
+ * accomplished in wasm app library version of on_destroy() */
+}
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/02_request.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/02_request.c
new file mode 100644
index 000000000..251de6ff4
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/02_request.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include "wasm_app.h"
+#include "wa-inc/request.h"
+
+void
+res1_handler(request_t *request)
+{
+ response_t response[1];
+ attr_container_t *payload;
+
+ printf("### user resource 1 handler called\n");
+
+ printf("###### dump request ######\n");
+ printf("sender: %lu\n", request->sender);
+ printf("url: %s\n", request->url);
+ printf("action: %d\n", request->action);
+ printf("payload:\n");
+ if (request->payload != NULL && request->payload_len > 0
+ && request->fmt == FMT_ATTR_CONTAINER)
+ attr_container_dump((attr_container_t *)request->payload);
+ printf("#### dump request end ###\n");
+
+ payload = attr_container_create("wasm app response payload");
+ if (payload == NULL)
+ return;
+
+ attr_container_set_string(&payload, "key1", "value1");
+ attr_container_set_string(&payload, "key2", "value2");
+
+ make_response_for_request(request, response);
+ set_response(response, CONTENT_2_05, FMT_ATTR_CONTAINER,
+ (const char *)payload,
+ attr_container_get_serialize_length(payload));
+ printf("reciver: %lu, mid:%d\n", response->reciever, response->mid);
+ api_response_send(response);
+
+ attr_container_destroy(payload);
+}
+
+void
+res2_handler(request_t *request)
+{
+ response_t response[1];
+ make_response_for_request(request, response);
+ set_response(response, DELETED_2_02, 0, NULL, 0);
+ api_response_send(response);
+
+ printf("### user resource 2 handler called\n");
+}
+
+void
+on_init()
+{
+ /* register resource uri */
+ api_register_resource_handler("/res1", res1_handler);
+ api_register_resource_handler("/res2", res2_handler);
+}
+
+void
+on_destroy()
+{
+ /* real destroy work including killing timer and closing sensor is
+ * accomplished in wasm app library version of on_destroy() */
+}
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/03_event.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/03_event.c
new file mode 100644
index 000000000..59cfd0097
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/03_event.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include "wasm_app.h"
+#include "wa-inc/timer_wasm_app.h"
+#include "wa-inc/request.h"
+
+int num = 0;
+
+void
+publish_overheat_event()
+{
+ attr_container_t *event;
+
+ event = attr_container_create("event");
+ attr_container_set_string(&event, "warning", "temperature is over high");
+
+ printf("###app publish event begin ###\n");
+
+ api_publish_event("alert/overheat", FMT_ATTR_CONTAINER, event,
+ attr_container_get_serialize_length(event));
+
+ printf("###app publish event end ###\n");
+
+ attr_container_destroy(event);
+}
+
+/* Timer callback */
+void
+timer1_update(user_timer_t timer)
+{
+ printf("Timer update %d\n", num++);
+ publish_overheat_event();
+}
+
+void
+start_timer()
+{
+ user_timer_t timer;
+
+ /* set up a timer */
+ timer = api_timer_create(1000, true, false, timer1_update);
+ api_timer_restart(timer, 1000);
+}
+
+void
+on_init()
+{
+ start_timer();
+}
+
+void
+on_destroy()
+{
+ /* real destroy work including killing timer and closing sensor is
+ * accomplished in wasm app library version of on_destroy() */
+}
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_req.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_req.c
new file mode 100644
index 000000000..99bab9704
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_req.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include "wasm_app.h"
+#include "wa-inc/request.h"
+
+uint32 mid;
+unsigned long sender;
+
+void
+my_response_handler(response_t *response, void *user_data)
+{
+ attr_container_t *payload;
+ printf("### user resource 1 handler called\n");
+
+ payload = attr_container_create("wasm app response payload");
+ if (payload == NULL)
+ return;
+
+ attr_container_set_string(&payload, "key1", "value1");
+ attr_container_set_string(&payload, "key2", "value2");
+
+ response->mid = mid;
+ response->reciever = sender;
+ set_response(response, CONTENT_2_05, FMT_ATTR_CONTAINER,
+ (const char *)payload,
+ attr_container_get_serialize_length(payload));
+ printf("reciver: %lu, mid:%d\n", response->reciever, response->mid);
+ api_response_send(response);
+
+ attr_container_destroy(payload);
+}
+
+static void
+test_send_request(const char *url, const char *tag)
+{
+ request_t request[1];
+
+ init_request(request, (char *)url, COAP_PUT, 0, NULL, 0);
+ api_send_request(request, my_response_handler, (void *)tag);
+}
+
+void
+res1_handler(request_t *request)
+{
+ mid = request->mid;
+ sender = request->sender;
+ test_send_request("url1", "a general request");
+}
+
+void
+res2_handler(request_t *request)
+{
+ mid = request->mid;
+ sender = request->sender;
+ test_send_request("/app/App1/url1", "a general request");
+}
+
+void
+on_init()
+{
+ /* register resource uri */
+ api_register_resource_handler("/res1", res1_handler);
+ api_register_resource_handler("/res2", res2_handler);
+}
+
+void
+on_destroy()
+{
+ /* real destroy work including killing timer and closing sensor is
+ * accomplished in wasm app library version of on_destroy() */
+}
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_resp.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_resp.c
new file mode 100644
index 000000000..13aecb43a
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_resp.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include "wasm_app.h"
+#include "wa-inc/request.h"
+
+void
+res1_handler(request_t *request)
+{
+ response_t response[1];
+ attr_container_t *payload;
+
+ printf("[resp] ### user resource 1 handler called\n");
+
+ printf("[resp] ###### dump request ######\n");
+ printf("[resp] sender: %lu\n", request->sender);
+ printf("[resp] url: %s\n", request->url);
+ printf("[resp] action: %d\n", request->action);
+ printf("[resp] payload:\n");
+ if (request->payload != NULL && request->fmt == FMT_ATTR_CONTAINER)
+ attr_container_dump((attr_container_t *)request->payload);
+ printf("[resp] #### dump request end ###\n");
+
+ payload = attr_container_create("wasm app response payload");
+ if (payload == NULL)
+ return;
+
+ attr_container_set_string(&payload, "key1", "value1");
+ attr_container_set_string(&payload, "key2", "value2");
+
+ make_response_for_request(request, response);
+ set_response(response, CONTENT_2_05, FMT_ATTR_CONTAINER,
+ (const char *)payload,
+ attr_container_get_serialize_length(payload));
+ printf("[resp] response payload len %d\n",
+ attr_container_get_serialize_length(payload));
+ printf("[resp] reciver: %lu, mid:%d\n", response->reciever, response->mid);
+ api_response_send(response);
+
+ attr_container_destroy(payload);
+}
+
+void
+on_init()
+{
+ /* register resource uri */
+ api_register_resource_handler("/url1", res1_handler);
+}
+
+void
+on_destroy()
+{
+ /* real destroy work including killing timer and closing sensor is
+ * accomplished in wasm app library version of on_destroy() */
+}
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_provider.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_provider.c
new file mode 100644
index 000000000..59cfd0097
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_provider.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include "wasm_app.h"
+#include "wa-inc/timer_wasm_app.h"
+#include "wa-inc/request.h"
+
+int num = 0;
+
+void
+publish_overheat_event()
+{
+ attr_container_t *event;
+
+ event = attr_container_create("event");
+ attr_container_set_string(&event, "warning", "temperature is over high");
+
+ printf("###app publish event begin ###\n");
+
+ api_publish_event("alert/overheat", FMT_ATTR_CONTAINER, event,
+ attr_container_get_serialize_length(event));
+
+ printf("###app publish event end ###\n");
+
+ attr_container_destroy(event);
+}
+
+/* Timer callback */
+void
+timer1_update(user_timer_t timer)
+{
+ printf("Timer update %d\n", num++);
+ publish_overheat_event();
+}
+
+void
+start_timer()
+{
+ user_timer_t timer;
+
+ /* set up a timer */
+ timer = api_timer_create(1000, true, false, timer1_update);
+ api_timer_restart(timer, 1000);
+}
+
+void
+on_init()
+{
+ start_timer();
+}
+
+void
+on_destroy()
+{
+ /* real destroy work including killing timer and closing sensor is
+ * accomplished in wasm app library version of on_destroy() */
+}
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_subscriber.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_subscriber.c
new file mode 100644
index 000000000..00e451369
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_subscriber.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include "wasm_app.h"
+#include "wa-inc/request.h"
+
+uint32 mid;
+unsigned long sender;
+
+void
+over_heat_event_handler(request_t *request)
+{
+ response_t response[1];
+ attr_container_t *payload;
+
+ payload = attr_container_create("wasm app response payload");
+ if (payload == NULL)
+ return;
+
+ attr_container_set_string(&payload, "key1", "value1");
+ attr_container_set_string(&payload, "key2", "value2");
+
+ response->mid = mid;
+ response->reciever = sender;
+ set_response(response, CONTENT_2_05, FMT_ATTR_CONTAINER,
+ (const char *)payload,
+ attr_container_get_serialize_length(payload));
+ printf("reciver: %lu, mid:%d\n", response->reciever, response->mid);
+ api_response_send(response);
+
+ attr_container_destroy(payload);
+}
+
+void
+res1_handler(request_t *request)
+{
+ mid = request->mid;
+ sender = request->sender;
+ api_subscribe_event("alert/overheat", over_heat_event_handler);
+}
+
+void
+on_init()
+{
+ /* register resource uri */
+ api_register_resource_handler("/res1", res1_handler);
+}
+
+void
+on_destroy()
+{
+ /* real destroy work including killing timer and closing sensor is
+ * accomplished in wasm app library version of on_destroy() */
+}
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/06_timer.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/06_timer.c
new file mode 100644
index 000000000..6aa107d5c
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/06_timer.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include "wasm_app.h"
+#include "wa-inc/request.h"
+#include "wa-inc/timer_wasm_app.h"
+
+/* User global variable */
+int num = 0;
+
+/* Timer callback */
+void
+timer1_update(user_timer_t timer)
+{
+ if (num < 2)
+ num++;
+}
+
+void
+res1_handler(request_t *request)
+{
+ user_timer_t timer;
+
+ /* set up a timer */
+ timer = api_timer_create(1000, true, false, timer1_update);
+ api_timer_restart(timer, 1000);
+
+ response_t response[1];
+
+ make_response_for_request(request, response);
+
+ set_response(response, CONTENT_2_05, FMT_ATTR_CONTAINER, NULL, 0);
+
+ api_response_send(response);
+}
+
+void
+res2_handler(request_t *request)
+{
+ response_t response[1];
+ attr_container_t *payload;
+
+ if (num == 2) {
+ attr_container_t *payload;
+ printf("### user resource 1 handler called\n");
+
+ payload = attr_container_create("wasm app response payload");
+ if (payload == NULL)
+ return;
+
+ attr_container_set_int(&payload, "num", num);
+
+ make_response_for_request(request, response);
+
+ set_response(response, CONTENT_2_05, FMT_ATTR_CONTAINER,
+ (const char *)payload,
+ attr_container_get_serialize_length(payload));
+ printf("reciver: %lu, mid:%d\n", response->reciever, response->mid);
+ api_response_send(response);
+
+ attr_container_destroy(payload);
+ }
+}
+
+void
+on_init()
+{
+ /* register resource uri */
+ api_register_resource_handler("/res1", res1_handler);
+ api_register_resource_handler("/check_timer", res2_handler);
+}
+
+void
+on_destroy()
+{
+ /* real destroy work including killing timer and closing sensor is
+ * accomplished in wasm app library version of on_destroy() */
+}
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/07_sensor.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/07_sensor.c
new file mode 100644
index 000000000..a6c24a8bc
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/07_sensor.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include "wasm_app.h"
+#include "wa-inc/request.h"
+#include "wa-inc/sensor.h"
+
+uint32 mid;
+unsigned long sender;
+
+/* Sensor event callback*/
+void
+sensor_event_handler(sensor_t sensor, attr_container_t *event, void *user_data)
+{
+ printf("### app get sensor event\n");
+
+ response_t response[1];
+ attr_container_t *payload;
+
+ payload = attr_container_create("wasm app response payload");
+ if (payload == NULL)
+ return;
+
+ attr_container_set_string(&payload, "key1", "value1");
+ attr_container_set_string(&payload, "key2", "value2");
+
+ response->mid = mid;
+ response->reciever = sender;
+ set_response(response, CONTENT_2_05, FMT_ATTR_CONTAINER,
+ (const char *)payload,
+ attr_container_get_serialize_length(payload));
+ printf("reciver: %lu, mid:%d\n", response->reciever, response->mid);
+ api_response_send(response);
+
+ attr_container_destroy(payload);
+}
+
+void
+res1_handler(request_t *request)
+{
+ mid = request->mid;
+ sender = request->sender;
+
+ sensor_t sensor;
+ char *user_data;
+ attr_container_t *config;
+
+ printf("### app on_init 1\n");
+ /* open a sensor */
+ user_data = malloc(100);
+ printf("### app on_init 2\n");
+ sensor = sensor_open("sensor_test", 0, sensor_event_handler, user_data);
+ printf("### app on_init 3\n");
+
+ /* config the sensor */
+ sensor_config(sensor, 2000, 0, 0);
+ printf("### app on_init 4\n");
+}
+
+void
+on_init()
+{
+ /* register resource uri */
+ api_register_resource_handler("/res1", res1_handler);
+}
+
+void
+on_destroy()
+{
+ /* real destroy work including killing timer and closing sensor is
+ * accomplished in wasm app library version of on_destroy() */
+}
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/08_on_destroy.c b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/08_on_destroy.c
new file mode 100644
index 000000000..ac05a77da
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/08_on_destroy.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ */
+
+#include "wasm_app.h"
+#include "wa-inc/request.h"
+#include "wa-inc/sensor.h"
+
+uint32 mid;
+unsigned long sender;
+sensor_t sensor;
+
+/* Sensor event callback*/
+void
+sensor_event_handler(sensor_t sensor, attr_container_t *event, void *user_data)
+{
+ printf("### app get sensor event\n");
+
+ response_t response[1];
+ attr_container_t *payload;
+
+ payload = attr_container_create("wasm app response payload");
+ if (payload == NULL)
+ return;
+
+ attr_container_set_string(&payload, "key1", "value1");
+
+ response->mid = mid;
+ response->reciever = sender;
+ set_response(response, CONTENT_2_05, FMT_ATTR_CONTAINER,
+ (const char *)payload,
+ attr_container_get_serialize_length(payload));
+ printf("reciver: %lu, mid:%d\n", response->reciever, response->mid);
+ api_response_send(response);
+
+ attr_container_destroy(payload);
+}
+
+void
+res1_handler(request_t *request)
+{
+ mid = request->mid;
+ sender = request->sender;
+
+ char *user_data;
+ attr_container_t *config;
+
+ printf("### app on_init 1\n");
+ /* open a sensor */
+ user_data = malloc(100);
+ printf("### app on_init 2\n");
+ sensor = sensor_open("sensor_test", 0, sensor_event_handler, user_data);
+ printf("### app on_init 3\n");
+}
+
+void
+on_init()
+{
+ /* register resource uri */
+ api_register_resource_handler("/res1", res1_handler);
+}
+
+void
+on_destroy()
+{
+ if (NULL != sensor) {
+ sensor_close(sensor);
+ }
+}
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/build.sh b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/build.sh
new file mode 100755
index 000000000..4b5428051
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/test-app/build.sh
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+. ../../../set_dev_env.sh
+
+CC=/opt/wasi-sdk/bin/clang
+APP_DIR=$PWD
+WAMR_DIR=${APP_DIR}/../../../../../
+SDK_DIR=${WAMR_DIR}/wamr-sdk/out/simple-host-interp
+APP_FRAMEWORK_DIR=${SDK_DIR}/app-sdk/wamr-app-framework
+DEPS_DIR=${WAMR_DIR}/core/deps
+
+for i in `ls *.c`
+do
+APP_SRC="$i"
+OUT_FILE=${i%.*}.wasm
+/opt/wasi-sdk/bin/clang -O3 \
+ -Wno-int-conversion \
+ -I${APP_FRAMEWORK_DIR}/include \
+ -I${DEPS_DIR} \
+ -O3 -z stack-size=4096 -Wl,--initial-memory=65536 \
+ --sysroot=${SDK_DIR}/app-sdk/libc-builtin-sysroot \
+ -L${APP_FRAMEWORK_DIR}/lib -lapp_framework \
+ -Wl,--allow-undefined-file=${SDK_DIR}/app-sdk/libc-builtin-sysroot/share/defined-symbols.txt \
+ -Wl,--strip-all,--no-entry -nostdlib \
+ -Wl,--export=on_init -Wl,--export=on_destroy \
+ -Wl,--export=on_request -Wl,--export=on_response \
+ -Wl,--export=on_sensor_event -Wl,--export=on_timer_callback \
+ -Wl,--export=on_connection_data \
+ -o ${OUT_FILE} \
+ ${APP_SRC}
+if [ -f ${OUT_FILE} ]; then
+ echo "build ${OUT_FILE} success"
+else
+ echo "build ${OUT_FILE} fail"
+fi
+done
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/tools/product/start.sh b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/tools/product/start.sh
new file mode 100755
index 000000000..f83e39356
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/tools/product/start.sh
@@ -0,0 +1,10 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+#!/bin/bash
+
+cd $(dirname "$0")
+
+./simple -s > /dev/null 2>&1 &
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/tools/product/stop.sh b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/tools/product/stop.sh
new file mode 100755
index 000000000..b7bc2c8d2
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/01-life-cycle/tools/product/stop.sh
@@ -0,0 +1,9 @@
+#
+# Copyright (C) 2019 Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+
+#!/bin/bash
+
+ps aux | grep -ie host_tool | awk '{print $2}' | xargs kill -9 &
+ps aux | grep -ie simple | awk '{print $2}' | xargs kill -9 &
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/__init__.py b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/__init__.py
diff --git a/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/readme.txt b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/readme.txt
new file mode 100644
index 000000000..1e8792f5b
--- /dev/null
+++ b/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/test-tools/component-test/suites/readme.txt
@@ -0,0 +1,19 @@
+The description of each case in the test suites, should add descriptions in this file when new cases created in the future.
+
+suite 01-life-cycle:
+case 01-install:
+ install or uninstall apps for times and query apps to see if the app list is expected.
+case 02-request:
+ send request to an app, the app will respond specific attribute objects, host side should get them.
+case 03-event:
+ register event to an app, the app will send event back periodically, host side should get some payload.
+case 04-request_internal:
+ install 2 apps, host sends request to app2, then app2 sends request to app1, finally app1 respond specific payload to host, host side will check it.
+case 05-event_internal:
+ install 2 apps, host sends request to app2, then app2 subscribe app1's event, finally app1 respond specific payload to host, host side will check it.
+case 06-timer:
+ host send request to an app, the app then start a timer, when time goes by 2 seconds, app will respond specific payload to host, host side will check it.
+case 07-sensor:
+ open sensor in app and then config the sensor in on_init, finally app will respond specific payload to host, host side will check it.
+case 08-on_destroy:
+ open sensor in app in on_init, and close the sensor in on_destroy, host should install and uninstall the app successfully.