From 7f71927ae4fba79a761f8c6f8e0b65d20039883b Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 20 Feb 2018 19:42:22 +0900 Subject: [PATCH] utest: add BufmgrBoLockType testcase Change-Id: I2e799a461c42ca423398dcd47b917e17eb796ec5 --- utests/ut.cpp | 19 +++++++++++++++++++ utests/ut.h | 13 +++++++++++++ utests/ut_tbm_bufmgr.cpp | 6 +++--- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/utests/ut.cpp b/utests/ut.cpp index a52ce6e..ad64b50 100644 --- a/utests/ut.cpp +++ b/utests/ut.cpp @@ -56,6 +56,25 @@ void BufmgrBoTest::TearDown() tbm_bufmgr_deinit(bufmgr); } +void BufmgrBoLockTypeTest::UtBufmgrInit() +{ + ut_set_default_tbm_env(); + + bufmgr = tbm_bufmgr_init(-1); + ASSERT_TRUE(bufmgr != NULL); +} + +void BufmgrBoLockTypeTest::SetUp() +{ + bufmgr = NULL; +} + +void BufmgrBoLockTypeTest::TearDown() +{ + if (bufmgr) + tbm_bufmgr_deinit(bufmgr); +} + void ut_set_default_tbm_env() { setenv("XDG_RUNTIME_DIR", "/run", 1); diff --git a/utests/ut.h b/utests/ut.h index 58f4b2d..af5f644 100644 --- a/utests/ut.h +++ b/utests/ut.h @@ -47,6 +47,19 @@ public: int bo_flags; }; +/* The test fixture class, which deinitializes bufmgr after the test is finished. +To init bufmgr you need to call UtBufmgrInit() func. Do not call tbm_bufmgr_init() +directly because deinitialization won't be called if test is failed */ +class BufmgrBoLockTypeTest : public ::testing::Test +{ +protected: + void SetUp(); + void TearDown(); +public: + void UtBufmgrInit(); + tbm_bufmgr bufmgr; +}; + void ut_set_default_tbm_env(); /* test fixture class, which initializes bufmgr and allocate the tbm surface before the tests and diff --git a/utests/ut_tbm_bufmgr.cpp b/utests/ut_tbm_bufmgr.cpp index fde1bf0..ea6af98 100644 --- a/utests/ut_tbm_bufmgr.cpp +++ b/utests/ut_tbm_bufmgr.cpp @@ -586,7 +586,7 @@ TEST_F(BufmgrTest, BoLockedFailNoValidBo) ASSERT_EQ(ret, 0); } -TEST_F(UtInit, BoLockedOnce) +TEST_F(BufmgrBoLockTypeTest, BoLockedOnce) { tbm_bo_handle bo_handle1, bo_handle2; tbm_bo bo; @@ -613,7 +613,7 @@ TEST_F(UtInit, BoLockedOnce) ASSERT_EQ(ret_locked, 0); } -TEST_F(UtInit, BoLockedAlways) +TEST_F(BufmgrBoLockTypeTest, BoLockedAlways) { tbm_bo_handle bo_handle1, bo_handle2; tbm_bo bo; @@ -640,7 +640,7 @@ TEST_F(UtInit, BoLockedAlways) ASSERT_EQ(ret_locked, 1); } -TEST_F(UtInit, BoLockedNone) +TEST_F(BufmgrBoLockTypeTest, BoLockedNone) { tbm_bo_handle bo_handle1; tbm_bo bo; -- 2.7.4