From patchwork Thu Mar 4 08:17:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11492 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 14CAFBD80E for ; Thu, 4 Mar 2021 08:17:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C50C368AB0; Thu, 4 Mar 2021 09:17:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="fXEkafgf"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D40968A98 for ; Thu, 4 Mar 2021 09:17:42 +0100 (CET) Received: by mail-wm1-x335.google.com with SMTP id o7-20020a05600c4fc7b029010a0247d5f0so4061193wmq.1 for ; Thu, 04 Mar 2021 00:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/2nAUCPXEZmL+MFvY43byb0UcTthYl9RlzZxWH65CNw=; b=fXEkafgf/sApgd4P6bQA+PGQSV7kmIh93LbsoArrtvXFPduweAs4qfoKsUdfw1XW34 v6DF5bf7brB/LJRYgXiTmwonozwrGygMCATyC1VQwt4TT0qEb43xBAcKWDb2LO+FRTQ9 jGtXMz9FuJXjThWQ3ETLpDC6RZnJJngOdknmrpU0T5ET91eT+ZG77MB+a9KLN1/Qe9Hh mR4TFCP9Mebw67WZfLKotCRudfUAF+6mV3edMde2B+wgxaxyml1F47YzjnYlIdREYN0w lDNH1bYXJuVFhgDs8GwyE5lgtVid5dI6/b/zqLnNcXWYI3fcib7sMCDDK2zuOK3tx6KU QXYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/2nAUCPXEZmL+MFvY43byb0UcTthYl9RlzZxWH65CNw=; b=G9IQZT13VCcaen9W4XxQ6NnOh+jMS0EagKS32vMT81LrpDPX9cj5J9VvFEnjYEWfME BIhi9NOe5XHu4tnOGfqiZsGbyL7qd7g66/6zvLu2zvVeMJFz+nl1M1uR2rHw12FwnSrk O0+JKYEYaV/xf8dJs6ersg0WuZCl3zsemHjO4DZ9u/viAA+NMBge5svUVP8iCWXGlimR W6KZYbFAYPpWxro+BNp+EkGltIWLuNPOHEw6aEfqc8M0wt2/ib1ckvxOHdOmeJ4rKlPc 8LhVjwUJ3VU8z+vHXla3q34ucORH/oZVeIu9pyAudFUeFxJaGLNhQHp0QaA9JIsd4q2A TrQw== X-Gm-Message-State: AOAM533i1Um4AmDhaCa4HJalmjE8INQpixUSjE27a/3MhrEbOIXwI01a rw2DsytbMfmE0pL4Kr2ImoWV4vpIaL4j+tQB X-Google-Smtp-Source: ABdhPJzHOM9x7QaLGh5J8vM0/S8GrB41VafjORgnpHRBUVoolhwTSuInwPC9KiifpBwoHqNXWiDuYg== X-Received: by 2002:a7b:ce16:: with SMTP id m22mr2676697wmc.65.1614845861571; Thu, 04 Mar 2021 00:17:41 -0800 (PST) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id b186sm6997926wmc.44.2021.03.04.00.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 00:17:41 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Thu, 4 Mar 2021 08:17:27 +0000 Message-Id: <20210304081728.1058394-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210304081728.1058394-1-naush@raspberrypi.com> References: <20210304081728.1058394-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 6/7] test: delayed_controls: Fixup tests after recent DelayedControls changes X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The recent fixes applied to DelayedControls change the behavior of the library. As such, the tests ended up failing as they relied on the old behavior of the helper. Update the tests to account for the new behavior and get the tests passing again. Specifically, the following changes have been made for each test: singleControlNoDelay(): - Add a call to reset() to initialise internal DelayedControls state only after setting the control on the device. - Trigger a first frame start by calling applyControls() as a pipeline handler would. - Test frames from 1 onwards, as we will never have a queue item at frame 0, since the reset() handles that. singleControlWithDelay(): - Trigger a first frame start by calling applyControls() as a pipeline handler would. - Test frames from 1 onwards, as we will never have a queue item at frame 0, since the reset() handles that. dualControlsWithDelay() and dualControlsMultiQueue(): - Trigger a first frame start by calling applyControls() as a pipeline handler would. - Test frames from (startOffset + 1) onwards, as we will never have a queue item at frame startOffset. - Use the max delay (2 in this case) to determine the expected result value. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham --- test/delayed_contols.cpp | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/test/delayed_contols.cpp b/test/delayed_contols.cpp index 3855eb18ecd4..c6f195b7bc7f 100644 --- a/test/delayed_contols.cpp +++ b/test/delayed_contols.cpp @@ -82,9 +82,13 @@ protected: /* Reset control to value not used in test. */ ctrls.set(V4L2_CID_BRIGHTNESS, 1); dev_->setControls(&ctrls); + delayed->reset(); + + /* Trigger the first frame start event */ + delayed->applyControls(0); /* Test control without delay are set at once. */ - for (unsigned int i = 0; i < 100; i++) { + for (unsigned int i = 1; i < 100; i++) { int32_t value = 100 + i; ctrls.set(V4L2_CID_BRIGHTNESS, value); @@ -122,8 +126,11 @@ protected: dev_->setControls(&ctrls); delayed->reset(); + /* Trigger the first frame start event */ + delayed->applyControls(0); + /* Test single control with delay. */ - for (unsigned int i = 0; i < 100; i++) { + for (unsigned int i = 1; i < 100; i++) { int32_t value = 10 + i; ctrls.set(V4L2_CID_BRIGHTNESS, value); @@ -150,9 +157,11 @@ protected: int dualControlsWithDelay(uint32_t startOffset) { + static const unsigned int maxDelay = 2; + std::unordered_map delays = { { V4L2_CID_BRIGHTNESS, { 1, false } }, - { V4L2_CID_CONTRAST, { 2, false } }, + { V4L2_CID_CONTRAST, { maxDelay, false } }, }; std::unique_ptr delayed = std::make_unique(dev_.get(), delays); @@ -165,8 +174,11 @@ protected: dev_->setControls(&ctrls); delayed->reset(); + /* Trigger the first frame start event */ + delayed->applyControls(startOffset); + /* Test dual control with delay. */ - for (unsigned int i = 0; i < 100; i++) { + for (unsigned int i = 1; i < 100; i++) { uint32_t frame = startOffset + i; int32_t value = 10 + i; @@ -189,7 +201,7 @@ protected: return TestFail; } - expected = i < 1 ? expected : value - 1; + expected = i < maxDelay ? expected : value - 1; } return TestPass; @@ -197,9 +209,11 @@ protected: int dualControlsMultiQueue() { + static const unsigned int maxDelay = 2; + std::unordered_map delays = { { V4L2_CID_BRIGHTNESS, { 1, false } }, - { V4L2_CID_CONTRAST, { 2, false } } + { V4L2_CID_CONTRAST, { maxDelay, false } } }; std::unique_ptr delayed = std::make_unique(dev_.get(), delays); @@ -212,6 +226,9 @@ protected: dev_->setControls(&ctrls); delayed->reset(); + /* Trigger the first frame start event */ + delayed->applyControls(0); + /* * Queue all controls before any fake frame start. Note we * can't queue up more then the delayed controls history size @@ -226,8 +243,8 @@ protected: } /* Process all queued controls. */ - for (unsigned int i = 0; i < 16; i++) { - int32_t value = 10 + i; + for (unsigned int i = 1; i < 16; i++) { + int32_t value = 10 + i - 1; delayed->applyControls(i); @@ -245,7 +262,7 @@ protected: return TestFail; } - expected = i < 1 ? expected : value - 1; + expected = i < maxDelay ? expected : value - 1; } return TestPass;