haltest: add test for board 87/254987/5
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 11 Mar 2021 06:11:07 +0000 (15:11 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 15 Mar 2021 04:59:05 +0000 (04:59 +0000)
Change-Id: I5397e82b32ed9f2c745aadfc11221523791d59cc
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
haltest/CMakeLists.txt
haltest/board.cpp [new file with mode: 0644]
haltest/haltest.h

index 34a4cf0..7fddc66 100644 (file)
@@ -35,7 +35,8 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 
 SET(src ${CMAKE_SOURCE_DIR}/haltest/main.cpp
        ${CMAKE_SOURCE_DIR}/haltest/display.cpp
-       ${CMAKE_SOURCE_DIR}/haltest/battery.cpp)
+       ${CMAKE_SOURCE_DIR}/haltest/battery.cpp
+       ${CMAKE_SOURCE_DIR}/haltest/board.cpp)
 ADD_EXECUTABLE(${PROJECT_NAME} ${src})
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl ${HALAPI_LIBRARY})
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/hal)
diff --git a/haltest/board.cpp b/haltest/board.cpp
new file mode 100644 (file)
index 0000000..356c2c0
--- /dev/null
@@ -0,0 +1,44 @@
+#include "haltest.h"
+#include "hal-board.h"
+
+class BOARD : public testing::Test {
+       protected:
+               void SetUp() override {}
+
+               void TearDown() override {}
+};
+
+TEST_F(BOARD, GetBackendP)
+{
+       int ret_val;
+
+       ret_val = hal_device_board_get_backend();
+       EXPECT_EQ(ret_val, 0) << "Failed to get board device (" << ret_val << ")";
+}
+
+TEST_F(BOARD, GetDeviceSerialP)
+{
+       int ret_val;
+       char *serial = nullptr;
+
+       ret_val = hal_device_board_get_device_serial(&serial);
+       EXPECT_EQ(ret_val, 0) << "Failed to get device serial (" << ret_val << ")";
+       EXPECT_NE(serial, nullptr) << "Failed to get device serial (nullptr)";
+
+       if (ret_val == 0 && serial)
+               DEBUG_MESSAGE("Serial=%s", serial);
+
+       free(serial);
+}
+
+TEST_F(BOARD, GetDeviceRevisionP)
+{
+       int ret_val;
+       int revision;
+
+       ret_val = hal_device_board_get_device_revision(&revision);
+       EXPECT_EQ(ret_val, 0) << "Failed to get device revision (" << ret_val << ")";
+
+       if (ret_val == 0)
+               DEBUG_MESSAGE("Revision=%d", revision);
+}
index 8576f55..32a3d4d 100644 (file)
@@ -34,13 +34,20 @@ namespace testing
        }
 }
 
-#define SKIP_MESSAGE(args...) \
+#define SKIP_MESSAGE(fmt, args...) \
 do { \
        testing::internal::ColoredPrintf(testing::internal::COLOR_YELLOW, "[  SKIPPED ] "); \
-       testing::internal::ColoredPrintf(testing::internal::COLOR_YELLOW, ##args); \
+       testing::internal::ColoredPrintf(testing::internal::COLOR_YELLOW, fmt, ##args); \
        testing::internal::ColoredPrintf(testing::internal::COLOR_YELLOW, "\n"); \
 } while (0)
 
+#define DEBUG_MESSAGE(fmt, args...) \
+do { \
+       testing::internal::ColoredPrintf(testing::internal::COLOR_GREEN, "[    DEBUG ] "); \
+       testing::internal::ColoredPrintf(testing::internal::COLOR_DEFAULT, fmt, ##args); \
+       testing::internal::ColoredPrintf(testing::internal::COLOR_DEFAULT, "\n"); \
+} while (0)
+
 #define FEATURE_BATTERY     "http://tizen.org/feature/battery"
 #define FEATURE_DISPLAY     "http://tizen.org/feature/display"
 #define FEATURE_LED         "http://tizen.org/feature/led"
@@ -48,5 +55,4 @@ do { \
 #define FEATURE_THERMISTOR  "http://tizen.org/feature/thermistor.ap"
 #define FEATURE_BEZEL       "http://tizen.org/feature/input.rotating_bezel"
 
-
 #endif /* __HALTEST_H__ */