From 21b426d2da17f0442110d833238fc24a82af18c2 Mon Sep 17 00:00:00 2001 From: "tommi@webrtc.org" Date: Fri, 16 Nov 2012 09:37:08 +0000 Subject: [PATCH] Revert 3111 (revert of a revert). The trybots are succeeding and the modified code shouldn't affect the test that failed so I suspect it was a fluke. If this fails, I'll revert my revert so that we can revert while we revert. --- Revert 3105 - Don't crash the unit test host when tests fail. Instead, just report the error, fail, and move on. TEST=Run vie_auto_test, option=1. On my machine most of the tests fail for some reason that I'm still investigating, but the tests shouldn't be crashing the process which is what I'm fixing here. Review URL: https://webrtc-codereview.appspot.com/929019 TBR=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/936026 TBR=mikhal@webrtc.org Review URL: https://webrtc-codereview.appspot.com/966021 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3115 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../primitives/general_primitives.cc | 22 ++++++++++--------- .../auto_test/source/vie_autotest_base.cc | 6 ++++- .../auto_test/source/vie_autotest_capture.cc | 14 +++++++----- .../libvietest/testbed/tb_capture_device.cc | 3 ++- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc b/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc index 86d4b648a..fda0abdf3 100644 --- a/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc +++ b/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc @@ -36,17 +36,19 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture, *device_video = webrtc::VideoCaptureFactory::Create(4571, unique_id); EXPECT_TRUE(*device_video != NULL); - (*device_video)->AddRef(); + if (*device_video) { + (*device_video)->AddRef(); - int error = capture->AllocateCaptureDevice(**device_video, *device_id); - if (error == 0) { - ViETest::Log("Using capture device: %s, captureId: %d.", - device_name, *device_id); - capture_device_set = true; - break; - } else { - (*device_video)->Release(); - (*device_video) = NULL; + int error = capture->AllocateCaptureDevice(**device_video, *device_id); + if (error == 0) { + ViETest::Log("Using capture device: %s, captureId: %d.", + device_name, *device_id); + capture_device_set = true; + break; + } else { + (*device_video)->Release(); + (*device_video) = NULL; + } } } delete dev_info; diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc index 5f0ef7cff..4a7437a96 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc @@ -28,7 +28,7 @@ void ViEAutoTest::ViEBaseStandardTest() { int video_channel = -1; EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel)); - webrtc::VideoCaptureModule* video_capture_module(NULL); + webrtc::VideoCaptureModule* video_capture_module = NULL; const unsigned int kMaxDeviceNameLength = 128; char device_name[kMaxDeviceNameLength]; memset(device_name, 0, kMaxDeviceNameLength); @@ -44,6 +44,10 @@ void ViEAutoTest::ViEBaseStandardTest() { &capture_id, &video_capture_module); + EXPECT_TRUE(video_capture_module); + if (!video_capture_module) + return; + EXPECT_EQ(0, capture_interface->ConnectCaptureDevice(capture_id, video_channel)); EXPECT_EQ(0, capture_interface->StartCapture(capture_id)); diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc index bec665767..d44f6b916 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc @@ -121,10 +121,10 @@ void ViEAutoTest::ViECaptureStandardTest() { ASSERT_GT(number_of_capture_devices, 0) << "This test requires a capture device (i.e. a webcam)"; - int capture_device_id[10]; - memset(capture_device_id, 0, sizeof(capture_device_id)); - webrtc::VideoCaptureModule* vcpms[10]; - memset(vcpms, 0, sizeof(vcpms)); +#if !defined(WEBRTC_MAC) + int capture_device_id[10] = {0}; + webrtc::VideoCaptureModule* vcpms[10] = {0}; +#endif // Check capabilities for (int device_index = 0; device_index < number_of_capture_devices; @@ -179,6 +179,9 @@ void ViEAutoTest::ViECaptureStandardTest() { webrtc::VideoCaptureModule* vcpm = webrtc::VideoCaptureFactory::Create(device_index, device_unique_name); EXPECT_TRUE(vcpm != NULL); + if (!vcpm) + continue; + vcpm->AddRef(); vcpms[device_index] = vcpm; @@ -249,7 +252,8 @@ void ViEAutoTest::ViECaptureStandardTest() { EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice( capture_device_id[device_index])); #endif // !WEBRTC_ANDROID - vcpms[device_index]->Release(); + if (vcpms[device_index]) + vcpms[device_index]->Release(); } #endif // !WEBRTC_MAC } diff --git a/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc b/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc index 684bff978..61b356563 100644 --- a/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc +++ b/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc @@ -66,7 +66,8 @@ TbCaptureDevice::~TbCaptureDevice(void) { EXPECT_EQ(0, ViE.capture->StopCapture(captureId)); EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId)); - vcpm_->Release(); + if (vcpm_) + vcpm_->Release(); } void TbCaptureDevice::ConnectTo(int videoChannel)