Add capi-system-resource-monitor 21/273021/5 accepted/tizen/unified/20220401.033603 submit/tizen/20220401.015456 submit/tizen/20220401.020712
authorChanwoo Choi <cw00.choi@samsung.com>
Mon, 7 Mar 2022 07:38:09 +0000 (16:38 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 30 Mar 2022 06:12:53 +0000 (15:12 +0900)
Add new capi-system-resource-monitor to support resource monitor
and add the skeleton code for capi-system-resource-monitor-tool.

[Package list]
- Following packages provides Tizen C API library and header file.
capi-system-resource-monitor-0.0.1-0.aarch64.rpm
capi-system-resource-monitor-devel-0.0.1-0.aarch64.rpm
capi-system-resource-monitor-debuginfo-0.0.1-0.aarch64.rpm
capi-system-resource-monitor-debugsource-0.0.1-0.aarch64.rpm

- Following packages provides the 'resouce-monitor-test' executable binary.
capi-system-resource-monitor-tool-0.0.1-0.aarch64.rpm
capi-system-resource-monitor-tool-debuginfo-0.0.1-0.aarch64.rpm

[File hierarchy]
usr/
├── bin
│   └── resource-monitor-test
├── include
│   └── system
│       └── resource-monitor.h
├── lib
│   └── debug
│       └── usr
│           ├── bin
│           │   └── resource-monitor-test.debug
│           └── lib64
│               └── libcapi-system-resource-monitor.so.0.0.1.debug
├── lib64
│   ├── libcapi-system-resource-monitor.so -> libcapi-system-resource-monitor.so.0
│   ├── libcapi-system-resource-monitor.so.0 -> libcapi-system-resource-monitor.so.0.0.1
│   ├── libcapi-system-resource-monitor.so.0.0.1
│   └── pkgconfig
│       └── capi-system-resource-monitor.pc
├── share
│   └── licenses
│       └── capi-system-resource-monitor
│           └── LICENSE
└── src
    └── debug
        └── capi-system-resource-monitor-0.0.1-0.aarch64
            ├── src
            │   └── resouce-monitor.c
            └── test
                └── resource-monitor-test.c

Change-Id: I1442fe2b5aab47c1c7678fc2403e2b8be51a04ac
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
13 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0644]
NOTICE [new file with mode: 0644]
capi-system-resource-monitor.pc.in [new file with mode: 0644]
doc/resource-monitor-doc.h [new file with mode: 0644]
include/resource-monitor.h [new file with mode: 0644]
packaging/capi-system-resource-monitor.changes [new file with mode: 0644]
packaging/capi-system-resource-monitor.manifest [new file with mode: 0644]
packaging/capi-system-resource-monitor.spec [new file with mode: 0644]
src/resouce-monitor.c [new file with mode: 0644]
test/CMakeLists.txt [new file with mode: 0644]
test/resource-monitor-test.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..9037e7f
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+Chanwoo Choi <cw00.choi@samsung.com>
+Dongwoo Lee <dwoo08.lee@samsung.com>
+Sunghun Kim <sfoon.kim@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e7f243e
--- /dev/null
@@ -0,0 +1,114 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-system-resource-monitor")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(PKG_MODULES
+       dlog
+       capi-base-common
+       capi-system-info
+       libpass
+)
+SET(pc_dependents "capi-base-common libpass")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${PKG_MODULES})
+FOREACH(flag ${${fw_name}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+    SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -fPIC -Wall -Werror -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
+
+aux_source_directory(src/cpp CPPSOURCES)
+aux_source_directory(src SOURCES)
+
+SET(ALL_SRC ${SOURCES} ${CPPSOURCES})
+
+ADD_LIBRARY(${fw_name} SHARED ${ALL_SRC})
+
+SET_TARGET_PROPERTIES(${fw_name}
+     PROPERTIES
+     VERSION ${FULLVER}
+     SOVERSION ${MAJORVER}
+     CLEAN_DIRECT_OUTPUT 1
+)
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+SET_TARGET_PROPERTIES(${fw_name}
+     PROPERTIES
+     VERSION ${FULLVER}
+     SOVERSION ${MAJORVER}
+     CLEAN_DIRECT_OUTPUT 1
+)
+
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(
+        DIRECTORY ${INC_DIR}/ DESTINATION include/system
+        FILES_MATCHING
+        PATTERN "*_private.h" EXCLUDE
+        PATTERN "*cpp*.h" EXCLUDE
+        PATTERN "C*.h" EXCLUDE
+        PATTERN "I*.h" EXCLUDE
+        PATTERN "${INC_DIR}/*.h"
+        )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_dependents})
+SET(PC_LDFLAGS -l${fw_name})
+SET(PC_CFLAGS -I\${includedir}/system)
+
+CONFIGURE_FILE(
+    ${fw_name}.pc.in
+    ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+    @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+ADD_SUBDIRECTORY(test)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+        DEPENDS clean
+        COMMENT "distribution clean"
+        COMMAND find
+        ARGS    .
+        -not -name config.cmake -and \(
+        -name tester.c -or
+        -name Testing -or
+        -name CMakeFiles -or
+        -name cmake.depends -or
+        -name cmake.check_depends -or
+        -name CMakeCache.txt -or
+        -name cmake.check_cache -or
+        -name *.cmake -or
+        -name Makefile -or
+        -name core -or
+        -name core.* -or
+        -name gmon.out -or
+        -name install_manifest.txt -or
+        -name *.pc -or
+        -name *~ \)
+        | grep -v TC | xargs rm -rf
+        TARGET  distclean
+        VERBATIM
+)
+
+ENDIF(UNIX)
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..2a23d75
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,203 @@
+Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..ccdad52
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
diff --git a/capi-system-resource-monitor.pc.in b/capi-system-resource-monitor.pc.in
new file mode 100644 (file)
index 0000000..4037ac7
--- /dev/null
@@ -0,0 +1,14 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=@LIB_INSTALL_DIR@
+includedir=/usr/include/system
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
diff --git a/doc/resource-monitor-doc.h b/doc/resource-monitor-doc.h
new file mode 100644 (file)
index 0000000..ef488be
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_SYSTEM_RESOURCE_MONITOR_DOC_H__
+#define __TIZEN_SYSTEM_RESOURCE_MONITOR_DOC_H__
+
+/**
+ * @file resource-monitor-doc.h
+ * @brief This file contains high level documentation for the Resource Monitor API.
+ *
+ */
+
+/**
+ * @defgroup CAPI_SYSTEM_RESOURCE_MONITOR_MODULE Resource Monitor
+ * @ingroup CAPI_SYSTEM_FRAMEWORK
+ */
+
+/**
+ * @ingroup CAPI_SYSTEM_FRAMEWORK
+ * @addtogroup CAPI_SYSTEM_RESOURCE_MONITOR_MODULE
+ * @brief The @ref CAPI_SYSTEM_RESOURCE_MONITOR_MODULE API provides functions for monitoring the devices such as Process, CPU, GPU, Memory Bus, Network, Disk and so on.
+ * @section CAPI_SYSTEM_RESOURCE_MONITOR_MODULE_HEADER Required Header
+ *    \#include <system/resource_monitor.h>
+ *
+ * @section CAPI_SYSTEM_RESOURCE_MONITOR_MODULE_OVERVIEW Overview
+ * The Resource Monitor API provides a set of functions to monitor the resources such as Process, CPU, GPU, Memory Bus, Network, Disk and so on.
+ *
+ * TODO
+ */
+
+#endif /* __TIZEN_SYSTEM_RESOURCE_MONITOR_DOC_H__ */
diff --git a/include/resource-monitor.h b/include/resource-monitor.h
new file mode 100644 (file)
index 0000000..5bbbe72
--- /dev/null
@@ -0,0 +1,331 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __resource_SYSTEM_RESOURCE_MONITOR_H__
+#define __resource_SYSTEM_RESOURCE_MONITOR_H__
+
+#include <sys/types.h>
+#include <pass/tmonitor.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file resource-monitor.h
+ * @brief Provide resource C API for Resource Monitor
+ */
+
+/**
+ * @addtogroup CAPI_SYSTEM_RESOURCE_MONITOR_MODULE
+ * @{
+ */
+
+/**
+ * @brief Define the supported resource type for monitoring
+ * @since_tizen 7.0
+ */
+enum {
+       RESOURCE_MONITOR_TYPE_UNKNOWN                   = RESOURCE_TYPE_UNKNOWN,
+       RESOURCE_MONITOR_TYPE_CPU                       = RESOURCE_TYPE_CPU,
+       RESOURCE_MONITOR_TYPE_BUS                       = RESOURCE_TYPE_BUS,
+       RESOURCE_MONITOR_TYPE_GPU                       = RESOURCE_TYPE_GPU,
+       RESOURCE_MONITOR_TYPE_MEMORY                    = RESOURCE_TYPE_MEMORY,
+       RESOURCE_MONITOR_TYPE_BATTERY                   = RESOURCE_TYPE_BATTERY,
+       RESOURCE_MONITOR_TYPE_PROCESS                   = RESOURCE_TYPE_PROCESS,
+       RESOURCE_MONITOR_TYPE_DISPLAY                   = RESOURCE_TYPE_DISPLAY,
+       RESOURCE_MONITOR_TYPE_SYSTEM                    = RESOURCE_TYPE_SYSTEM,
+       RESOURCE_MONITOR_TYPE_PROCESS_GROUP             = RESOURCE_TYPE_PROCESS_GROUP,
+};
+
+/**
+ * @brief Define the supported attributes and controls for CPU resource type
+ * @since_tizen 7.0
+ */
+enum {
+       RESOURCE_MONITOR_CPU_ATTR_CUR_FREQ              = CPU_ATTR_CUR_FREQ,            /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_CPU_ATTR_MIN_FREQ              = CPU_ATTR_MIN_FREQ,            /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_CPU_ATTR_MAX_FREQ              = CPU_ATTR_MAX_FREQ,            /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_CPU_ATTR_AVAILABLE_MIN_FREQ    = CPU_ATTR_AVAILABLE_MIN_FREQ,  /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_CPU_ATTR_AVAILABLE_MAX_FREQ    = CPU_ATTR_AVAILABLE_MAX_FREQ,  /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_CPU_ATTR_CUR_GOVERNOR          = CPU_ATTR_CUR_GOVERNOR,        /* DATA_TYPE_STRING */
+};
+
+enum {
+       RESOURCE_MONITOR_CPU_CTRL_CLUSTER_ID            = CPU_CTRL_CLUSTER_ID,
+};
+
+/**
+ * @brief Define the supported attributes and controls for Memory bus resource type
+ * @since_tizen 7.0
+ */
+enum {
+       RESOURCE_MONITOR_BUS_ATTR_CUR_FREQ              = BUS_ATTR_CUR_FREQ,            /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_BUS_ATTR_MIN_FREQ              = BUS_ATTR_MIN_FREQ,            /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_BUS_ATTR_MAX_FREQ              = BUS_ATTR_MAX_FREQ,            /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_BUS_ATTR_AVAILABLE_MIN_FREQ    = BUS_ATTR_AVAILABLE_MIN_FREQ,  /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_BUS_ATTR_AVAILABLE_MAX_FREQ    = BUS_ATTR_AVAILABLE_MAX_FREQ,  /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_BUS_ATTR_CUR_GOVERNOR          = BUS_ATTR_CUR_GOVERNOR,        /* DATA_TYPE_STRING */
+};
+
+enum {
+       RESOURCE_MONITOR_BUS_CTRL_DEVICE_ID             = BUS_CTRL_DEVICE_ID,
+};
+
+/**
+ * @brief Define the supported attributes and controls for GPU resource type
+ * @since_tizen 7.0
+ */
+enum {
+       RESOURCE_MONITOR_GPU_ATTR_CUR_FREQ              = GPU_ATTR_CUR_FREQ,            /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_GPU_ATTR_MIN_FREQ              = GPU_ATTR_MIN_FREQ,            /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_GPU_ATTR_MAX_FREQ              = GPU_ATTR_MAX_FREQ,            /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_GPU_ATTR_AVAILABLE_MIN_FREQ    = GPU_ATTR_AVAILABLE_MIN_FREQ,  /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_GPU_ATTR_AVAILABLE_MAX_FREQ    = GPU_ATTR_AVAILABLE_MAX_FREQ,  /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_GPU_ATTR_CUR_GOVERNOR          = GPU_ATTR_CUR_GOVERNOR,        /* DATA_TYPE_STRING */
+};
+
+enum {
+       RESOURCE_MONITOR_GPU_CTRL_DEVICE_ID             = GPU_CTRL_DEVICE_ID,
+};
+
+/**
+ * @brief Define the supported attributes for Memory resource type
+ * @since_tizen 7.0
+ */
+enum {
+       RESOURCE_MONITOR_MEMORY_ATTR_TOTAL              = MEMORY_ATTR_TOTAL,            /* DATA_TYPE_UINT64 */
+       RESOURCE_MONITOR_MEMORY_ATTR_AVAILABLE          = MEMORY_ATTR_AVAILABLE,        /* DATA_TYPE_UINT64 */
+       RESOURCE_MONITOR_MEMORY_ATTR_FREE               = MEMORY_ATTR_FREE,             /* DATA_TYPE_UINT64 */
+       RESOURCE_MONITOR_MEMORY_ATTR_BUFFER             = MEMORY_ATTR_BUFFER,           /* DATA_TYPE_UINT64 */
+       RESOURCE_MONITOR_MEMORY_ATTR_CACHED             = MEMORY_ATTR_CACHED,           /* DATA_TYPE_UINT64 */
+       RESOURCE_MONITOR_MEMORY_ATTR_CMA_TOTAL          = MEMORY_ATTR_CMA_TOTAL,        /* DATA_TYPE_UINT64 */
+       RESOURCE_MONITOR_MEMORY_ATTR_CMA_FREE           = MEMORY_ATTR_CMA_FREE,         /* DATA_TYPE_UINT64 */
+};
+
+/**
+ * @brief Define the supported attributes for Battery resource type
+ * @since_tizen 7.0
+ */
+enum {
+       RESOURCE_MONITOR_BATTERY_ATTR_CAPACITY          = BATTERY_ATTR_CAPACITY,        /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_BATTERY_ATTR_STATUS            = BATTERY_ATTR_STATUS,          /* DATA_TYPE_STRING */
+       RESOURCE_MONITOR_BATTERY_ATTR_TEMPERATURE       = BATTERY_ATTR_TEMPERATURE,     /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_BATTERY_ATTR_VOLTAGE_NOW       = BATTERY_ATTR_VOLTAGE_NOW,     /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_BATTERY_ATTR_CURRENT_NOW       = BATTERY_ATTR_CURRENT_NOW,     /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_BATTERY_ATTR_PRESENT           = BATTERY_ATTR_PRESENT,         /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_BATTERY_ATTR_ONLINE            = BATTERY_ATTR_ONLINE,          /* DATA_TYPE_INT */
+};
+
+/**
+ * @brief Define the supported attributes and controls for Display resource type
+ * @since_tizen 7.0
+ */
+enum {
+       RESOURCE_MONITOR_DISPLAY_ATTR_FPS                       = DISPLAY_ATTR_FPS,             /* DATA_TYPE_DOUBLE */
+};
+
+enum {
+       RESOURCE_MONITOR_DISPLAY_CTRL_DEVICE_ID         = DISPLAY_CTRL_DEVICE_ID,
+};
+
+/**
+ * @brief Define the supported attributes for System resource type
+ * @since_tizen 7.0
+ */
+enum {
+       RESOURCE_MONITOR_SYSTEM_ATTR_CPU_UTIL           = SYSTEM_ATTR_CPU_UTIL,         /* DATA_TYPE_DOUBLE */
+       RESOURCE_MONITOR_SYSTEM_ATTR_CPU_USER_UTIL      = SYSTEM_ATTR_CPU_USER_UTIL,    /* DATA_TYPE_DOUBLE */
+       RESOURCE_MONITOR_SYSTEM_ATTR_CPU_SYS_UTIL       = SYSTEM_ATTR_CPU_SYS_UTIL,     /* DATA_TYPE_DOUBLE */
+       RESOURCE_MONITOR_SYSTEM_ATTR_PER_CPU_UTIL       = SYSTEM_ATTR_PER_CPU_UTIL,     /* DATA_TYPE_ARRAY(DOUBLE) */
+       RESOURCE_MONITOR_SYSTEM_ATTR_PER_CPU_USER_UTIL  = SYSTEM_ATTR_PER_CPU_USER_UTIL,/* DATA_TYPE_ARRAY(DOUBLE) */
+       RESOURCE_MONITOR_SYSTEM_ATTR_PER_CPU_SYS_UTIL   = SYSTEM_ATTR_PER_CPU_SYS_UTIL, /* DATA_TYPE_ARRAY(DOUBLE) */
+       RESOURCE_MONITOR_SYSTEM_ATTR_POSSIBLE_CPU       = SYSTEM_ATTR_POSSIBLE_CPU,     /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_SYSTEM_ATTR_ONLINE_CPU         = SYSTEM_ATTR_ONLINE_CPU,       /* DATA_TYPE_INT */
+};
+
+/**
+ * @brief Define the supported attributes and controls for Process resource type
+ * @since_tizen 7.0
+ */
+enum {
+       RESOURCE_MONITOR_PROCESS_ATTR_CPU_UTIL          = PROCESS_ATTR_CPU_UTIL,        /* DATA_TYPE_DOUBLE */
+       RESOURCE_MONITOR_PROCESS_ATTR_MEM_VIRT          = PROCESS_ATTR_MEM_VIRT,        /* DATA_TYPE_UINT64 */
+       RESOURCE_MONITOR_PROCESS_ATTR_MEM_RSS           = PROCESS_ATTR_MEM_RSS,         /* DATA_TYPE_UINT64 */
+       RESOURCE_MONITOR_PROCESS_ATTR_MEM_RSS_PERCENT   = PROCESS_ATTR_MEM_RSS_PERCENT, /* DATA_TYPE_DOUBLE */
+       RESOURCE_MONITOR_PROCESS_ATTR_DISK_READ_BPS     = PROCESS_ATTR_DISK_READ_BPS,   /* DATA_TYPE_UINT */
+       RESOURCE_MONITOR_PROCESS_ATTR_DISK_WRITE_BPS    = PROCESS_ATTR_DISK_WRITE_BPS,  /* DATA_TYPE_UINT */
+       RESOURCE_MONITOR_PROCESS_ATTR_COMM              = PROCESS_ATTR_COMM,            /* DATA_TYPE_STRING */
+       RESOURCE_MONITOR_PROCESS_ATTR_PGID              = PROCESS_ATTR_PGID,            /* DATA_TYPE_INT */
+       RESOURCE_MONITOR_PROCESS_ATTR_PPID              = PROCESS_ATTR_PPID,            /* DATA_TYPE_INT */
+};
+
+enum {
+       RESOURCE_MONITOR_PROCESS_CTRL_TGID              = PROCESS_CTRL_TGID,
+};
+
+/**
+ * @brief Define the supported attributes and controls for Process Group resource type
+ * @since_tizen 7.0
+ */
+enum {
+       RESOURCE_MONITOR_PROCESS_GROUP_ATTR_PID_LIST    = PROCESS_GROUP_ATTR_PID_LIST,  /* DATA_TYPE_ARRAY(INT) */
+       RESOURCE_MONITOR_PROCESS_GROUP_ATTR_COMM_LIST   = PROCESS_GROUP_ATTR_COMM_LIST, /* DATA_TYPE_ARRAY(STRING) */
+};
+
+enum {
+       RESOURCE_MONITOR_PROCESS_GROUP_CTRL_ROOT_PID    = PROCESS_GROUP_CTRL_ROOT_PID,
+};
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SYSTEM_RESOURCE_MONITOR_MODULE
+ * @{
+ */
+
+/**
+ * @brief Initialize the resource monitor
+ * @since_tizen 7.0
+ * @return @c positive integer as resource monitor id on success, otherwise a negative error value
+ */
+int resource_monitor_init(void);
+
+/**
+ * @brief Exit the resource monitor
+ * @param[in] Id of resource monitor which be returnted by resource_monitor_init
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int resource_monitor_exit(int id);
+
+/**
+ * @brief Get the count of supported resources according to resource type
+ * @param[in] Resource monitor id
+ * @param[in] Resource type
+ * @return @c positive integer as resource count on success, otherwise a negative error value
+ */
+int resource_monitor_get_resource_count(int id, int resource_type);
+
+/**
+ * @brief Create resource for given resource_type
+ * @param[in] Resource monitor id which be returnted by resource_monitor_init
+ * @param[in] Resource type
+ * @return @c positive integer as resource id on success, otherwise a negative error value
+ */
+int resource_monitor_create_resource(int id, int resource_type);
+
+/**
+ * @brief Delete resource of given resource id
+ * @param[in] Resource monitor id which be returnted by resource_monitor_init
+ * @param[in] Resource id
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int resource_monitor_delete_resource(int id, int resource_id);
+
+/**
+ * @brief Set the resource control with value which is diffierential according to resource control id
+ * @param[in] Resource monitor id
+ * @param[in] Resource id
+ * @param[in] Resource control id
+ * @param[in] Value for resource control id
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int resource_monitor_set_resource_ctrl(int id, int resource_id, u_int64_t ctrl_id, int value);
+
+/**
+ * @brief Set the interested attributes for monitoring
+ * @param[in] Resource monitor id
+ * @param[in] Resource id
+ * @param[in] Attribute mask including the various attributes
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int resource_monitor_set_resource_attr(int id, int resource_id, u_int64_t attr_mask);
+
+/**
+ * @brief Unset the interested attributes for monitoring
+ * @param[in] Resource monitor id
+ * @param[in] Resource id
+ * @param[in] Attribute mask including the various attributes
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int resource_monitor_unset_resource_attr(int id, int resource_id, u_int64_t attr_mask);
+
+/**
+ * @brief Check whether a resouce attribute is supported or not
+ * @param[in] Resource monitor id
+ * @param[in] Resource id
+ * @param[in] Resource attribute id
+ * @return @c 0 on success, otherwise a negative error value
+ */
+bool resource_monitor_is_resource_attr_supported(int id, int resource_id, u_int64_t attr_id);
+
+/**
+ * @brief Update value of the interested attributes for all created resource
+ * @param[in] Resource monitor id
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int resource_monitor_update(int id);
+
+/**
+ * @brief Update value of the interested attributes for a resource
+ * @param[in] Resource monitor id
+ * @param[in] Resource id
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int resource_monitor_update_resource(int id, int resource_id);
+
+/**
+ * @brief Get [int/int64/uint/uint64/double/string] value of resource attribute
+ * @param[in] Resource monitor id
+ * @param[in] Resource id
+ * @param[in] Resource attribute id
+ * @param[out] Value retrieved from resource attribute
+ * @return @ 0 on success, otherwise a negative error value
+ */
+int resource_monitor_get_value_int(int id, int resource_id, u_int64_t attr, int32_t *value);
+int resource_monitor_get_value_int64(int id, int resource_id, u_int64_t attr, int64_t *value);
+int resource_monitor_get_value_uint(int id, int resource_id, u_int64_t attr, u_int32_t *value);
+int resource_monitor_get_value_uint64(int id, int resource_id, u_int64_t attr, u_int64_t *value);
+int resource_monitor_get_value_double(int id, int resource_id, u_int64_t attr, double *value);
+int resource_monitor_get_value_string(int id, int resource_id, u_int64_t attr, char *value);
+
+/**
+ * @brief Get [int/int64/uint/uint64/double/string] array of resource attribute
+ * @param[in] Resource monitor id
+ * @param[in] Resource id
+ * @param[in] Resource attribute id
+ * @param[out] Array retrieved from resource attribute
+ * @param[out] Length of array
+ * @return @ 0 on success, otherwise a negative error value
+ */
+int resource_monitor_get_array_int(int id, int res_id, u_int64_t attr, int32_t **array, int *length);
+int resource_monitor_get_array_int64(int id, int res_id, u_int64_t attr, int64_t **array, int *length);
+int resource_monitor_get_array_uint(int id, int res_id, u_int64_t attr, u_int32_t **array, int *length);
+int resource_monitor_get_array_uint64(int id, int res_id, u_int64_t attr, u_int64_t **array, int *length);
+int resource_monitor_get_array_double(int id, int res_id, u_int64_t attr, double **array, int *length);
+int resource_monitor_get_array_string(int id, int res_id, u_int64_t attr, char ***array, int *length);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __resource_SYSTEM_RESOURCE_MONITOR_H__ */
diff --git a/packaging/capi-system-resource-monitor.changes b/packaging/capi-system-resource-monitor.changes
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/packaging/capi-system-resource-monitor.manifest b/packaging/capi-system-resource-monitor.manifest
new file mode 100644 (file)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/packaging/capi-system-resource-monitor.spec b/packaging/capi-system-resource-monitor.spec
new file mode 100644 (file)
index 0000000..8a14072
--- /dev/null
@@ -0,0 +1,95 @@
+Name:           capi-system-resource-monitor
+Summary:        An Resource Monitor library in Tizen Native API
+Version:        0.0.1
+Release:        0
+Group:          System/API
+License:        Apache-2.0
+Source0:        %{name}-%{version}.tar.gz
+Source1001:     capi-system-resource-monitor.manifest
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(capi-system-info)
+BuildRequires:  pkgconfig(libpass)
+
+%description
+An Resource Monitor library in Tizen Native API
+
+%package devel
+Summary:  An Resource Monitor library in Tizen Native API (Development)
+Group:    System / Kernel
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+An Resource Monitor library in Tizen Native API (Development)
+
+%if 0%{?gcov:1}
+%package gcov
+Summary: Line Coverage files
+Group: Development/System
+
+%description gcov
+Collection of files related to line coverage using gcov.
+%endif
+
+%package tool
+Summary:  An Resource Monitor library in Tizen Native API (Tool)
+Group:    System / Kernel
+Requires: %{name} = %{version}-%{release}
+
+%description tool
+An Resource Monitor library in Tizen Native API (Tool)
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
+
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
+
+make %{?jobs:-j%jobs}
+
+%if 0%{?gcov:1}
+mkdir -p gcov-obj
+find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
+%endif
+
+%install
+%make_install
+
+%if 0%{?gcov:1}
+mkdir -p %{buildroot}%{_datadir}/gcov/obj/%{name}
+install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name}
+%endif
+
+%post
+/sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%{_libdir}/libcapi-system-resource-monitor.so.*
+
+%files devel
+%manifest %{name}.manifest
+%{_includedir}/system/resource-monitor.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/libcapi-system-resource-monitor.so
+
+%files tool
+%manifest %{name}.manifest
+%{_prefix}/bin/resource-monitor-test
+
+%if 0%{?gcov:1}
+%files gcov
+%{_datadir}/gcov/obj/*
+%endif
diff --git a/src/resouce-monitor.c b/src/resouce-monitor.c
new file mode 100644 (file)
index 0000000..52efe46
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+* Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <dlog.h>
+#include "resource-monitor.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_RESOURCE_MONITOR"
+
+int resource_monitor_init(void)
+{
+       return tmonitor_init();
+}
+
+int resource_monitor_exit(int id)
+{
+       return tmonitor_exit(id);
+}
+
+int resource_monitor_get_resource_count(int id, int resource_type)
+{
+       return tmonitor_get_resource_count(id, resource_type);
+}
+
+int resource_monitor_create_resource(int id, int resource_type)
+{
+       return tmonitor_create_resource(id, resource_type);
+}
+
+int resource_monitor_delete_resource(int id, int resource_id)
+{
+       return tmonitor_delete_resource(id, resource_id);
+}
+
+int resource_monitor_set_resource_ctrl(int id, int resource_id, u_int64_t ctrl_id, int value)
+{
+       return tmonitor_set_resource_ctrl(id, resource_id, ctrl_id, value);
+}
+
+int resource_monitor_set_resource_attr(int id, int resource_id, u_int64_t attr_mask)
+{
+       return tmonitor_set_resource_attr(id, resource_id, attr_mask);
+}
+
+int resource_monitor_unset_resource_attr(int id, int resource_id, u_int64_t attr_mask)
+{
+       return tmonitor_unset_resource_attr(id, resource_id, attr_mask);
+}
+
+bool resource_monitor_is_resource_attr_supported(int id, int resource_id, u_int64_t attr_id)
+{
+       return tmonitor_is_resource_attr_supported(id, resource_id, attr_id);
+}
+
+int resource_monitor_update(int id)
+{
+       return tmonitor_update(id);
+}
+
+int resource_monitor_update_resource(int id, int resource_id)
+{
+       return resource_monitor_update_resource(id, resource_id);
+}
+
+int resource_monitor_get_value_int(int id, int resource_id, u_int64_t attr, int32_t *value)
+{
+       return tmonitor_get_value_int(id, resource_id, attr, value);
+}
+
+int resource_monitor_get_value_int64(int id, int resource_id, u_int64_t attr, int64_t *value)
+{
+       return tmonitor_get_value_int64(id, resource_id, attr, value);
+}
+
+int resource_monitor_get_value_uint(int id, int resource_id, u_int64_t attr, u_int32_t *value)
+{
+       return tmonitor_get_value_uint(id, resource_id, attr, value);
+}
+
+int resource_monitor_get_value_uint64(int id, int resource_id, u_int64_t attr, u_int64_t *value)
+{
+       return tmonitor_get_value_uint64(id, resource_id, attr, value);
+}
+
+int resource_monitor_get_value_double(int id, int resource_id, u_int64_t attr, double *value)
+{
+       return tmonitor_get_value_double(id, resource_id, attr, value);
+}
+
+int resource_monitor_get_value_string(int id, int resource_id, u_int64_t attr, char *value)
+{
+       return tmonitor_get_value_string(id, resource_id, attr, value);
+}
+
+int resource_monitor_get_array_int(int id, int res_id, u_int64_t attr, int32_t **array, int *length)
+{
+       return tmonitor_get_array_int(id, res_id, attr, array, length);
+}
+
+int resource_monitor_get_array_int64(int id, int res_id, u_int64_t attr, int64_t **array, int *length)
+{
+       return tmonitor_get_array_int64(id, res_id, attr, array, length);
+}
+
+int resource_monitor_get_array_uint(int id, int res_id, u_int64_t attr, u_int32_t **array, int *length)
+{
+       return tmonitor_get_array_uint(id, res_id, attr, array, length);
+}
+
+int resource_monitor_get_array_uint64(int id, int res_id, u_int64_t attr, u_int64_t **array, int *length)
+{
+       return tmonitor_get_array_uint64(id, res_id, attr, array, length);
+}
+
+int resource_monitor_get_array_double(int id, int res_id, u_int64_t attr, double **array, int *length)
+{
+       return tmonitor_get_array_double(id, res_id, attr, array, length);
+}
+
+int resource_monitor_get_array_string(int id, int res_id, u_int64_t attr, char ***array, int *length)
+{
+       return tmonitor_get_array_string(id, res_id, attr, array, length);
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4d57019
--- /dev/null
@@ -0,0 +1,21 @@
+SET(fw_test "${fw_name}-test")
+
+INCLUDE(FindPkgConfig)
+FOREACH(flag ${${fw_test}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE -fPIC")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+    GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+    MESSAGE("${src_name}")
+    ADD_EXECUTABLE(${src_name} ${src})
+    TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS} -lm -pthread)
+ENDFOREACH()
+
+INSTALL(TARGETS resource-monitor-test DESTINATION bin)
diff --git a/test/resource-monitor-test.c b/test/resource-monitor-test.c
new file mode 100644 (file)
index 0000000..32e9acf
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <stdio.h>
+#include "../include/resource-monitor.h"
+
+int main(int argc, char **argv)
+{
+       /* TODO */
+
+       return 0;
+}