#include "sensor-haltest.h" #include "hal-sensor.h" #define CHECK_NODEV(ret_val) \ if (ret_val == -ENODEV) { \ SKIP_MESSAGE("Not supported HAL."); \ return ; \ } class SENSOR_API : public testing::Test { protected: static void SetUpHalTestSuite() { } void SetUp() override { } void TearDown() override {} }; TEST_F(SENSOR_API, GetBackendP) { SKIP_NO_FEATURE(); int ret_val; ret_val = hal_sensor_get_backend(); EXPECT_EQ(ret_val, 0) << strerr("Failed to get sensor device", ret_val); } TEST_F(SENSOR_API, CreateP) { SKIP_NO_FEATURE(); int ret_val; void **devices; ret_val = hal_sensor_create(&devices); if (ret_val == -ENODEV) { SKIP_MESSAGE("Not supported HAL"); return; } ASSERT_GT(ret_val, 0) << strerr("Failed to call create", ret_val); ASSERT_NE(devices[0], nullptr) << "Opened devices are invalid."; } int main(int argc, char **argv) { int ret = -1; try { testing::InitGoogleTest(&argc, argv); } catch(...) { std::cout << "Exception occurred." << std::endl; } try { ret = RUN_ALL_TESTS(); } catch (const ::testing::internal::GoogleTestFailureException& e) { ret = -1; std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl; } return ret; }