aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>2021-04-15 10:48:30 +0000
committerNaoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>2021-04-15 10:48:30 +0000
commitb3e72c7944a738fe9201c406332cbcd878df65e3 (patch)
tree0d7c76f916859893832b0c9ed24650ac06bf3acf
Initial commit for AGL cluster api library
This source code is AGL instrument cluster common API library. Currently, this source code is missing author information, license and other. Will be add by author. Author: Nozomu Abe (nozo_abe@nippon-seiki.co.jp) Committed by Naoto Yamaguchi. Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt36
-rw-r--r--Readme.md138
-rw-r--r--cluster_api.pc.in11
-rw-r--r--include/cluster_api.h22
-rw-r--r--include/cluster_api_registernotify.h10
-rw-r--r--include/cluster_api_shiftposition.h37
-rw-r--r--include/cluster_api_speed.h13
-rw-r--r--include/cluster_api_tacho.h6
-rw-r--r--include/cluster_api_telltale.h94
-rw-r--r--include/cluster_api_tripcomputer.h50
-rw-r--r--src/CMakeLists.txt46
-rw-r--r--src/cluster_api.c605
-rw-r--r--src/cluster_api_internal.h50
-rw-r--r--test/client_test/CMakeLists.txt41
-rw-r--r--test/client_test/client_main.c47
-rw-r--r--test/client_test/client_test_common.c101
-rw-r--r--test/client_test/client_test_common.h24
-rw-r--r--test/client_test/client_test_init_term.c69
-rw-r--r--test/client_test/client_test_register_notify.c480
-rw-r--r--test/client_test/client_test_shiftposition.c31
-rw-r--r--test/client_test/client_test_speed.c32
-rw-r--r--test/client_test/client_test_suites.h13
-rw-r--r--test/client_test/client_test_tacho.c30
-rw-r--r--test/client_test/client_test_telltale.c132
-rw-r--r--test/client_test/client_test_tripcomputer.c68
-rw-r--r--test/client_test/dummy_server.c176
27 files changed, 2364 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ac53bc8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+build*
+cmakeBuild
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..0f4faed
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,36 @@
+project(cluster_api C)
+
+cmake_minimum_required(VERSION 2.8)
+
+set(CLUSTER_API_LIBRARY_VERSION "1.0.0")
+
+# Name of library API
+set(TARGET_NAME cluster_api)
+
+find_package(PkgConfig)
+
+# Build option for DEBUG
+option(DEBUG_BUILD "This is debug build." OFF)
+
+# set gcc flags
+set(CMAKE_C_FLAGS "-Wall -O2")
+
+if(DEBUG_BUILD)
+ add_definitions(-DDEBUG)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
+ set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/installdir/usr CACHE PATH "..." FORCE)
+endif()
+
+include(GNUInstallDirs)
+
+# Subdirectories
+add_subdirectory(src)
+if(DEBUG_BUILD)
+ add_subdirectory(test/client_test)
+endif()
+
+configure_file(cluster_api.pc.in cluster_api.pc @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cluster_api.pc
+ DESTINATION
+ ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+
diff --git a/Readme.md b/Readme.md
new file mode 100644
index 0000000..f83891a
--- /dev/null
+++ b/Readme.md
@@ -0,0 +1,138 @@
+# IC service Cluster API
+
+## Overview
+
+This repository has 3 main elements:
+
+* Cluster API library code: ./src ./include
+* Test app for client: ./test/client_test
+
+## How to build
+
+```bash
+# ipc library is required by cluster_api, so please check ipc library and headers are installed in the system.
+$ ./buildtest.sh
+```
+
+## How to run
+
+* For client_test
+
+```bash
+$ ./buildtest.sh -d
+$ cd cmakeBuild/test/client_test
+$ ./client_test
+
+
+ CUnit - A Unit testing framework for C - Version 2.1-2
+ http://cunit.sourceforge.net/
+
+
+***************** CUNIT CONSOLE - MAIN MENU ******************************
+(R)un (S)elect (L)ist (A)ctivate (F)ailures (O)ptions (H)elp (Q)uit
+Enter command: ★rを入力すると全テスト自動実行。 ★q入力で終了
+```
+
+# ソース構成
+
+- cluster_api/
+ - include/
+ - 外部公開ヘッダ一式
+ - src/
+ - cluster_apiライブラリ実装ソース
+ - test/
+ - client_test/
+ - Cluster APIテスト環境実装ソース
+
+# 生成物構成
+
+以下、./buildtest.sh を実行した場合の生成物を示す。
+
+- cluster_api/
+ - cmakeBuild/
+ - src/
+ - 以下、Cluster APIのライブラリ
+ ```bash
+ libcluster_api.so -> libcluster_api.so.1
+ libcluster_api.so.1 -> libcluster_api.so.1.0.0
+ libcluster_api.so.1.0.0
+ ```
+ - test/
+ - client_test/
+ - Cluster APIテスト実行ファイル
+ ```bash
+ client_test
+ dummy_server
+ ```
+
+# Cluster API実装内容
+
+- アプリ向けのI/FとなるAPI関数は IC-Service_API_rev0.4.docx の通りに実装した。
+- 主な実装処理は、IC-Service用サーバから送信されたデータを管理しておき、アプリからAPIが呼ばれたら、管理しているデータから該当データだけを取り出すこと。
+- IC-Service_API_rev0.4.docx に加え、以下の2つのAPIを追加実装した。
+ - bool clusterInit(void)
+ - Cluster APIを使用するための初期化処理。
+ - このAPIによりIC-Service用のサーバと接続するので、サーバが起動済みであることが前提。
+ - 処理成功時をtrueとしたbool値を返す。
+ - bool clusterTerm(void)
+ - Cluster API終了処理。
+ - IC-Service用サーバとの接続を切断するために使用。
+ - 処理成功時をtrueとしたbool値を返す。
+- アプリはcluster_api.hをincludeし、libcluster_api.soとリンクすることで、各種APIを呼び出すことが可能となる。
+
+# client_test テスト内容
+
+Cluster APIの各種APIに対する動作テストを実施する。構成は以下の通り。
+
+- テストは実行ファイルclient_testとdummy_serverの2つで構成される。
+ - client_test : Cluster APIテスト本体
+ - dummy_server : Cluster APIテストに使用する疑似IC-Serviceサーバ
+- テスト実行時はclient_testだけ実行すれば良い。
+- dummy_serverはclient_test内から自動で起動される。
+- dummy_serverの起動待ち、dummy_serverからの送信待ちについては10msecとしている。
+ (別プロセスで非同期であることから、全く待ちがないと意図通りに動作しない)
+- client_testはCUnitを用いて実装した自動テストプログラムである。CUnitの仕様通り全項目テスト、単体項目テスト、いずれも可能である。
+- ※プロセス間通信のタイミングの関係上、稀にテストがFAILすることがある。
+(テスト全156項目を20周繰り返して1項目FAILする程度)
+
+実施するテスト項目については以下の通り。
+
+1. InitAndTerm (5項目)
+ - clusterInit()とclusterTerm()が意図通り動作することを確認する。
+ - IC-Service用サーバが存在する状態でclusterInit()とclusterTerm()を順に呼ぶ時の動作を確認する(正常系)
+ - APIの呼び出し順誤りでエラーになることを確認する。
+ - clusterInit()2連続呼び出し。
+ - clusterInit()後、clusterTerm()を2連続呼び出し。
+ - clusterInit()を呼ばずにclusterTerm()を呼び出し。
+ - IC-Service用サーバが存在しない状態でのclusterInit()呼び出しでエラーになることを確認する。
+2. Telltale (52項目)
+ - IC-Service_API_rev0.4.docx の 3-4 Telltale に記載されている各種APIで意図通りの値が取得できることを確認する。
+ - 各API 1パターンずつ実施。
+3. ShiftPosition (2項目)
+ - IC-Service_API_rev0.4.docx の 3-5 ShiftPosition に記載されている各種APIで意図通りの値が取得できることを確認する。
+ - 各API 1パターンずつ実施。
+4. Speed (2項目)
+ - IC-Service_API_rev0.4.docx の 3-6 Speed に記載されている各種APIで意図通りの値が取得できることを確認する。
+ - 各API 1パターンずつ実施。
+5. Tacho (1項目)
+ - IC-Service_API_rev0.4.docx の 3-7 Tacho に記載されている各種APIで意図通りの値が取得できることを確認する。
+ - 各API 1パターンずつ実施。
+6. TripComputer (20項目)
+ - IC-Service_API_rev0.4.docx の 3-8 TripComputer に記載されている各種APIで意図通りの値が取得できることを確認する。
+ - 各API 1パターンずつ実施。
+7. RegisterAndNotify (74項目)
+ - IC-Service_API_rev0.4.docx の 3-9 Register/Notify にある registerIcHmi()の動作が意図通りであることを確認する。
+ - 第1引数 arg_1 に IC_HMI_TT_ALL を指定した時のテスト。
+ - 3-2-1 TellTaleに記載された34種のどのシグナルが変化してもコールバック関数が呼ばれることを確認する。
+ - 3-2-1 TellTaleに記載された34種いずれのシグナルも変化していなければコールバック関数が呼ばれないことを確認する。
+ - 3-2-1 TellTaleに記載された34種のシグナル以外が変化してもコールバック関数が呼ばれないことを確認する。
+ - 第1引数 arg_1 に 0 を指定した場合に、3-2-1 TellTaleに記載された34種のどのシグナルが変化してもコールバック関数が呼ばれないことを確認する。
+ - 第1引数 arg_1 に 3-2-1-1~3-2-1-34 に示されたフラグ以外全てをセットした場合に、3-2-1 TellTaleに記載された34種のどのシグナルが変化してもコールバック関数が呼ばれないことを確認する。
+ - 第2引数 addr にNULLが指定された場合にエラーとなることを確認する。
+ - 第1引数 arg_1 に 3-2-1-1~3-2-1-34 のいずれか1つをセットした値を指定した場合について以下の2つを実施する。
+ - 指定したフラグに該当するシグナルが変化した時だけコールバック関数が呼ばれることを確認する。
+ - 他の33種のシグナルが変化してもコールバック関数が呼ばれないことを確認する。
+ - 第1引数 arg_1 に 3-2-1-1~3-2-1-34 のいずれか1つのフラグだけクリアした値を指定した場合について以下の2つを実施する。
+ - クリアしたフラグに該当するシグナルが変化しても、コールバック関数が呼ばれないことを確認する。
+ - 他の33種のシグナルが変化しても、誤ってクリアしたフラグに関するコールバック通知が行われないことを確認する。
+ (他のシグナル変化へのコールバック通知は行われること)
diff --git a/cluster_api.pc.in b/cluster_api.pc.in
new file mode 100644
index 0000000..d9bcf80
--- /dev/null
+++ b/cluster_api.pc.in
@@ -0,0 +1,11 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+
+Name: @TARGET_NAME@
+Description: cluster api library using ipc library
+Version: @CLUSTER_API_LIBRARY_VERSION@
+
+Requires: ipc
+Cflags: -I${includedir}
+Libs: -L${libdir} -lcluster_api \ No newline at end of file
diff --git a/include/cluster_api.h b/include/cluster_api.h
new file mode 100644
index 0000000..792495e
--- /dev/null
+++ b/include/cluster_api.h
@@ -0,0 +1,22 @@
+#ifndef CLUSTER_API_H
+#define CLUSTER_API_H
+
+typedef enum {
+ IC_HMI_OFF = 0,
+ IC_HMI_ON,
+} IC_HMI_ON_OFF;
+
+#include <cluster_api_telltale.h>
+#include <cluster_api_shiftposition.h>
+#include <cluster_api_speed.h>
+#include <cluster_api_tacho.h>
+#include <cluster_api_tripcomputer.h>
+#include <cluster_api_registernotify.h>
+
+bool clusterInit(void);
+bool clusterTerm(void);
+
+// Callback function pointer type
+typedef void (*IC_HMI_FUNC_NOTIFY_IC_HMI)(unsigned long long arg_1, IC_HMI_ON_OFF arg_2);
+
+#endif // CLUSTER_API_H
diff --git a/include/cluster_api_registernotify.h b/include/cluster_api_registernotify.h
new file mode 100644
index 0000000..6f64d8a
--- /dev/null
+++ b/include/cluster_api_registernotify.h
@@ -0,0 +1,10 @@
+#ifndef CLUSTER_API_REGISTERNOTIFY_H
+#define CLUSTER_API_REGISTERNOTIFY_H
+
+#include <stdbool.h>
+
+typedef void(* IC_HMI_FUNC_NOTIFY_IC_HMI)(unsigned long long arg_1, IC_HMI_ON_OFF arg_2);
+
+bool registerIcHmi(unsigned long long arg_1, IC_HMI_FUNC_NOTIFY_IC_HMI addr);
+
+#endif // CLUSTER_API_REGISTERNOTIFY_H
diff --git a/include/cluster_api_shiftposition.h b/include/cluster_api_shiftposition.h
new file mode 100644
index 0000000..88d5671
--- /dev/null
+++ b/include/cluster_api_shiftposition.h
@@ -0,0 +1,37 @@
+#ifndef CLUSTER_API_SHIFTPOSITION_H
+#define CLUSTER_API_SHIFTPOSITION_H
+
+typedef enum
+{
+ IC_HMI_AT_OFF = 0,
+ IC_HMI_AT_PARKING,
+ IC_HMI_AT_REVERSE,
+ IC_HMI_AT_NEUTRAL,
+ IC_HMI_AT_DRIVE,
+ IC_HMI_AT_SECOND,
+ IC_HMI_AT_LOW_GEAR,
+ IC_HMI_AT_FIRST,
+ IC_HMI_AT_MANUAL,
+ IC_HMI_AT_BRAKE,
+ IC_HMI_AT_ALL_ON,
+ IC_HMI_AT_ALL_OFF,
+ IC_HMI_AT_UNUSED,
+} IC_HMI_GEAR_AT_VAL;
+
+typedef enum
+{
+ IC_HMI_MT_OFF = 0,
+ IC_HMI_MT_FIRST,
+ IC_HMI_MT_SECOND,
+ IC_HMI_MT_THIRD,
+ IC_HMI_MT_FOURTH,
+ IC_HMI_MT_FIFTH,
+ IC_HMI_MT_SIXTH,
+ IC_HMI_MT_SEVENTH,
+ IC_HMI_MT_EIGHTTH,
+} IC_HMI_GEAR_MT_VAL;
+
+IC_HMI_GEAR_AT_VAL getGearAtVal(void);
+IC_HMI_GEAR_MT_VAL getGearMtVal(void);
+
+#endif // CLUSTER_API_SHIFTPOSITION_H
diff --git a/include/cluster_api_speed.h b/include/cluster_api_speed.h
new file mode 100644
index 0000000..164db9d
--- /dev/null
+++ b/include/cluster_api_speed.h
@@ -0,0 +1,13 @@
+#ifndef CLUSTER_API_SPEED_H
+#define CLUSTER_API_SPEED_H
+
+typedef enum
+{
+ IC_HMI_SP_KM_H = 0,
+ IC_HMI_SP_MPH = 1,
+} IC_HMI_SP_UNIT_VAL;
+
+unsigned long getSpAnalogVal(void);
+IC_HMI_SP_UNIT_VAL getSpAnaDigUnitVal(void);
+
+#endif // CLUSTER_API_SPEED_H
diff --git a/include/cluster_api_tacho.h b/include/cluster_api_tacho.h
new file mode 100644
index 0000000..38d2ddd
--- /dev/null
+++ b/include/cluster_api_tacho.h
@@ -0,0 +1,6 @@
+#ifndef CLUSTER_API_TACHO_H
+#define CLUSTER_API_TACHO_H
+
+unsigned long getTaAnalogVal(void);
+
+#endif // CLUSTER_API_TACHO_H \ No newline at end of file
diff --git a/include/cluster_api_telltale.h b/include/cluster_api_telltale.h
new file mode 100644
index 0000000..17d69d2
--- /dev/null
+++ b/include/cluster_api_telltale.h
@@ -0,0 +1,94 @@
+#ifndef CLUSTER_API_TELLTALE_H
+#define CLUSTER_API_TELLTALE_H
+
+// Signal flags
+#define IC_HMI_TT_TURN_R 0x0000000000000001ULL
+#define IC_HMI_TT_TURN_L 0x0000000000000002ULL
+#define IC_HMI_TT_BRAKE 0x0000000000000004ULL
+#define IC_HMI_TT_SEATBELT 0x0000000000000008ULL
+#define IC_HMI_TT_HIGHBEAM 0x0000000000000010ULL
+#define IC_HMI_TT_DOOR 0x0000000000000020ULL
+#define IC_HMI_TT_EPS 0x0000000000000040ULL
+#define IC_HMI_TT_SRS_AIRBAG 0x0000000000000080ULL
+#define IC_HMI_TT_ABS 0x0000000000000100ULL
+#define IC_HMI_TT_LOW_BATTERY 0x0000000000000200ULL
+#define IC_HMI_TT_OIL_PRESS 0x0000000000000400ULL
+#define IC_HMI_TT_ENGINE 0x0000000000000800ULL
+#define IC_HMI_TT_FUEL 0x0000000000001000ULL
+#define IC_HMI_TT_IMMOBI 0x0000000000002000ULL
+#define IC_HMI_TT_TM_FAIL 0x0000000000004000ULL
+#define IC_HMI_TT_ESP_ACT 0x0000000000008000ULL
+#define IC_HMI_TT_ESP_OFF 0x0000000000010000ULL
+#define IC_HMI_TT_ADAPTING_LIGHTING 0x0000000000020000ULL
+#define IC_HMI_TT_AUTO_STOP 0x0000000000040000ULL
+#define IC_HMI_TT_AUTO_STOP_FAIL 0x0000000000080000ULL
+#define IC_HMI_TT_PARKING_LIGHTS 0x0000000000100000ULL
+#define IC_HMI_TT_FRONT_FOG 0x0000000000200000ULL
+#define IC_HMI_TT_EXTERIOR_LIGHT_FAULT 0x0000000000400000ULL
+#define IC_HMI_TT_ACC_FAIL 0x0000000000800000ULL
+#define IC_HMI_TT_LDW_OFF 0x0000000001000000ULL
+#define IC_HMI_TT_HILL_DESCENT 0x0000000002000000ULL
+#define IC_HMI_TT_AUTO_HI_BEAM_GREEN 0x0000000004000000ULL
+#define IC_HMI_TT_AUTO_HI_BEAM_AMBER 0x0000000008000000ULL
+#define IC_HMI_TT_LDW_OPERATE 0x0000000010000000ULL
+#define IC_HMI_TT_GENERAL_WARN 0x0000000020000000ULL
+#define IC_HMI_TT_SPORTS_MODE 0x0000000040000000ULL
+#define IC_HMI_TT_DRIVING_POWER_MODE 0x0000000080000000ULL
+#define IC_HMI_TT_HOT_TEMP 0x0000000100000000ULL
+#define IC_HMI_TT_LOW_TEMP 0x0000000200000000ULL
+#define IC_HMI_TT_ALL 0xFFFFFFFFFFFFFFFFULL
+
+IC_HMI_ON_OFF getTurnR(void);
+IC_HMI_ON_OFF getTurnL(void);
+IC_HMI_ON_OFF getBrake(void);
+IC_HMI_ON_OFF getSeatbelt(void);
+IC_HMI_ON_OFF getFrontRightSeatbelt(void);
+IC_HMI_ON_OFF getFrontCenterSeatbelt(void);
+IC_HMI_ON_OFF getFrontLeftSeatbelt(void);
+IC_HMI_ON_OFF getMid1RightSeatbelt(void);
+IC_HMI_ON_OFF getMid1CenterSeatbelt(void);
+IC_HMI_ON_OFF getMid1LeftSeatbelt(void);
+IC_HMI_ON_OFF getMid2RightSeatbelt(void);
+IC_HMI_ON_OFF getMid2CenterSeatbelt(void);
+IC_HMI_ON_OFF getMid2LeftSeatbelt(void);
+IC_HMI_ON_OFF getRearRightSeatbelt(void);
+IC_HMI_ON_OFF getRearCenterSeatbelt(void);
+IC_HMI_ON_OFF getRearLeftSeatbelt(void);
+IC_HMI_ON_OFF getHighbeam(void);
+IC_HMI_ON_OFF getDoor(void);
+IC_HMI_ON_OFF getFrontRightDoor(void);
+IC_HMI_ON_OFF getFrontLeftDoor(void);
+IC_HMI_ON_OFF getRearRightDoor(void);
+IC_HMI_ON_OFF getRearLeftDoor(void);
+IC_HMI_ON_OFF getTrunkDoor(void);
+IC_HMI_ON_OFF getHoodDoor(void);
+IC_HMI_ON_OFF getEps(void);
+IC_HMI_ON_OFF getSrsAirbag(void);
+IC_HMI_ON_OFF getAbs(void);
+IC_HMI_ON_OFF getLowBattery(void);
+IC_HMI_ON_OFF getOilPress(void);
+IC_HMI_ON_OFF getEngine(void);
+IC_HMI_ON_OFF getFuel(void);
+IC_HMI_ON_OFF getImmobi(void);
+IC_HMI_ON_OFF getTMFail(void);
+IC_HMI_ON_OFF getEspAct(void);
+IC_HMI_ON_OFF getEspOff(void);
+IC_HMI_ON_OFF getAdaptingLighting(void);
+IC_HMI_ON_OFF getAutoStop(void);
+IC_HMI_ON_OFF getAutoStopFail(void);
+IC_HMI_ON_OFF getParkingLights(void);
+IC_HMI_ON_OFF getFrontFog(void);
+IC_HMI_ON_OFF getExteriorLightFault(void);
+IC_HMI_ON_OFF getAccFail(void);
+IC_HMI_ON_OFF getLdwOff(void);
+IC_HMI_ON_OFF getHillDescent(void);
+IC_HMI_ON_OFF getAutoHiBeamGreen(void);
+IC_HMI_ON_OFF getAutoHiBeamAmber(void);
+IC_HMI_ON_OFF getSportsMode(void);
+IC_HMI_ON_OFF getLdwOperate(void);
+IC_HMI_ON_OFF getGeneralWarn(void);
+IC_HMI_ON_OFF getDriverPowerMode(void);
+IC_HMI_ON_OFF getHotTemp(void);
+IC_HMI_ON_OFF getLowTemp(void);
+
+#endif // CLUSTER_API_TELLTALE_H
diff --git a/include/cluster_api_tripcomputer.h b/include/cluster_api_tripcomputer.h
new file mode 100644
index 0000000..7f79d39
--- /dev/null
+++ b/include/cluster_api_tripcomputer.h
@@ -0,0 +1,50 @@
+#ifndef CLUSTER_API_TRIPCOMPUTER_H
+#define CLUSTER_API_TRIPCOMPUTER_H
+
+typedef enum
+{
+ IC_HMI_TRCOM_KM = 0,
+ IC_HMI_TRCOM_MILE = 1,
+} IC_HMI_TRCOM_UNIT_VAL;
+
+typedef enum
+{
+ IC_HMI_FUEL_KM_L = 0,
+ IC_HMI_FUEL_MPG_US,
+ IC_HMI_FUEL_MPG_IG,
+ IC_HMI_FUEL_L_100KM,
+ IC_HMI_FUEL_MILE_KWH,
+ IC_HMI_FUEL_KM_KWH,
+ IC_HMI_FUEL_MILE_KG,
+ IC_HMI_FUEL_KM_KG,
+ IC_HMI_FUEL_KWH_100KM,
+} IC_HMI_FUEL_ECONOMY_UNIT_VAL;
+
+typedef enum
+{
+ IC_HMI_OTEMP_UNIT_C = 0,
+ IC_HMI_OTEMP_UNIT_K = 1,
+} IC_HMI_OTEMP_UNIT_VAL;
+
+unsigned long getTrcomTripAVal(void);
+unsigned long getTrcomTripBVal(void);
+unsigned long getTrcomOdoVal(void);
+IC_HMI_TRCOM_UNIT_VAL getTrcomUnitVal(void);
+unsigned short getAvgSpeedAVal(void);
+unsigned short getAvgSpeedBVal(void);
+unsigned short getHourAVal(void);
+unsigned short getHourBVal(void);
+unsigned char getMinuteAVal(void);
+unsigned char getMinuteBVal(void);
+unsigned char getSecondAVal(void);
+unsigned char getSecondBVal(void);
+signed short getOTempVal(void);
+IC_HMI_OTEMP_UNIT_VAL getOTempUnitVal(void);
+unsigned short getCruRangeVal(void);
+unsigned short getAvgFuelAVal(void);
+unsigned short getAvgFuelBVal(void);
+unsigned short getInsFuelAVal(void);
+unsigned short getInsFuelBVal(void);
+IC_HMI_FUEL_ECONOMY_UNIT_VAL getFuelEconomyUnitVal(void);
+
+#endif // CLUSTER_API_TRIPCOMPUTER_H
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..f6bbca1
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,46 @@
+
+# Define project Targets
+add_library(${TARGET_NAME} SHARED
+ cluster_api.c
+)
+
+pkg_check_modules(IPC REQUIRED ipc)
+
+# Include directories
+target_include_directories(${TARGET_NAME} PRIVATE
+ ./
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
+ $<BUILD_INTERFACE:${IPC_INCLUDE_DIRS}>
+ $<INSTALL_INTERFACE:/include>
+)
+
+# find thread library
+find_package(Threads REQUIRED)
+target_link_libraries(${TARGET_NAME} INTERFACE
+ Threads::Threads
+ ${IPC_LIBRARIES})
+
+set_target_properties(${TARGET_NAME}
+ PROPERTIES
+ VERSION ${CLUSTER_API_LIBRARY_VERSION}
+ SOVERSION 1
+)
+
+set(CLUSTER_API_HEADERS
+ ../include/cluster_api.h ../include/cluster_api_registernotify.h
+ ../include/cluster_api_shiftposition.h
+ ../include/cluster_api_speed.h
+ ../include/cluster_api_tacho.h
+ ../include/cluster_api_telltale.h
+ ../include/cluster_api_tripcomputer.h
+ )
+
+# make install
+install(
+ TARGETS ${TARGET_NAME}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
+)
+
+install (
+ FILES ${CLUSTER_API_HEADERS} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
+) \ No newline at end of file
diff --git a/src/cluster_api.c b/src/cluster_api.c
new file mode 100644
index 0000000..095a416
--- /dev/null
+++ b/src/cluster_api.c
@@ -0,0 +1,605 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include <ipc.h>
+
+#include <cluster_api.h>
+#include <cluster_api_internal.h>
+
+static IPC_DATA_IC_SERVICE_S gAllSigData;
+static unsigned long long gRegisteredSignals = 0x0000000000000000ULL;
+static IC_HMI_FUNC_NOTIFY_IC_HMI gNotifyIcHmiCB;
+
+static IPC_RET_E clusterClientStart(void);
+static IPC_RET_E clusterReadDataPool(void);
+static IPC_RET_E clusterRegisterCallback(void);
+static IPC_RET_E clusterClientStop(void);
+static void notifyCheck(void* pData, signed int size, int kind);
+
+// == Internal functions ==
+static IPC_RET_E clusterClientStart(void)
+{
+ IPC_RET_E ret;
+
+ ret = ipcClientStart(IPC_USAGE_TYPE_IC_SERVICE);
+ E_CHECK(ret == IPC_RET_OK, ret, end);
+
+end:
+ return ret;
+}
+
+static IPC_RET_E clusterRegisterCallback(void)
+{
+ IPC_RET_E ret;
+
+ ret = ipcRegisterCallback(IPC_USAGE_TYPE_IC_SERVICE, &notifyCheck);
+ E_CHECK(ret == IPC_RET_OK, ret, end);
+
+end:
+ return ret;
+}
+
+static void notifyCheck(void* pData, signed int size, int kind)
+{
+ IC_HMI_ON_OFF data = 0;
+
+ if (gNotifyIcHmiCB == NULL) {
+ return;
+ }
+
+ // If signal is registered, notify IC HMI
+ if (gSigTable[kind] == (gSigTable[kind] & gRegisteredSignals))
+ {
+ memcpy(&data, pData, size);
+ gNotifyIcHmiCB(gSigTable[kind], data);
+ }
+}
+
+static IPC_RET_E clusterClientStop(void)
+{
+ IPC_RET_E ret;
+
+ ret = ipcClientStop(IPC_USAGE_TYPE_IC_SERVICE);
+ E_CHECK(ret == IPC_RET_OK, ret, end);
+
+ end:
+ return ret;
+}
+
+static IPC_RET_E clusterReadDataPool()
+{
+ IPC_RET_E ret;
+ int sigDataSize = sizeof(gAllSigData);
+
+ ret = ipcReadDataPool(IPC_USAGE_TYPE_IC_SERVICE, &gAllSigData, &sigDataSize);
+ E_CHECK(ret == IPC_RET_OK, ret, end);
+ E_CHECK(sigDataSize == sizeof(gAllSigData), sigDataSize, end);
+
+ ret = IPC_RET_OK;
+
+end:
+ return ret;
+}
+
+// == API functions for apps ==
+// === Initialize/Terminate ===
+bool clusterInit(void)
+{
+ bool ret = false;
+ IPC_RET_E rc;
+
+ memset(&gAllSigData, 0x00, sizeof(gAllSigData));
+ gRegisteredSignals = 0x0000000000000000ULL;
+ gNotifyIcHmiCB = NULL;
+
+ rc = clusterClientStart();
+ E_CHECK(rc == IPC_RET_OK, rc, end);
+
+ rc = clusterRegisterCallback();
+ E_CHECK(rc == IPC_RET_OK, rc, end);
+
+ ret = true;
+end:
+ return ret;
+}
+
+bool clusterTerm(void)
+{
+ bool ret = false;
+ IPC_RET_E rc;
+
+ rc = clusterClientStop();
+ E_CHECK(rc == IPC_RET_OK, rc, end);
+
+ memset(&gAllSigData, 0x00, sizeof(gAllSigData));
+ gRegisteredSignals = 0x0000000000000000ULL;
+ gNotifyIcHmiCB = NULL;
+
+ ret = true;
+end:
+ return ret;
+}
+
+// === Register/Notify ===
+bool registerIcHmi(unsigned long long arg_1, IC_HMI_FUNC_NOTIFY_IC_HMI addr)
+{
+ if (addr == NULL) {
+ return false;
+ }
+
+ gNotifyIcHmiCB = addr;
+ gRegisteredSignals = (gRegisteredSignals | arg_1);
+
+ return true;
+}
+
+
+// === Telltale ===
+IC_HMI_ON_OFF getTurnR(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.turnR;
+}
+
+IC_HMI_ON_OFF getTurnL(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.turnL;
+}
+
+IC_HMI_ON_OFF getBrake(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.brake;
+}
+
+IC_HMI_ON_OFF getSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.seatbelt;
+}
+
+IC_HMI_ON_OFF getFrontRightSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.frontRightSeatbelt;
+}
+
+IC_HMI_ON_OFF getFrontCenterSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.frontCenterSeatbelt;
+}
+
+IC_HMI_ON_OFF getFrontLeftSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.frontLeftSeatbelt;
+}
+
+IC_HMI_ON_OFF getMid1RightSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.mid1RightSeatbelt;
+}
+
+IC_HMI_ON_OFF getMid1CenterSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.mid1CenterSeatbelt;
+}
+
+IC_HMI_ON_OFF getMid1LeftSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.mid1LeftSeatbelt;
+}
+
+IC_HMI_ON_OFF getMid2RightSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.mid2RightSeatbelt;
+}
+
+IC_HMI_ON_OFF getMid2CenterSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.mid2CenterSeatbelt;
+}
+
+IC_HMI_ON_OFF getMid2LeftSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.mid2LeftSeatbelt;
+}
+
+IC_HMI_ON_OFF getRearRightSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.rearRightSeatbelt;
+}
+
+IC_HMI_ON_OFF getRearCenterSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.rearCenterSeatbelt;
+}
+
+IC_HMI_ON_OFF getRearLeftSeatbelt(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.rearLeftSeatbelt;
+}
+
+IC_HMI_ON_OFF getHighbeam(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.highbeam;
+}
+
+IC_HMI_ON_OFF getDoor(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.door;
+}
+
+IC_HMI_ON_OFF getFrontRightDoor(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.frontRightDoor;
+}
+
+IC_HMI_ON_OFF getFrontLeftDoor(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.frontLeftDoor;
+}
+
+IC_HMI_ON_OFF getRearRightDoor(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.rearRightDoor;
+}
+
+IC_HMI_ON_OFF getRearLeftDoor(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.rearLeftDoor;
+}
+
+IC_HMI_ON_OFF getTrunkDoor(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.trunkDoor;
+}
+
+IC_HMI_ON_OFF getHoodDoor(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.hoodDoor;
+}
+
+IC_HMI_ON_OFF getEps(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.eps;
+}
+
+IC_HMI_ON_OFF getSrsAirbag(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.srsAirbag;
+}
+
+IC_HMI_ON_OFF getAbs(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.abs;
+}
+
+IC_HMI_ON_OFF getLowBattery(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.lowBattery;
+}
+
+IC_HMI_ON_OFF getOilPress(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.oilPress;
+}
+
+IC_HMI_ON_OFF getEngine(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.engine;
+}
+
+IC_HMI_ON_OFF getFuel(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.fuel;
+}
+
+IC_HMI_ON_OFF getImmobi(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.immobi;
+}
+
+IC_HMI_ON_OFF getTMFail(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.tmFail;
+}
+
+IC_HMI_ON_OFF getEspAct(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.espAct;
+}
+
+IC_HMI_ON_OFF getEspOff(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.espOff;
+}
+
+IC_HMI_ON_OFF getAdaptingLighting(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.adaptingLighting;
+}
+
+IC_HMI_ON_OFF getAutoStop(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.autoStop;
+}
+
+IC_HMI_ON_OFF getAutoStopFail(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.autoStopFail;
+}
+
+IC_HMI_ON_OFF getParkingLights(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.parkingLights;
+}
+
+IC_HMI_ON_OFF getFrontFog(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.frontFog;
+}
+
+IC_HMI_ON_OFF getExteriorLightFault(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.exteriorLightFault;
+}
+
+IC_HMI_ON_OFF getAccFail(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.accFail;
+}
+
+IC_HMI_ON_OFF getLdwOff(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.ldwOff;
+}
+
+IC_HMI_ON_OFF getHillDescent(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.hillDescent;
+}
+
+IC_HMI_ON_OFF getAutoHiBeamGreen(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.autoHiBeamGreen;
+}
+
+IC_HMI_ON_OFF getAutoHiBeamAmber(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.autoHiBeamAmber;
+}
+
+IC_HMI_ON_OFF getSportsMode(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.sportsMode;
+}
+
+IC_HMI_ON_OFF getLdwOperate(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.ldwOperate;
+}
+
+IC_HMI_ON_OFF getGeneralWarn(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.generalWarn;
+}
+
+IC_HMI_ON_OFF getDriverPowerMode(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.drivingPowerMode;
+}
+
+IC_HMI_ON_OFF getHotTemp(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.hotTemp;
+}
+
+IC_HMI_ON_OFF getLowTemp(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.lowTemp;
+}
+
+// === TripComputer ===
+unsigned long getTrcomTripAVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.trcomTripAVal;
+}
+
+unsigned long getTrcomTripBVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.trcomTripBVal;
+}
+
+unsigned long getTrcomOdoVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.trcomOdoVal;
+}
+
+IC_HMI_TRCOM_UNIT_VAL getTrcomUnitVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.trcomUnitVal;
+}
+
+unsigned short getAvgSpeedAVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.avgSpeedAVal;
+}
+
+unsigned short getAvgSpeedBVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.avgSpeedBVal;
+}
+
+unsigned short getHourAVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.hourAVal;
+}
+
+unsigned short getHourBVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.hourBVal;
+}
+
+unsigned char getMinuteAVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.minuteAVal;
+}
+
+unsigned char getMinuteBVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.minuteBVal;
+}
+
+unsigned char getSecondAVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.secondAVal;
+}
+
+unsigned char getSecondBVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.secondBVal;
+}
+
+signed short getOTempVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.oTempVal;
+}
+
+IC_HMI_OTEMP_UNIT_VAL getOTempUnitVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.oTempUnitVal;
+}
+
+unsigned short getCruRangeVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.cruRangeVal;
+}
+
+unsigned short getAvgFuelAVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.avgFuelAVal;
+}
+
+unsigned short getAvgFuelBVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.avgFuelBVal;
+}
+
+unsigned short getInsFuelAVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.insFuelAVal;
+}
+
+unsigned short getInsFuelBVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.insFuelBVal;
+}
+
+IC_HMI_FUEL_ECONOMY_UNIT_VAL getFuelEconomyUnitVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.fuelEconomyUnitVal;
+}
+
+// === ShiftPosition ===
+IC_HMI_GEAR_AT_VAL getGearAtVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.gearAtVal;
+}
+
+IC_HMI_GEAR_MT_VAL getGearMtVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.gearMtVal;
+}
+
+// === Speed ===
+unsigned long getSpAnalogVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.spAnalogVal;
+}
+
+IC_HMI_SP_UNIT_VAL getSpAnaDigUnitVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.spAnaDigUnitVal;
+}
+
+// === Tacho ===
+unsigned long getTaAnalogVal(void)
+{
+ clusterReadDataPool();
+ return gAllSigData.taAnalogVal;
+}
+
diff --git a/src/cluster_api_internal.h b/src/cluster_api_internal.h
new file mode 100644
index 0000000..da7a3c1
--- /dev/null
+++ b/src/cluster_api_internal.h
@@ -0,0 +1,50 @@
+#ifndef CLUSTER_API_INTERNAL_H
+#define CLUSTER_API_INTERNAL_H
+
+#define E_CHECK(condition, value, label) \
+ do { \
+ if (!(condition)) { \
+ printf("%s:%d ERROR:%s %s:%d\n", __func__, __LINE__, #condition, #value, (int)value); \
+ goto label; \
+ } \
+ } while(0)
+
+// Table with signal bits (defined to fit IPC_KIND_IC_SERVICE_E from ipc_protocol.h)
+const unsigned long long gSigTable[] = {
+ IC_HMI_TT_TURN_R,
+ IC_HMI_TT_TURN_L,
+ IC_HMI_TT_BRAKE,
+ IC_HMI_TT_SEATBELT,
+ IC_HMI_TT_HIGHBEAM,
+ IC_HMI_TT_DOOR,
+ IC_HMI_TT_EPS,
+ IC_HMI_TT_SRS_AIRBAG,
+ IC_HMI_TT_ABS,
+ IC_HMI_TT_LOW_BATTERY,
+ IC_HMI_TT_OIL_PRESS,
+ IC_HMI_TT_ENGINE,
+ IC_HMI_TT_FUEL,
+ IC_HMI_TT_IMMOBI,
+ IC_HMI_TT_TM_FAIL,
+ IC_HMI_TT_ESP_ACT,
+ IC_HMI_TT_ESP_OFF,
+ IC_HMI_TT_ADAPTING_LIGHTING,
+ IC_HMI_TT_AUTO_STOP,
+ IC_HMI_TT_AUTO_STOP_FAIL,
+ IC_HMI_TT_PARKING_LIGHTS,
+ IC_HMI_TT_FRONT_FOG,
+ IC_HMI_TT_EXTERIOR_LIGHT_FAULT,
+ IC_HMI_TT_ACC_FAIL,
+ IC_HMI_TT_LDW_OFF,
+ IC_HMI_TT_HILL_DESCENT,
+ IC_HMI_TT_AUTO_HI_BEAM_GREEN,
+ IC_HMI_TT_AUTO_HI_BEAM_AMBER,
+ IC_HMI_TT_LDW_OPERATE,
+ IC_HMI_TT_GENERAL_WARN,
+ IC_HMI_TT_SPORTS_MODE,
+ IC_HMI_TT_DRIVING_POWER_MODE,
+ IC_HMI_TT_HOT_TEMP,
+ IC_HMI_TT_LOW_TEMP
+};
+
+#endif // CLUSTER_API_INTERNAL_H
diff --git a/test/client_test/CMakeLists.txt b/test/client_test/CMakeLists.txt
new file mode 100644
index 0000000..940326b
--- /dev/null
+++ b/test/client_test/CMakeLists.txt
@@ -0,0 +1,41 @@
+cmake_minimum_required(VERSION 2.8)
+
+pkg_check_modules(IPC REQUIRED ipc)
+
+# use the variable <RESULTNAME>_INCLUDE_DIRS to get include paths
+include_directories(
+ ${IPC_INCLUDE_DIRS}
+ ../../include
+ )
+
+# Define project Targets
+set(CLIENT_TEST_BINARY_NAME client_test)
+add_executable(${CLIENT_TEST_BINARY_NAME}
+ client_main.c
+ client_test_common.c
+ client_test_init_term.c
+ client_test_telltale.c
+ client_test_shiftposition.c
+ client_test_speed.c
+ client_test_tacho.c
+ client_test_tripcomputer.c
+ client_test_register_notify.c
+ )
+
+# use the variable <RESULTNAME>_LIBRARIES to get library paths
+target_link_libraries(${CLIENT_TEST_BINARY_NAME}
+ ${IPC_LIBRARIES}
+ ${TARGET_NAME}
+ pthread
+ cunit
+ )
+
+# Define project Targets
+set(DUMMY_SERVER_BINARY_NAME dummy_server)
+add_executable(${DUMMY_SERVER_BINARY_NAME} dummy_server.c)
+
+target_link_libraries(${DUMMY_SERVER_BINARY_NAME}
+ ${IPC_LIBRARIES}
+ pthread
+ )
+
diff --git a/test/client_test/client_main.c b/test/client_test/client_main.c
new file mode 100644
index 0000000..aca9d55
--- /dev/null
+++ b/test/client_test/client_main.c
@@ -0,0 +1,47 @@
+// Test program for IC-service IPC inplementation
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <CUnit/CUnit.h>
+#include <CUnit/Console.h>
+
+#include <ipc.h>
+#include <cluster_api.h>
+
+#include "client_test_common.h"
+#include "client_test_suites.h"
+
+int main(int argc, char *argv[])
+{
+ pid_t child;
+
+ setenv(IPC_ENV_DOMAIN_SOCKET_PATH, IPC_TEST_DOMAIN_PATH, 1);
+
+ setExeFilePath(argv[0]);
+ if ((child = fork()) < 0) {
+ fprintf(stderr, "client_main:%d Failed to fork() : %d\n", __LINE__, child);
+ exit(EXIT_FAILURE);
+ }
+
+ startDummyServer(child);
+ connectToDummyServer();
+
+ CU_initialize_registry();
+
+ SetTestSuiteInitAndTerm();
+ SetTestSuiteTelltale();
+ SetTestSuiteShiftPosition();
+ SetTestSuiteSpeed();
+ SetTestSuiteTacho();
+ SetTestSuiteTripComputer();
+ SetTestSuiteRegisterAndNotify();
+
+ CU_console_run_tests();
+
+ CU_cleanup_registry();
+
+ stopDummyServer();
+
+ return 0;
+}
diff --git a/test/client_test/client_test_common.c b/test/client_test/client_test_common.c
new file mode 100644
index 0000000..5b71630
--- /dev/null
+++ b/test/client_test/client_test_common.c
@@ -0,0 +1,101 @@
+#include <stdio.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <cluster_api.h>
+
+#include "client_test_common.h"
+
+#define CLUSTER_TEST_WAIT_TIME (10000)
+
+static int g_dummyServerFd = -1;
+static char g_dummyServerExeFilePath[256];
+
+void setExeFilePath(const char *exeFilePath)
+{
+ char *pCh;
+
+ // dummy_server in the same path as client_test.
+ strcpy(g_dummyServerExeFilePath, exeFilePath);
+ pCh = strrchr(g_dummyServerExeFilePath, '/');
+ pCh = pCh != NULL ? pCh + 1: g_dummyServerExeFilePath;
+ strcpy(pCh, "dummy_server");
+}
+
+void startDummyServer(pid_t child)
+{
+ if (child == 0) {
+ int rc;
+ char *argv[2] = {NULL, NULL};
+
+ argv[0] = g_dummyServerExeFilePath;
+
+ rc = execv(argv[0], argv);
+ if (rc < 0) {
+ ERRNO_LOG(execv);
+ }
+ }
+ else {
+ usleep(CLUSTER_TEST_WAIT_TIME);
+ }
+}
+
+void stopDummyServer(void)
+{
+ if (g_dummyServerFd >= 0) {
+ shutdown(g_dummyServerFd, SHUT_RDWR);
+ close(g_dummyServerFd);
+ }
+ unlink(CLUSTER_TEST_SENDDATA_FILE);
+ sleep(1);
+}
+
+void connectToDummyServer(void)
+{
+ int rc;
+ int fd;
+ struct sockaddr_un unixAddr;
+ int len;
+
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ ERRNO_LOG(socket);
+ return;
+ }
+ unixAddr.sun_family = AF_UNIX;
+ strcpy(unixAddr.sun_path, CLUSTER_TEST_DOMAIN_PATH);
+ len = sizeof(unixAddr.sun_family)+strlen(unixAddr.sun_path);
+ rc = connect(fd, (struct sockaddr *)&unixAddr, len);
+ if (rc != 0) {
+ ERRNO_LOG(connect);
+ shutdown(fd, SHUT_RDWR);
+ close(fd);
+ return;
+ }
+
+ g_dummyServerFd = fd;
+}
+
+void requestSendData(IPC_DATA_IC_SERVICE_S *pSendData)
+{
+ FILE *fp = NULL;
+ int dummy = 1;
+ int size;
+
+ fp = fopen(CLUSTER_TEST_SENDDATA_FILE, "wb");
+ if (fp != NULL) {
+ size = fwrite(pSendData, 1, sizeof(IPC_DATA_IC_SERVICE_S), fp);
+ if (size < sizeof(IPC_DATA_IC_SERVICE_S)) {
+ ERRNO_LOG(fwrite);
+ }
+ fclose(fp);
+
+ size = write(g_dummyServerFd, &dummy, sizeof(dummy));
+ if (size < 0) {
+ ERRNO_LOG(write);
+ }
+ usleep(CLUSTER_TEST_WAIT_TIME);
+ }
+}
+
diff --git a/test/client_test/client_test_common.h b/test/client_test/client_test_common.h
new file mode 100644
index 0000000..36a990f
--- /dev/null
+++ b/test/client_test/client_test_common.h
@@ -0,0 +1,24 @@
+#ifndef CLIENT_TEST_COMMON_H
+#define CLIENT_TEST_COMMON_H
+
+#include <unistd.h>
+#include <ipc.h>
+
+#define IPC_TEST_DOMAIN_PATH "./"
+
+#define CLUSTER_TEST_DOMAIN_PATH "cluster_test_domain"
+#define CLUSTER_TEST_SENDDATA_FILE "cluster_test.dat"
+
+#define ERRNO_LOG(func) \
+ do { \
+ perror(#func "()"); \
+ fprintf(stderr, "%s:%d Failed to %s()\n", __FILE__, __LINE__, #func); \
+ }while(0)
+
+void setExeFilePath(const char *exeFilePath);
+void startDummyServer(pid_t child);
+void stopDummyServer(void);
+void connectToDummyServer(void);
+void requestSendData(IPC_DATA_IC_SERVICE_S *pSendData);
+
+#endif // CLIENT_TEST_COMMON_H
diff --git a/test/client_test/client_test_init_term.c b/test/client_test/client_test_init_term.c
new file mode 100644
index 0000000..00f2f13
--- /dev/null
+++ b/test/client_test/client_test_init_term.c
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <CUnit/CUnit.h>
+
+#include <cluster_api.h>
+
+#include "client_test_common.h"
+
+// OK case. Calling the APIs of Init and Term while the server is already started.
+static void TestInitAndTermOK(void)
+{
+ CU_ASSERT(clusterInit() == true);
+ CU_ASSERT(clusterTerm() == true);
+}
+
+// NG case. Call the API of Init function twice.
+static void TestInitAndTermNG1(void)
+{
+ CU_ASSERT(clusterInit() == true);
+ CU_ASSERT(clusterInit() == false);
+ CU_ASSERT(clusterTerm() == true);
+}
+
+// NG case. Call the API of Term function twice.
+static void TestInitAndTermNG2(void)
+{
+ CU_ASSERT(clusterInit() == true);
+ CU_ASSERT(clusterTerm() == true);
+ CU_ASSERT(clusterTerm() == false);
+}
+
+// NG case. Call the API of Term only.
+static void TestInitAndTermNG3(void)
+{
+ CU_ASSERT(clusterTerm() == false);
+}
+
+// NG case. Server is not ready.
+static void TestInitAndTermNG4(void)
+{
+ pid_t child;
+
+ stopDummyServer();
+ CU_ASSERT(clusterInit() == false);
+ CU_ASSERT(clusterTerm() == false);
+
+ if ((child = fork()) < 0) {
+ fprintf(stderr, "%s:%d Failed to fork() : %d\n", __FILE__, __LINE__, child);
+ exit(EXIT_FAILURE);
+ }
+
+ startDummyServer(child);
+ connectToDummyServer();
+}
+
+void SetTestSuiteInitAndTerm(void)
+{
+ CU_pSuite testSuite;
+
+ testSuite = CU_add_suite("InitAndTerm", NULL, NULL);
+ CU_add_test(testSuite, "InitAndTerm_OK", TestInitAndTermOK);
+ CU_add_test(testSuite, "InitAndTerm_NG_1", TestInitAndTermNG1);
+ CU_add_test(testSuite, "InitAndTerm_NG_2", TestInitAndTermNG2);
+ CU_add_test(testSuite, "InitAndTerm_NG_3", TestInitAndTermNG3);
+ CU_add_test(testSuite, "InitAndTerm_NG_4", TestInitAndTermNG4);
+}
+
diff --git a/test/client_test/client_test_register_notify.c b/test/client_test/client_test_register_notify.c
new file mode 100644
index 0000000..2458e73
--- /dev/null
+++ b/test/client_test/client_test_register_notify.c
@@ -0,0 +1,480 @@
+#include <string.h>
+#include <stdbool.h>
+
+#include <CUnit/CUnit.h>
+
+#include <cluster_api.h>
+
+#include "client_test_common.h"
+
+typedef struct {
+ IC_HMI_ON_OFF value;
+ bool isCallbacked;
+ const unsigned long long flag;
+ const char *name;
+} CLUSTER_TEST_CB_STORE_TABLE_S;
+
+#define CLUSTER_TEST_DECLARE_STORE_UNIT(flag) \
+ {IC_HMI_OFF, false, flag, #flag}
+
+static CLUSTER_TEST_CB_STORE_TABLE_S g_cbStoreTable[] = {
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_TURN_R),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_TURN_L),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_BRAKE),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_SEATBELT),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_HIGHBEAM),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_DOOR),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_EPS),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_SRS_AIRBAG),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_ABS),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_LOW_BATTERY),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_OIL_PRESS),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_ENGINE),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_FUEL),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_IMMOBI),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_TM_FAIL),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_ESP_ACT),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_ESP_OFF),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_ADAPTING_LIGHTING),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_AUTO_STOP),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_AUTO_STOP_FAIL),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_PARKING_LIGHTS),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_FRONT_FOG),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_EXTERIOR_LIGHT_FAULT),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_ACC_FAIL),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_LDW_OFF),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_HILL_DESCENT),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_AUTO_HI_BEAM_GREEN),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_AUTO_HI_BEAM_AMBER),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_LDW_OPERATE),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_GENERAL_WARN),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_SPORTS_MODE),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_DRIVING_POWER_MODE),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_HOT_TEMP),
+ CLUSTER_TEST_DECLARE_STORE_UNIT(IC_HMI_TT_LOW_TEMP)
+};
+
+static bool g_isCalledCallback = false;
+
+#define CLUSTER_TEST_STORE_TABLE_SIZE (sizeof(g_cbStoreTable)/sizeof(g_cbStoreTable[0]))
+
+static void cleanStoreTable(void)
+{
+ int i;
+
+ for (i = 0; i < CLUSTER_TEST_STORE_TABLE_SIZE; i++) {
+ g_cbStoreTable[i].value = 0;
+ g_cbStoreTable[i].isCallbacked = false;
+ }
+}
+
+static bool checkValueFromStoreTable(const unsigned long long flag,
+ const bool expectedIsCallbacked,
+ const IC_HMI_ON_OFF expectedOnOff)
+{
+ bool ret = true;
+ int i;
+
+ for (i = 0; i < CLUSTER_TEST_STORE_TABLE_SIZE; i++) {
+ if (flag == g_cbStoreTable[i].flag) {
+ if (g_cbStoreTable[i].isCallbacked != expectedIsCallbacked) {
+ ret = false;
+ fprintf(stderr, "%s:%d [%s] isCallbacked == %d is false\n", __FILE__, __LINE__, g_cbStoreTable[i].name, expectedIsCallbacked);
+ }
+
+ if (expectedIsCallbacked == true && g_cbStoreTable[i].value != expectedOnOff) {
+ ret = false;
+ fprintf(stderr, "%s:%d [%s] value == %d is false\n", __FILE__, __LINE__, g_cbStoreTable[i].name, expectedOnOff);
+ }
+ return ret;
+ }
+ }
+
+ return false;
+}
+
+static void sendDataAllSet(IPC_DATA_IC_SERVICE_S *pSendData, IC_HMI_ON_OFF onOff)
+{
+ pSendData->turnR = onOff;
+ pSendData->turnL = onOff;
+ pSendData->brake = onOff;
+ pSendData->seatbelt = onOff;
+ pSendData->highbeam = onOff;
+ pSendData->door = onOff;
+ pSendData->eps = onOff;
+ pSendData->srsAirbag = onOff;
+ pSendData->abs = onOff;
+ pSendData->lowBattery = onOff;
+ pSendData->oilPress = onOff;
+ pSendData->engine = onOff;
+ pSendData->fuel = onOff;
+ pSendData->immobi = onOff;
+ pSendData->tmFail = onOff;
+ pSendData->espAct = onOff;
+ pSendData->espOff = onOff;
+ pSendData->adaptingLighting = onOff;
+ pSendData->autoStop = onOff;
+ pSendData->autoStopFail = onOff;
+ pSendData->parkingLights = onOff;
+ pSendData->frontFog = onOff;
+ pSendData->exteriorLightFault = onOff;
+ pSendData->accFail = onOff;
+ pSendData->ldwOff = onOff;
+ pSendData->hillDescent = onOff;
+ pSendData->autoHiBeamGreen = onOff;
+ pSendData->autoHiBeamAmber = onOff;
+ pSendData->ldwOperate = onOff;
+ pSendData->generalWarn = onOff;
+ pSendData->sportsMode = onOff;
+ pSendData->drivingPowerMode = onOff;
+ pSendData->hotTemp = onOff;
+ pSendData->lowTemp = onOff;
+}
+
+static void notifyIcHmi(unsigned long long arg_1, IC_HMI_ON_OFF arg_2)
+{
+ int i;
+
+ g_isCalledCallback = true;
+
+ for (i = 0; i < sizeof(g_cbStoreTable) / sizeof(g_cbStoreTable[0]); i++) {
+ if ((arg_1 & g_cbStoreTable[i].flag) == g_cbStoreTable[i].flag) {
+ g_cbStoreTable[i].value = arg_2;
+ g_cbStoreTable[i].isCallbacked = true;
+ }
+ }
+}
+
+static void TestregisterIcHmi_ALL_DifferentData() {
+ unsigned long long arg_1;
+ IPC_DATA_IC_SERVICE_S sendData;
+ int i;
+
+ CU_ASSERT(clusterInit() == true);
+
+ cleanStoreTable();
+ g_isCalledCallback = false;
+
+ arg_1 = IC_HMI_TT_ALL;
+ CU_ASSERT(registerIcHmi(arg_1, notifyIcHmi) == true);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ memset(&sendData, 0x00, sizeof(sendData));
+ sendDataAllSet(&sendData, IC_HMI_ON);
+ requestSendData(&sendData);
+
+ CU_ASSERT(g_isCalledCallback == true);
+ for (i = 0; i < CLUSTER_TEST_STORE_TABLE_SIZE; i++) {
+ CU_ASSERT(checkValueFromStoreTable(g_cbStoreTable[i].flag, true, IC_HMI_ON) == true);
+ }
+
+ g_isCalledCallback = false;
+ sendDataAllSet(&sendData, IC_HMI_OFF);
+ requestSendData(&sendData);
+
+ CU_ASSERT(g_isCalledCallback == true);
+ for (i = 0; i < CLUSTER_TEST_STORE_TABLE_SIZE; i++) {
+ CU_ASSERT(checkValueFromStoreTable(g_cbStoreTable[i].flag, true, IC_HMI_OFF) == true);
+ }
+
+ CU_ASSERT(clusterTerm() == true);
+}
+
+static void TestregisterIcHmi_ALL_SameData() {
+ unsigned long long arg_1;
+ IPC_DATA_IC_SERVICE_S sendData;
+
+ CU_ASSERT(clusterInit() == true);
+
+ cleanStoreTable();
+ g_isCalledCallback = false;
+
+ arg_1 = IC_HMI_TT_ALL;
+ CU_ASSERT(registerIcHmi(arg_1, notifyIcHmi) == true);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ // Send the data "different" from initial value.
+ memset(&sendData, 0x00, sizeof(sendData));
+ sendDataAllSet(&sendData, IC_HMI_OFF);
+ requestSendData(&sendData);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ g_isCalledCallback = false;
+ sendDataAllSet(&sendData, IC_HMI_OFF);
+ requestSendData(&sendData);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ CU_ASSERT(clusterTerm() == true);
+}
+
+static void TestregisterIcHmi_NullFunc() {
+ unsigned long long arg_1;
+
+ CU_ASSERT(clusterInit() == true);
+
+ arg_1 = IC_HMI_TT_ALL;
+ CU_ASSERT(registerIcHmi(arg_1, NULL) == false);
+
+ CU_ASSERT(clusterTerm() == true);
+}
+
+static void TestregisterIcHmi_ALL_OFF() {
+ unsigned long long arg_1;
+ IPC_DATA_IC_SERVICE_S sendData;
+
+ CU_ASSERT(clusterInit() == true);
+
+ cleanStoreTable();
+ g_isCalledCallback = false;
+
+ arg_1 = 0ULL;
+ CU_ASSERT(registerIcHmi(arg_1, notifyIcHmi) == true);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ memset(&sendData, 0x00, sizeof(sendData));
+ sendDataAllSet(&sendData, IC_HMI_ON);
+ requestSendData(&sendData);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ g_isCalledCallback = false;
+ sendDataAllSet(&sendData, IC_HMI_OFF);
+ requestSendData(&sendData);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ CU_ASSERT(clusterTerm() == true);
+}
+
+static void TestregisterIcHmi_ALL_UnrelatedParams(void)
+{
+ unsigned long long arg_1;
+ IPC_DATA_IC_SERVICE_S sendData;
+
+ CU_ASSERT(clusterInit() == true);
+
+ cleanStoreTable();
+ g_isCalledCallback = false;
+
+ arg_1 = IC_HMI_TT_ALL;
+ CU_ASSERT(registerIcHmi(arg_1, notifyIcHmi) == true);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ memset(&sendData, 0x01, sizeof(sendData));
+ sendDataAllSet(&sendData, IC_HMI_OFF);
+ requestSendData(&sendData);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ g_isCalledCallback = false;
+ memset(&sendData, 0x00, sizeof(sendData));
+ sendDataAllSet(&sendData, IC_HMI_OFF);
+ requestSendData(&sendData);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ CU_ASSERT(clusterTerm() == true);
+}
+
+static void TestregisterIcHmi_Set_UnusedFlag(void)
+{
+ unsigned long long arg_1;
+ IPC_DATA_IC_SERVICE_S sendData;
+ int i;
+
+ CU_ASSERT(clusterInit() == true);
+
+ cleanStoreTable();
+ g_isCalledCallback = false;
+
+ arg_1 = IC_HMI_TT_ALL;
+ for (i = 0; i < CLUSTER_TEST_STORE_TABLE_SIZE; i++) {
+ arg_1 &= ~(g_cbStoreTable[i].flag);
+ }
+ CU_ASSERT(registerIcHmi(arg_1, notifyIcHmi) == true);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ memset(&sendData, 0x00, sizeof(sendData));
+ sendDataAllSet(&sendData, IC_HMI_ON);
+ requestSendData(&sendData);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ g_isCalledCallback = false;
+ sendDataAllSet(&sendData, IC_HMI_OFF);
+ requestSendData(&sendData);
+
+ CU_ASSERT(g_isCalledCallback == false);
+
+ CU_ASSERT(clusterTerm() == true);
+}
+
+#define REGISTER_NOTIFY_TEST_FUNC(flag, param) \
+ static void TestregisterIcHmi_ON_ ##flag(void) \
+ { \
+ unsigned long long arg_1; \
+ IPC_DATA_IC_SERVICE_S sendData; \
+ \
+ CU_ASSERT(clusterInit() == true); \
+ \
+ cleanStoreTable(); \
+ g_isCalledCallback = false; \
+ \
+ arg_1 = IC_HMI_ ##flag; \
+ CU_ASSERT(registerIcHmi(arg_1, notifyIcHmi) == true); \
+ \
+ CU_ASSERT(g_isCalledCallback == false); \
+ \
+ memset(&sendData, 0x00, sizeof(sendData)); \
+ sendDataAllSet(&sendData, IC_HMI_ON); \
+ sendData.param = IC_HMI_OFF; \
+ requestSendData(&sendData); \
+ \
+ CU_ASSERT(g_isCalledCallback == false); \
+ \
+ g_isCalledCallback = false; \
+ sendData.param = IC_HMI_ON; \
+ requestSendData(&sendData); \
+ \
+ CU_ASSERT(g_isCalledCallback == true); \
+ CU_ASSERT(checkValueFromStoreTable(IC_HMI_ ##flag, true, IC_HMI_ON) == true); \
+ \
+ g_isCalledCallback = false; \
+ sendData.param = IC_HMI_OFF; \
+ requestSendData(&sendData); \
+ \
+ CU_ASSERT(g_isCalledCallback == true); \
+ CU_ASSERT(checkValueFromStoreTable(IC_HMI_ ##flag, true, IC_HMI_OFF) == true); \
+ \
+ CU_ASSERT(clusterTerm() == true); \
+ } \
+ static void TestregisterIcHmi_OFF_ ##flag(void) \
+ { \
+ unsigned long long arg_1; \
+ IPC_DATA_IC_SERVICE_S sendData; \
+ \
+ CU_ASSERT(clusterInit() == true); \
+ \
+ cleanStoreTable(); \
+ g_isCalledCallback = false; \
+ \
+ arg_1 = IC_HMI_TT_ALL & ~IC_HMI_ ##flag; \
+ CU_ASSERT(registerIcHmi(arg_1, notifyIcHmi) == true); \
+ \
+ CU_ASSERT(g_isCalledCallback == false); \
+ \
+ memset(&sendData, 0x00, sizeof(sendData)); \
+ sendDataAllSet(&sendData, IC_HMI_OFF); \
+ sendData.param = IC_HMI_ON; \
+ requestSendData(&sendData); \
+ \
+ CU_ASSERT(g_isCalledCallback == false); \
+ \
+ g_isCalledCallback = false; \
+ sendData.param = IC_HMI_OFF; \
+ requestSendData(&sendData); \
+ \
+ CU_ASSERT(g_isCalledCallback == false); \
+ \
+ g_isCalledCallback = false; \
+ sendDataAllSet(&sendData, IC_HMI_ON); \
+ requestSendData(&sendData); \
+ \
+ CU_ASSERT(g_isCalledCallback == true); \
+ CU_ASSERT(checkValueFromStoreTable(IC_HMI_ ##flag, false, IC_HMI_OFF) == true); \
+ \
+ CU_ASSERT(clusterTerm() == true); \
+ }
+
+#define REGISTER_NOTIFY_ADD_TEST(testSuite, flag) \
+ CU_add_test(testSuite, "registerIcHmi_ON_" #flag, TestregisterIcHmi_ON_ ##flag); \
+ CU_add_test(testSuite, "registerIcHmi_OFF_" #flag, TestregisterIcHmi_OFF_ ##flag)
+
+REGISTER_NOTIFY_TEST_FUNC(TT_TURN_R, turnR)
+REGISTER_NOTIFY_TEST_FUNC(TT_TURN_L, turnL)
+REGISTER_NOTIFY_TEST_FUNC(TT_BRAKE, brake)
+REGISTER_NOTIFY_TEST_FUNC(TT_SEATBELT, seatbelt)
+REGISTER_NOTIFY_TEST_FUNC(TT_HIGHBEAM, highbeam)
+REGISTER_NOTIFY_TEST_FUNC(TT_DOOR, door)
+REGISTER_NOTIFY_TEST_FUNC(TT_EPS, eps)
+REGISTER_NOTIFY_TEST_FUNC(TT_SRS_AIRBAG, srsAirbag)
+REGISTER_NOTIFY_TEST_FUNC(TT_ABS, abs)
+REGISTER_NOTIFY_TEST_FUNC(TT_LOW_BATTERY, lowBattery)
+REGISTER_NOTIFY_TEST_FUNC(TT_OIL_PRESS, oilPress)
+REGISTER_NOTIFY_TEST_FUNC(TT_ENGINE, engine)
+REGISTER_NOTIFY_TEST_FUNC(TT_FUEL, fuel)
+REGISTER_NOTIFY_TEST_FUNC(TT_IMMOBI, immobi)
+REGISTER_NOTIFY_TEST_FUNC(TT_TM_FAIL, tmFail)
+REGISTER_NOTIFY_TEST_FUNC(TT_ESP_ACT, espAct)
+REGISTER_NOTIFY_TEST_FUNC(TT_ESP_OFF, espOff)
+REGISTER_NOTIFY_TEST_FUNC(TT_ADAPTING_LIGHTING, adaptingLighting)
+REGISTER_NOTIFY_TEST_FUNC(TT_AUTO_STOP, autoStop)
+REGISTER_NOTIFY_TEST_FUNC(TT_AUTO_STOP_FAIL, autoStopFail)
+REGISTER_NOTIFY_TEST_FUNC(TT_PARKING_LIGHTS, parkingLights)
+REGISTER_NOTIFY_TEST_FUNC(TT_FRONT_FOG, frontFog)
+REGISTER_NOTIFY_TEST_FUNC(TT_EXTERIOR_LIGHT_FAULT, exteriorLightFault)
+REGISTER_NOTIFY_TEST_FUNC(TT_ACC_FAIL, accFail)
+REGISTER_NOTIFY_TEST_FUNC(TT_LDW_OFF, ldwOff)
+REGISTER_NOTIFY_TEST_FUNC(TT_HILL_DESCENT, hillDescent)
+REGISTER_NOTIFY_TEST_FUNC(TT_AUTO_HI_BEAM_GREEN, autoHiBeamGreen)
+REGISTER_NOTIFY_TEST_FUNC(TT_AUTO_HI_BEAM_AMBER, autoHiBeamAmber)
+REGISTER_NOTIFY_TEST_FUNC(TT_LDW_OPERATE, ldwOperate)
+REGISTER_NOTIFY_TEST_FUNC(TT_GENERAL_WARN, generalWarn)
+REGISTER_NOTIFY_TEST_FUNC(TT_SPORTS_MODE, sportsMode)
+REGISTER_NOTIFY_TEST_FUNC(TT_DRIVING_POWER_MODE, drivingPowerMode)
+REGISTER_NOTIFY_TEST_FUNC(TT_HOT_TEMP, hotTemp)
+REGISTER_NOTIFY_TEST_FUNC(TT_LOW_TEMP, lowTemp)
+
+void SetTestSuiteRegisterAndNotify(void)
+{
+ CU_pSuite testSuite;
+
+ testSuite = CU_add_suite("RegisterAndNotify", NULL, NULL);
+ CU_add_test(testSuite, "registerIcHmi_ALL_DifferentData", TestregisterIcHmi_ALL_DifferentData);
+ CU_add_test(testSuite, "registerIcHmi_ALL_SameData", TestregisterIcHmi_ALL_SameData);
+ CU_add_test(testSuite, "registerIcHmi_ALL_UnrelatedParams", TestregisterIcHmi_ALL_UnrelatedParams);
+ CU_add_test(testSuite, "registerIcHmi_ALL_OFF", TestregisterIcHmi_ALL_OFF);
+ CU_add_test(testSuite, "registerIcHmi_Set_UnusedFlag", TestregisterIcHmi_Set_UnusedFlag);
+ CU_add_test(testSuite, "registerIcHmi_NullFunc", TestregisterIcHmi_NullFunc);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_TURN_R);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_TURN_L);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_BRAKE);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_SEATBELT);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_HIGHBEAM);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_DOOR);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_EPS);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_SRS_AIRBAG);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_ABS);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_LOW_BATTERY);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_OIL_PRESS);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_ENGINE);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_FUEL);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_IMMOBI);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_TM_FAIL);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_ESP_ACT);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_ESP_OFF);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_ADAPTING_LIGHTING);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_AUTO_STOP);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_AUTO_STOP_FAIL);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_PARKING_LIGHTS);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_FRONT_FOG);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_EXTERIOR_LIGHT_FAULT);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_ACC_FAIL);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_LDW_OFF);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_HILL_DESCENT);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_AUTO_HI_BEAM_GREEN);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_AUTO_HI_BEAM_AMBER);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_LDW_OPERATE);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_GENERAL_WARN);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_SPORTS_MODE);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_DRIVING_POWER_MODE);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_HOT_TEMP);
+ REGISTER_NOTIFY_ADD_TEST(testSuite, TT_LOW_TEMP);
+}
diff --git a/test/client_test/client_test_shiftposition.c b/test/client_test/client_test_shiftposition.c
new file mode 100644
index 0000000..ead199c
--- /dev/null
+++ b/test/client_test/client_test_shiftposition.c
@@ -0,0 +1,31 @@
+#include <CUnit/CUnit.h>
+
+#include <cluster_api.h>
+
+#include "client_test_common.h"
+
+#define SHIFTPOSITION_TEST_FUNC(func, param, value) \
+ static void Test ##func() { \
+ IPC_DATA_IC_SERVICE_S sendData; \
+ CU_ASSERT(clusterInit() == true); \
+ memset(&sendData, 0x00, sizeof(sendData)); \
+ sendData.param = value; \
+ requestSendData(&sendData); \
+ CU_ASSERT(func() == value); \
+ CU_ASSERT(clusterTerm() == true); \
+ }
+
+#define SHIFTPOSITION_ADD_TEST(testSuite, func) \
+ CU_add_test(testSuite, #func, Test ##func)
+
+SHIFTPOSITION_TEST_FUNC(getGearAtVal, gearAtVal, IC_HMI_AT_UNUSED)
+SHIFTPOSITION_TEST_FUNC(getGearMtVal, gearMtVal, IC_HMI_MT_EIGHTTH)
+
+void SetTestSuiteShiftPosition(void)
+{
+ CU_pSuite testSuite;
+
+ testSuite = CU_add_suite("ShiftPosition", NULL, NULL);
+ SHIFTPOSITION_ADD_TEST(testSuite, getGearAtVal);
+ SHIFTPOSITION_ADD_TEST(testSuite, getGearMtVal);
+}
diff --git a/test/client_test/client_test_speed.c b/test/client_test/client_test_speed.c
new file mode 100644
index 0000000..c30e2e2
--- /dev/null
+++ b/test/client_test/client_test_speed.c
@@ -0,0 +1,32 @@
+#include <CUnit/CUnit.h>
+
+#include <cluster_api.h>
+
+#include "client_test_common.h"
+
+#define SPEED_TEST_FUNC(func, param, value) \
+ static void Test ##func() { \
+ IPC_DATA_IC_SERVICE_S sendData; \
+ CU_ASSERT(clusterInit() == true); \
+ memset(&sendData, 0x00, sizeof(sendData)); \
+ sendData.param = value; \
+ requestSendData(&sendData); \
+ CU_ASSERT(func() == value); \
+ CU_ASSERT(clusterTerm() == true); \
+ }
+
+#define SPEED_ADD_TEST(testSuite, func) \
+ CU_add_test(testSuite, #func, Test ##func)
+
+SPEED_TEST_FUNC(getSpAnalogVal, spAnalogVal, 0x00007530)
+SPEED_TEST_FUNC(getSpAnaDigUnitVal, spAnaDigUnitVal, IC_HMI_SP_MPH)
+
+void SetTestSuiteSpeed(void)
+{
+ CU_pSuite testSuite;
+
+ testSuite = CU_add_suite("Speed", NULL, NULL);
+ SPEED_ADD_TEST(testSuite, getSpAnalogVal);
+ SPEED_ADD_TEST(testSuite, getSpAnaDigUnitVal);
+}
+
diff --git a/test/client_test/client_test_suites.h b/test/client_test/client_test_suites.h
new file mode 100644
index 0000000..8306944
--- /dev/null
+++ b/test/client_test/client_test_suites.h
@@ -0,0 +1,13 @@
+#ifndef CLIENT_TEST_SUITES_H
+#define CLIENT_TEST_SUITES_H
+
+void SetTestSuiteInitAndTerm(void);
+void SetTestSuiteTelltale(void);
+void SetTestSuiteShiftPosition(void);
+void SetTestSuiteSpeed(void);
+void SetTestSuiteTacho(void);
+void SetTestSuiteTripComputer(void);
+void SetTestSuiteRegisterAndNotify(void);
+
+#endif // CLIENT_TEST_SUITES_H
+
diff --git a/test/client_test/client_test_tacho.c b/test/client_test/client_test_tacho.c
new file mode 100644
index 0000000..97b39e5
--- /dev/null
+++ b/test/client_test/client_test_tacho.c
@@ -0,0 +1,30 @@
+#include <CUnit/CUnit.h>
+
+#include <cluster_api.h>
+
+#include "client_test_common.h"
+
+#define TACHO_TEST_FUNC(func, param, value) \
+ static void Test ##func() { \
+ IPC_DATA_IC_SERVICE_S sendData; \
+ CU_ASSERT(clusterInit() == true); \
+ memset(&sendData, 0x00, sizeof(sendData)); \
+ sendData.param = value; \
+ requestSendData(&sendData); \
+ CU_ASSERT(func() == value); \
+ CU_ASSERT(clusterTerm() == true); \
+ }
+
+#define TACHO_ADD_TEST(testSuite, func) \
+ CU_add_test(testSuite, #func, Test ##func)
+
+TACHO_TEST_FUNC(getTaAnalogVal, taAnalogVal, 0x00004E20)
+
+void SetTestSuiteTacho(void)
+{
+ CU_pSuite testSuite;
+
+ testSuite = CU_add_suite("Tacho", NULL, NULL);
+ TACHO_ADD_TEST(testSuite, getTaAnalogVal);
+}
+
diff --git a/test/client_test/client_test_telltale.c b/test/client_test/client_test_telltale.c
new file mode 100644
index 0000000..b5dd14a
--- /dev/null
+++ b/test/client_test/client_test_telltale.c
@@ -0,0 +1,132 @@
+#include <CUnit/CUnit.h>
+
+#include <cluster_api.h>
+
+#include "client_test_common.h"
+
+#define TELLTALE_TEST_FUNC(func, param) \
+ static void Test ##func() { \
+ IPC_DATA_IC_SERVICE_S sendData; \
+ CU_ASSERT(clusterInit() == true); \
+ memset(&sendData, 0x00, sizeof(sendData)); \
+ sendData.param = IC_HMI_ON; \
+ requestSendData(&sendData); \
+ CU_ASSERT(func() == IC_HMI_ON); \
+ CU_ASSERT(clusterTerm() == true); \
+ }
+
+#define TELLTALE_ADD_TEST(testSuite, func) \
+ CU_add_test(testSuite, #func, Test ##func)
+
+TELLTALE_TEST_FUNC(getTurnR, turnR)
+TELLTALE_TEST_FUNC(getTurnL, turnL)
+TELLTALE_TEST_FUNC(getBrake, brake)
+TELLTALE_TEST_FUNC(getSeatbelt, seatbelt)
+TELLTALE_TEST_FUNC(getFrontRightSeatbelt, frontRightSeatbelt)
+TELLTALE_TEST_FUNC(getFrontCenterSeatbelt, frontCenterSeatbelt)
+TELLTALE_TEST_FUNC(getFrontLeftSeatbelt, frontLeftSeatbelt)
+TELLTALE_TEST_FUNC(getMid1RightSeatbelt, mid1RightSeatbelt)
+TELLTALE_TEST_FUNC(getMid1CenterSeatbelt, mid1CenterSeatbelt)
+TELLTALE_TEST_FUNC(getMid1LeftSeatbelt, mid1LeftSeatbelt)
+TELLTALE_TEST_FUNC(getMid2RightSeatbelt, mid2RightSeatbelt)
+TELLTALE_TEST_FUNC(getMid2CenterSeatbelt, mid2CenterSeatbelt)
+TELLTALE_TEST_FUNC(getMid2LeftSeatbelt, mid2LeftSeatbelt)
+TELLTALE_TEST_FUNC(getRearRightSeatbelt, rearRightSeatbelt)
+TELLTALE_TEST_FUNC(getRearCenterSeatbelt, rearCenterSeatbelt)
+TELLTALE_TEST_FUNC(getRearLeftSeatbelt, rearLeftSeatbelt)
+TELLTALE_TEST_FUNC(getHighbeam, highbeam)
+TELLTALE_TEST_FUNC(getDoor, door)
+TELLTALE_TEST_FUNC(getFrontRightDoor, frontRightDoor)
+TELLTALE_TEST_FUNC(getFrontLeftDoor, frontLeftDoor)
+TELLTALE_TEST_FUNC(getRearRightDoor, rearRightDoor)
+TELLTALE_TEST_FUNC(getRearLeftDoor, rearLeftDoor)
+TELLTALE_TEST_FUNC(getTrunkDoor, trunkDoor)
+TELLTALE_TEST_FUNC(getHoodDoor, hoodDoor)
+TELLTALE_TEST_FUNC(getEps, eps)
+TELLTALE_TEST_FUNC(getSrsAirbag, srsAirbag)
+TELLTALE_TEST_FUNC(getAbs, abs)
+TELLTALE_TEST_FUNC(getLowBattery, lowBattery)
+TELLTALE_TEST_FUNC(getOilPress, oilPress)
+TELLTALE_TEST_FUNC(getEngine, engine)
+TELLTALE_TEST_FUNC(getFuel, fuel)
+TELLTALE_TEST_FUNC(getImmobi, immobi)
+TELLTALE_TEST_FUNC(getTMFail, tmFail)
+TELLTALE_TEST_FUNC(getEspAct, espAct)
+TELLTALE_TEST_FUNC(getEspOff, espOff)
+TELLTALE_TEST_FUNC(getAdaptingLighting, adaptingLighting)
+TELLTALE_TEST_FUNC(getAutoStop, autoStop)
+TELLTALE_TEST_FUNC(getAutoStopFail, autoStopFail)
+TELLTALE_TEST_FUNC(getParkingLights, parkingLights)
+TELLTALE_TEST_FUNC(getFrontFog, frontFog)
+TELLTALE_TEST_FUNC(getExteriorLightFault, exteriorLightFault)
+TELLTALE_TEST_FUNC(getAccFail, accFail)
+TELLTALE_TEST_FUNC(getLdwOff, ldwOff)
+TELLTALE_TEST_FUNC(getHillDescent, hillDescent)
+TELLTALE_TEST_FUNC(getAutoHiBeamGreen, autoHiBeamGreen)
+TELLTALE_TEST_FUNC(getAutoHiBeamAmber, autoHiBeamAmber)
+TELLTALE_TEST_FUNC(getSportsMode, sportsMode)
+TELLTALE_TEST_FUNC(getLdwOperate, ldwOperate)
+TELLTALE_TEST_FUNC(getGeneralWarn, generalWarn)
+TELLTALE_TEST_FUNC(getDriverPowerMode, drivingPowerMode)
+TELLTALE_TEST_FUNC(getHotTemp, hotTemp)
+TELLTALE_TEST_FUNC(getLowTemp, lowTemp)
+
+void SetTestSuiteTelltale(void)
+{
+ CU_pSuite testSuite;
+
+ testSuite = CU_add_suite("Telltale", NULL, NULL);
+ TELLTALE_ADD_TEST(testSuite, getTurnR);
+ TELLTALE_ADD_TEST(testSuite, getTurnL);
+ TELLTALE_ADD_TEST(testSuite, getBrake);
+ TELLTALE_ADD_TEST(testSuite, getSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getFrontRightSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getFrontCenterSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getFrontLeftSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getMid1RightSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getMid1CenterSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getMid1LeftSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getMid2RightSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getMid2CenterSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getMid2LeftSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getRearRightSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getRearCenterSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getRearLeftSeatbelt);
+ TELLTALE_ADD_TEST(testSuite, getHighbeam);
+ TELLTALE_ADD_TEST(testSuite, getDoor);
+ TELLTALE_ADD_TEST(testSuite, getFrontRightDoor);
+ TELLTALE_ADD_TEST(testSuite, getFrontLeftDoor);
+ TELLTALE_ADD_TEST(testSuite, getRearRightDoor);
+ TELLTALE_ADD_TEST(testSuite, getRearLeftDoor);
+ TELLTALE_ADD_TEST(testSuite, getTrunkDoor);
+ TELLTALE_ADD_TEST(testSuite, getHoodDoor);
+ TELLTALE_ADD_TEST(testSuite, getEps);
+ TELLTALE_ADD_TEST(testSuite, getSrsAirbag);
+ TELLTALE_ADD_TEST(testSuite, getAbs);
+ TELLTALE_ADD_TEST(testSuite, getLowBattery);
+ TELLTALE_ADD_TEST(testSuite, getOilPress);
+ TELLTALE_ADD_TEST(testSuite, getEngine);
+ TELLTALE_ADD_TEST(testSuite, getFuel);
+ TELLTALE_ADD_TEST(testSuite, getImmobi);
+ TELLTALE_ADD_TEST(testSuite, getTMFail);
+ TELLTALE_ADD_TEST(testSuite, getEspAct);
+ TELLTALE_ADD_TEST(testSuite, getEspOff);
+ TELLTALE_ADD_TEST(testSuite, getAdaptingLighting);
+ TELLTALE_ADD_TEST(testSuite, getAutoStop);
+ TELLTALE_ADD_TEST(testSuite, getAutoStopFail);
+ TELLTALE_ADD_TEST(testSuite, getParkingLights);
+ TELLTALE_ADD_TEST(testSuite, getFrontFog);
+ TELLTALE_ADD_TEST(testSuite, getExteriorLightFault);
+ TELLTALE_ADD_TEST(testSuite, getAccFail);
+ TELLTALE_ADD_TEST(testSuite, getLdwOff);
+ TELLTALE_ADD_TEST(testSuite, getHillDescent);
+ TELLTALE_ADD_TEST(testSuite, getAutoHiBeamGreen);
+ TELLTALE_ADD_TEST(testSuite, getAutoHiBeamAmber);
+ TELLTALE_ADD_TEST(testSuite, getSportsMode);
+ TELLTALE_ADD_TEST(testSuite, getLdwOperate);
+ TELLTALE_ADD_TEST(testSuite, getGeneralWarn);
+ TELLTALE_ADD_TEST(testSuite, getDriverPowerMode);
+ TELLTALE_ADD_TEST(testSuite, getHotTemp);
+ TELLTALE_ADD_TEST(testSuite, getLowTemp);
+}
+
diff --git a/test/client_test/client_test_tripcomputer.c b/test/client_test/client_test_tripcomputer.c
new file mode 100644
index 0000000..a352230
--- /dev/null
+++ b/test/client_test/client_test_tripcomputer.c
@@ -0,0 +1,68 @@
+#include <CUnit/CUnit.h>
+
+#include <cluster_api.h>
+
+#include "client_test_common.h"
+
+#define TRIPCOMPUTER_TEST_FUNC(func, param, value) \
+ static void Test ##func() { \
+ IPC_DATA_IC_SERVICE_S sendData; \
+ CU_ASSERT(clusterInit() == true); \
+ memset(&sendData, 0x00, sizeof(sendData)); \
+ sendData.param = value; \
+ requestSendData(&sendData); \
+ CU_ASSERT(func() == value); \
+ CU_ASSERT(clusterTerm() == true); \
+ }
+
+#define TRIPCOMPUTER_ADD_TEST(testSuite, func) \
+ CU_add_test(testSuite, #func, Test ##func)
+
+TRIPCOMPUTER_TEST_FUNC(getTrcomTripAVal, trcomTripAVal, 0x0001869F)
+TRIPCOMPUTER_TEST_FUNC(getTrcomTripBVal, trcomTripBVal, 0x0001869F)
+TRIPCOMPUTER_TEST_FUNC(getTrcomOdoVal, trcomOdoVal, 0x000F423F)
+TRIPCOMPUTER_TEST_FUNC(getTrcomUnitVal, trcomUnitVal, IC_HMI_TRCOM_MILE)
+TRIPCOMPUTER_TEST_FUNC(getAvgSpeedAVal, avgSpeedAVal, 0x012C)
+TRIPCOMPUTER_TEST_FUNC(getAvgSpeedBVal, avgSpeedBVal, 0x012C)
+TRIPCOMPUTER_TEST_FUNC(getHourAVal, hourAVal, 0x03E7)
+TRIPCOMPUTER_TEST_FUNC(getHourBVal, hourBVal, 0x03E7)
+TRIPCOMPUTER_TEST_FUNC(getMinuteAVal, minuteAVal, 0x3B)
+TRIPCOMPUTER_TEST_FUNC(getMinuteBVal, minuteBVal, 0x3B)
+TRIPCOMPUTER_TEST_FUNC(getSecondAVal, secondAVal, 0x3B)
+TRIPCOMPUTER_TEST_FUNC(getSecondBVal, secondBVal, 0x3B)
+TRIPCOMPUTER_TEST_FUNC(getOTempVal, oTempVal, (signed short)0xFFD8)
+TRIPCOMPUTER_TEST_FUNC(getOTempUnitVal, oTempUnitVal, IC_HMI_OTEMP_UNIT_K)
+TRIPCOMPUTER_TEST_FUNC(getCruRangeVal, cruRangeVal, 0x064A)
+TRIPCOMPUTER_TEST_FUNC(getAvgFuelAVal, avgFuelAVal, 0x07CF)
+TRIPCOMPUTER_TEST_FUNC(getAvgFuelBVal, avgFuelBVal, 0x07CF)
+TRIPCOMPUTER_TEST_FUNC(getInsFuelAVal, insFuelAVal, 0x07CF)
+TRIPCOMPUTER_TEST_FUNC(getInsFuelBVal, insFuelBVal, 0x07CF)
+TRIPCOMPUTER_TEST_FUNC(getFuelEconomyUnitVal, fuelEconomyUnitVal, IC_HMI_FUEL_KWH_100KM)
+
+void SetTestSuiteTripComputer(void)
+{
+ CU_pSuite testSuite;
+
+ testSuite = CU_add_suite("TripComputer", NULL, NULL);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getTrcomTripAVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getTrcomTripBVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getTrcomOdoVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getTrcomUnitVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getAvgSpeedAVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getAvgSpeedBVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getHourAVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getHourBVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getMinuteAVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getMinuteBVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getSecondAVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getSecondBVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getOTempVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getOTempUnitVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getCruRangeVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getAvgFuelAVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getAvgFuelBVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getInsFuelAVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getInsFuelBVal);
+ TRIPCOMPUTER_ADD_TEST(testSuite, getFuelEconomyUnitVal);
+}
+
diff --git a/test/client_test/dummy_server.c b/test/client_test/dummy_server.c
new file mode 100644
index 0000000..987552a
--- /dev/null
+++ b/test/client_test/dummy_server.c
@@ -0,0 +1,176 @@
+#include "client_test_common.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/epoll.h>
+
+#include <ipc.h>
+
+#define CLUSTER_TEST_EPOLL_WAIT_NUM (2)
+
+int createEpoll(int waitNum)
+{
+ int fd = -1;
+
+ fd = epoll_create(waitNum);
+ if (fd < 0) {
+ ERRNO_LOG(epoll_create);
+ return -1;
+ }
+
+ return fd;
+}
+
+int createSocket(int epollFd, int *pOutTestFd)
+{
+ int rc;
+ int fd = -1;
+ int testFd = -1;
+ struct sockaddr_un unixAddr;
+ int len;
+ struct epoll_event epollEv;
+
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ ERRNO_LOG(socket);
+ return -1;
+ }
+
+ unixAddr.sun_family = AF_UNIX;
+ strcpy(unixAddr.sun_path, CLUSTER_TEST_DOMAIN_PATH);
+ len = sizeof(unixAddr.sun_family)+strlen(unixAddr.sun_path);
+ rc = bind(fd, (struct sockaddr *)&unixAddr, len);
+ if (rc < 0) {
+ ERRNO_LOG(bind);
+ goto err;
+ }
+
+ rc = listen(fd, 1);
+ if (rc < 0) {
+ ERRNO_LOG(listen);
+ goto err;
+ }
+
+ testFd = accept(fd, (struct sockaddr*)&unixAddr, (socklen_t *)&len);
+ if (testFd < 0) {
+ ERRNO_LOG(accept);
+ goto err;
+ }
+
+ memset(&epollEv, 0, sizeof(epollEv));
+ epollEv.events = EPOLLIN;
+ epollEv.data.fd = fd;
+ epoll_ctl(epollFd, EPOLL_CTL_ADD, epollEv.data.fd, &epollEv);
+
+ epollEv.events = EPOLLIN | EPOLLRDHUP;
+ epollEv.data.fd = testFd;
+ epoll_ctl(epollFd, EPOLL_CTL_ADD, epollEv.data.fd, &epollEv);
+
+ *pOutTestFd = testFd;
+
+ return fd;
+err:
+ shutdown(fd, SHUT_RDWR);
+ close(fd);
+ unlink(CLUSTER_TEST_DOMAIN_PATH);
+ return -1;
+}
+
+void sendMessageLoop(void)
+{
+ int epollFd = -1;
+ int socketFd = -1;
+ int testFd = -1;
+ int fdNum;
+ int i;
+ struct epoll_event epEvents[CLUSTER_TEST_EPOLL_WAIT_NUM];
+ bool isRunning = true;
+ int dummyData;
+ FILE *fp;
+ IPC_DATA_IC_SERVICE_S sendData;
+ IPC_RET_E rc;
+ int size;
+
+ epollFd = createEpoll(CLUSTER_TEST_EPOLL_WAIT_NUM);
+ if (epollFd < 0) {
+ goto end;
+ }
+
+ socketFd = createSocket(epollFd, &testFd);
+ if (socketFd < 0) {
+ goto end;
+ }
+
+ while(isRunning == true) {
+ fdNum = epoll_wait(epollFd, epEvents, CLUSTER_TEST_EPOLL_WAIT_NUM, -1);
+
+ for (i = 0; i < fdNum; i++) {
+ if (epEvents[i].events & EPOLLRDHUP) {
+ isRunning = false;
+ break;
+ }
+ else if (epEvents[i].events & EPOLLIN) {
+ size = read(epEvents[i].data.fd, &dummyData, sizeof(dummyData));
+ if (size < 0) {
+ ERRNO_LOG(read);
+ }
+ fp = fopen(CLUSTER_TEST_SENDDATA_FILE, "rb");
+ if (fp != NULL) {
+ size = fread(&sendData, 1, sizeof(sendData), fp);
+ if (size < sizeof(sendData) && ferror(fp)) {
+ ERRNO_LOG(fread);
+ }
+ fclose(fp);
+ rc = ipcSendMessage(IPC_USAGE_TYPE_IC_SERVICE, &sendData, sizeof(sendData));
+ if (rc != IPC_RET_OK) {
+ fprintf(stderr, "dummy_server:%d Failed to ipcSendMessage() : %d\n", __LINE__, rc);
+ }
+ }
+ }
+ }
+ }
+
+end:
+ if (testFd >= 0) {
+ shutdown(testFd, SHUT_RDWR);
+ close(testFd);
+ }
+
+ if (socketFd >= 0) {
+ shutdown(socketFd, SHUT_RDWR);
+ close(socketFd);
+ unlink(CLUSTER_TEST_DOMAIN_PATH);
+ }
+
+ if (epollFd >= 0) {
+ close(epollFd);
+ }
+}
+
+int main(void)
+{
+ IPC_RET_E ret;
+
+ setenv(IPC_ENV_DOMAIN_SOCKET_PATH, IPC_TEST_DOMAIN_PATH, 1);
+
+ ret = ipcServerStart(IPC_USAGE_TYPE_IC_SERVICE);
+ if (ret != IPC_RET_OK) {
+ fprintf(stderr, "dummy_server:%d Failed to ipcServerStart() : %d\n", __LINE__, ret);
+ exit(EXIT_FAILURE);
+ }
+
+ sendMessageLoop();
+
+ ret = ipcServerStop(IPC_USAGE_TYPE_IC_SERVICE);
+ if (ret != IPC_RET_OK) {
+ fprintf(stderr, "dummy_server:%d Failed to ipcServerStop() : %d\n", __LINE__, ret);
+ exit(EXIT_FAILURE);
+ }
+
+ return 0;
+}
+