ADD_DEFINITIONS("-DLIBPATH=\"${LIB_INSTALL_DIR}\"")
ADD_DEFINITIONS("-DSYSTEM_INFO_DB_RO_PATH=\"${DB_RO_PATH}\"")
ADD_DEFINITIONS("-DSYSTEM_INFO_DB_RW_PATH=\"${DB_RW_PATH}\"")
+ADD_DEFINITIONS("-DPLUGIN_DIR=\"${PLUGIN_DIR}\"")
ADD_DEFINITIONS(-D_GNU_SOURCE) # to make scandirat() available
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
%define model_config_rw_dir /opt/system/model-config
%define db_rw_path %{model_config_rw_dir}/system_info_db
+%define plugin_dir %{_libdir}
+
%build
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-DTIZEN_ID_PATH=%{tizen_id_path} \
-DDB_RO_PATH=%{db_ro_path} \
-DDB_RW_PATH=%{db_rw_path} \
+ -DPLUGIN_DIR=%{plugin_dir} \
-DGCOV=%{?gcov:1}%{!?gcov:0}
%__make %{?_smp_mflags}
#define BUF_MAX 256
-#define EXTERNAL_PLUGINS_DIR "/usr/lib/libsystem_info_plugins"
-#define EXTERNAL_SYSTEM_INFO "/usr/lib/libsystem-info-external-plugin.so"
+#define EXTERNAL_PLUGINS_DIR PLUGIN_DIR"/libsystem_info_plugins"
+#define EXTERNAL_SYSTEM_INFO PLUGIN_DIR"/libsystem-info-external-plugin.so"
//LCOV_EXCL_START
static int plugin_filter(const struct dirent *de)
ADD_DEPENDENCIES(${SYSTEM_INFO_TEST} ${fw_name})
TARGET_LINK_LIBRARIES(${SYSTEM_INFO_TEST} ${SYSTEM_INFO_TEST_pkgs_LDFLAGS} "-L${CMAKE_SOURCE_DIR} -lcapi-system-info")
+SET(TEST_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/system_info_external_plugin_test.sh)
+CONFIGURE_FILE(${TEST_SCRIPT}.in ${TEST_SCRIPT} @ONLY)
+
INSTALL(TARGETS ${SYSTEM_INFO_TEST} DESTINATION bin)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/test/system_info_external_plugin_test.sh DESTINATION bin)
+INSTALL(FILES ${TEST_SCRIPT} DESTINATION bin)
+++ /dev/null
-#!/bin/bash
-
-function test_key_type_string_cmd() {
- cmd_result="$(system_info_test -g custom -t string -k sysinfotest_ks)"
- name="'$FUNCNAME'"
-}
-
-function test_string_not_int_cmd() {
- cmd_result="$(system_info_test -g custom -t int -k sysinfotest_ks)"
- name="'$FUNCNAME'"
-}
-
-function test_string_not_double_cmd() {
- cmd_result="$(system_info_test -g custom -t double -k sysinfotest_ks)"
- name="'$FUNCNAME'"
-}
-
-function test_string_not_bool_cmd() {
- cmd_result="$(system_info_test -g custom -t bool -k sysinfotest_ks)"
- name="'$FUNCNAME'"
-}
-
-function test_key_type_int_cmd() {
- cmd_result="$(system_info_test -g custom -t int -k sysinfotest_ki)"
- name="'$FUNCNAME'"
-}
-
-function test_key_type_double_cmd() {
- cmd_result="$(system_info_test -g custom -t double -k sysinfotest_kd)"
- name="'$FUNCNAME'"
-}
-
-function test_key_type_bool_cmd() {
- cmd_result="$(system_info_test -g custom -t bool -k sysinfotest_kb)"
- name="'$FUNCNAME'"
-}
-
-function test_bool_not_string_cmd() {
- cmd_result="$(system_info_test -g custom -t string -k sysinfotest_kb)"
- name="'$FUNCNAME'"
-}
-
-function test_bool_not_int_cmd() {
- cmd_result="$(system_info_test -g custom -t int -k sysinfotest_kb)"
- name="'$FUNCNAME'"
-}
-
-function test_bool_not_double_cmd() {
- cmd_result="$(system_info_test -g custom -t double -k sysinfotest_kb)"
- name="'$FUNCNAME'"
-}
-
-function test_second_plugin_str_cmd() {
- cmd_result="$(system_info_test -g custom -t string -k sysinfotest_vks_custom)"
- name="'$FUNCNAME'"
-}
-
-function test_right_plugin_str_cmd() {
- cmd_result="$(system_info_test -g custom -t string -k sysinfotest_kvs)"
- name="'$FUNCNAME'"
-}
-
-function get_cmd_result() {
- check_result="$(echo $1 | cut -d'(' -f6 | cut -d')' -f1)"
-}
-
-function check_file_exists() {
- cmd_result="$(test -s $1 && echo 'exists' || echo 'not')"
- name="'$FUNCNAME' $1"
-}
-
-function check_command_exists() {
- command_exists="$(type -p system_info_test)"
-}
-
-function check_result() {
- local test_cmd=$1
- local expected_result=$2
-
- $test_cmd
- get_cmd_result "$cmd_result"
-
- #check if a variable is a number (formating cmd output)
- re='^[+-]?[0-9]+([.][0-9]+)?$'
- if [[ $check_result =~ $re ]] ; then
- check_result="$(printf '%.2f' $check_result)"
- if [[ $expected_result =~ $re ]] ; then
- expected_result="$(printf '%.2f' $expected_result)"
- fi
- fi
-
- sign='='
- nsign='!'
- if [[ $# -ge 3 && $3 == '!' ]]; then
- nsign=$sign
- sign=$3
- fi
- if [[ $check_result == '' ]]; then
- check_result='EMPTY_RESULT'
- fi
- if [[ ( $check_result != 'EMPTY_RESULT' && ( $sign == '!' && "$check_result" != "$expected_result" ) || ( "$check_result" == "$expected_result" ) ) ]]; then
- echo -e '\033[32m[' ' OK ' ']\e[0m' "$name:\t" "$sign('$expected_result')"
- else
- echo -e '\033[31m[' 'FAIL' ']\e[0m' "$name:\t" "('\033[31m$check_result\e[0m'" "$nsign=" "'\033[32m$expected_result\e[0m')"
- return_code=1
- fi
-}
-
-check_command_exists result
-if [ -z "$command_exists" ]; then
- exit 1
-fi
-
-return_code=0
-
-PLUGIN_FILE='/usr/lib/libsystem_info_plugins/libsystem_info_test_plugin.so'
-check_result "check_file_exists $PLUGIN_FILE" 'exists'
-PLUGIN_FILE='/usr/lib/libsystem_info_plugins/libsystem_info_test_plugin2.so'
-check_result "check_file_exists $PLUGIN_FILE" 'exists'
-
-check_result test_key_type_string_cmd 'plugin'
-check_result test_string_not_int_cmd 'ERROR : -22'
-check_result test_string_not_double_cmd 'ERROR : -22'
-check_result test_string_not_bool_cmd 'ERROR : -22'
-check_result test_key_type_int_cmd '1'
-check_result test_key_type_double_cmd '2.0'
-check_result test_key_type_bool_cmd '1'
-check_result test_bool_not_string_cmd 'ERROR : -22'
-check_result test_bool_not_int_cmd 'ERROR : -22'
-check_result test_bool_not_double_cmd 'ERROR : -22'
-check_result test_second_plugin_str_cmd 'various key'
-check_result test_right_plugin_str_cmd 'first_in_lexicographical_order'
-check_result test_right_plugin_str_cmd 'second_in_lexicographical_order' '!'
-check_result test_right_plugin_str_cmd 'ERROR : -22' '!'
-
-exit $return_code
--- /dev/null
+#!/bin/bash
+
+function test_key_type_string_cmd() {
+ cmd_result="$(system_info_test -g custom -t string -k sysinfotest_ks)"
+ name="'$FUNCNAME'"
+}
+
+function test_string_not_int_cmd() {
+ cmd_result="$(system_info_test -g custom -t int -k sysinfotest_ks)"
+ name="'$FUNCNAME'"
+}
+
+function test_string_not_double_cmd() {
+ cmd_result="$(system_info_test -g custom -t double -k sysinfotest_ks)"
+ name="'$FUNCNAME'"
+}
+
+function test_string_not_bool_cmd() {
+ cmd_result="$(system_info_test -g custom -t bool -k sysinfotest_ks)"
+ name="'$FUNCNAME'"
+}
+
+function test_key_type_int_cmd() {
+ cmd_result="$(system_info_test -g custom -t int -k sysinfotest_ki)"
+ name="'$FUNCNAME'"
+}
+
+function test_key_type_double_cmd() {
+ cmd_result="$(system_info_test -g custom -t double -k sysinfotest_kd)"
+ name="'$FUNCNAME'"
+}
+
+function test_key_type_bool_cmd() {
+ cmd_result="$(system_info_test -g custom -t bool -k sysinfotest_kb)"
+ name="'$FUNCNAME'"
+}
+
+function test_bool_not_string_cmd() {
+ cmd_result="$(system_info_test -g custom -t string -k sysinfotest_kb)"
+ name="'$FUNCNAME'"
+}
+
+function test_bool_not_int_cmd() {
+ cmd_result="$(system_info_test -g custom -t int -k sysinfotest_kb)"
+ name="'$FUNCNAME'"
+}
+
+function test_bool_not_double_cmd() {
+ cmd_result="$(system_info_test -g custom -t double -k sysinfotest_kb)"
+ name="'$FUNCNAME'"
+}
+
+function test_second_plugin_str_cmd() {
+ cmd_result="$(system_info_test -g custom -t string -k sysinfotest_vks_custom)"
+ name="'$FUNCNAME'"
+}
+
+function test_right_plugin_str_cmd() {
+ cmd_result="$(system_info_test -g custom -t string -k sysinfotest_kvs)"
+ name="'$FUNCNAME'"
+}
+
+function get_cmd_result() {
+ check_result="$(echo $1 | cut -d'(' -f6 | cut -d')' -f1)"
+}
+
+function check_file_exists() {
+ cmd_result="$(test -s $1 && echo 'exists' || echo 'not')"
+ name="'$FUNCNAME' $1"
+}
+
+function check_command_exists() {
+ command_exists="$(type -p system_info_test)"
+}
+
+function check_result() {
+ local test_cmd=$1
+ local expected_result=$2
+
+ $test_cmd
+ get_cmd_result "$cmd_result"
+
+ #check if a variable is a number (formating cmd output)
+ re='^[+-]?[0-9]+([.][0-9]+)?$'
+ if [[ $check_result =~ $re ]] ; then
+ check_result="$(printf '%.2f' $check_result)"
+ if [[ $expected_result =~ $re ]] ; then
+ expected_result="$(printf '%.2f' $expected_result)"
+ fi
+ fi
+
+ sign='='
+ nsign='!'
+ if [[ $# -ge 3 && $3 == '!' ]]; then
+ nsign=$sign
+ sign=$3
+ fi
+ if [[ $check_result == '' ]]; then
+ check_result='EMPTY_RESULT'
+ fi
+ if [[ ( $check_result != 'EMPTY_RESULT' && ( $sign == '!' && "$check_result" != "$expected_result" ) || ( "$check_result" == "$expected_result" ) ) ]]; then
+ echo -e '\033[32m[' ' OK ' ']\e[0m' "$name:\t" "$sign('$expected_result')"
+ else
+ echo -e '\033[31m[' 'FAIL' ']\e[0m' "$name:\t" "('\033[31m$check_result\e[0m'" "$nsign=" "'\033[32m$expected_result\e[0m')"
+ return_code=1
+ fi
+}
+
+check_command_exists result
+if [ -z "$command_exists" ]; then
+ exit 1
+fi
+
+return_code=0
+
+PLUGIN_FILE='@PLUGIN_DIR@/libsystem_info_plugins/libsystem_info_test_plugin.so'
+check_result "check_file_exists $PLUGIN_FILE" 'exists'
+PLUGIN_FILE='@PLUGIN_DIR@/libsystem_info_plugins/libsystem_info_test_plugin2.so'
+check_result "check_file_exists $PLUGIN_FILE" 'exists'
+
+check_result test_key_type_string_cmd 'plugin'
+check_result test_string_not_int_cmd 'ERROR : -22'
+check_result test_string_not_double_cmd 'ERROR : -22'
+check_result test_string_not_bool_cmd 'ERROR : -22'
+check_result test_key_type_int_cmd '1'
+check_result test_key_type_double_cmd '2.0'
+check_result test_key_type_bool_cmd '1'
+check_result test_bool_not_string_cmd 'ERROR : -22'
+check_result test_bool_not_int_cmd 'ERROR : -22'
+check_result test_bool_not_double_cmd 'ERROR : -22'
+check_result test_second_plugin_str_cmd 'various key'
+check_result test_right_plugin_str_cmd 'first_in_lexicographical_order'
+check_result test_right_plugin_str_cmd 'second_in_lexicographical_order' '!'
+check_result test_right_plugin_str_cmd 'ERROR : -22' '!'
+
+exit $return_code