From d887503095926eadfefefdc07fcedaff51e4f07d Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Tue, 18 Dec 2012 13:38:40 -0800 Subject: [PATCH] Camera2: Tests: Release streams after HAL is unloaded: DO NOT MERGE This fixes a segfault in the HAL where it was trying to write to a locked buffer that disappeared from underneath it. Any users of CameraModuleFixture should now call SetUp/TearDown explicitly. Other classes remain unchanged until we need a custom TearDown order for them. Change-Id: Ia2dc3ac3e2497d9ede9b580f6e10cf9ec646bdab --- tests/camera2/CameraModuleFixture.h | 8 ++------ tests/camera2/CameraModuleTests.cpp | 9 +++++++++ tests/camera2/CameraStreamFixture.h | 9 +++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/camera2/CameraModuleFixture.h b/tests/camera2/CameraModuleFixture.h index 6ad1ae8b..cd8ddc4d 100644 --- a/tests/camera2/CameraModuleFixture.h +++ b/tests/camera2/CameraModuleFixture.h @@ -37,14 +37,10 @@ struct CameraModuleFixture { TEST_EXTENSION_FORKING_CONSTRUCTOR; mCameraID = CameraID; - - SetUp(); } ~CameraModuleFixture() { TEST_EXTENSION_FORKING_DESTRUCTOR; - - TearDown(); } camera_metadata_ro_entry GetStaticEntry(uint32_t tag) const { @@ -53,8 +49,6 @@ struct CameraModuleFixture { return entry; } -private: - void SetUp() { TEST_EXTENSION_FORKING_SET_UP; @@ -88,6 +82,8 @@ private: } } +private: + void SetUpMixin() { /* For using this fixture in other tests only */ if (mCameraID != -1) { diff --git a/tests/camera2/CameraModuleTests.cpp b/tests/camera2/CameraModuleTests.cpp index 5e856982..b5b88fc4 100644 --- a/tests/camera2/CameraModuleTests.cpp +++ b/tests/camera2/CameraModuleTests.cpp @@ -33,6 +33,15 @@ namespace tests { class CameraModuleTest : public ::testing::Test, public CameraModuleFixture<> { + +public: + CameraModuleTest() { + CameraModuleFixture::SetUp(); + } + + ~CameraModuleTest() { + CameraModuleFixture::TearDown(); + } }; TEST_F(CameraModuleTest, LoadModule) { diff --git a/tests/camera2/CameraStreamFixture.h b/tests/camera2/CameraStreamFixture.h index 7a6fa31a..569b9d1d 100644 --- a/tests/camera2/CameraStreamFixture.h +++ b/tests/camera2/CameraStreamFixture.h @@ -68,6 +68,8 @@ private: void SetUp() { TEST_EXTENSION_FORKING_SET_UP; + CameraModuleFixture::SetUp(); + CameraStreamParams p = mParam; sp device = mDevice; @@ -89,6 +91,13 @@ private: } void TearDown() { TEST_EXTENSION_FORKING_TEAR_DOWN; + + // important: shut down HAL before releasing streams + CameraModuleFixture::TearDown(); + + mNativeWindow.clear(); + mCpuConsumer.clear(); + mFrameListener.clear(); } protected: