From patchwork Wed Jun 12 23:15:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1420 X-Patchwork-Delegate: paul.elder@ideasonboard.com Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CCFD63402 for ; Thu, 13 Jun 2019 01:15:19 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B6C1852C; Thu, 13 Jun 2019 01:15:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1560381319; bh=yWYVpoNK5A1U+oZc3vfd626L2UhBjyp1ULiT6HSGIMA=; h=From:To:Cc:Subject:Date:From; b=iOdU08ROJaUv2D2NUOWGaPXvsNNouqcpsE/VBI6vLpmEaZc8Eap5DUHyasUaSEWUz oIkkT9DI8TH++WV/48YcVD/0Xf27vwJ7CjtxHeDcVYJrde6ezqMPoM/E/puzt2DBU9 kUyswcazNIRCYxwffiSElKz0NvlSCHUR09JRO7sk= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 12 Jun 2019 19:15:05 -0400 Message-Id: <20190612231505.25311-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] tests: Add unset IPA environment variable test X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jun 2019 23:15:19 -0000 There once was a crash that was caused by an unset LIBCAMERA_IPA_MODULE_PATH environment variable. (Fixed as of "libcamera: ipa_manager: Fix handling of unset LIBCAMERA_IPA_MODULE_PATH") All tests have this environment variable set, which is why this error wasn't caught for a while. Add a test (that is essentially the same as list-cameras) that unsets this environment variable. Signed-off-by: Paul Elder --- test/ipa/ipa_env_var_test.cpp | 56 +++++++++++++++++++++++++++++++++++ test/ipa/meson.build | 1 + 2 files changed, 57 insertions(+) create mode 100644 test/ipa/ipa_env_var_test.cpp diff --git a/test/ipa/ipa_env_var_test.cpp b/test/ipa/ipa_env_var_test.cpp new file mode 100644 index 0000000..a221cd9 --- /dev/null +++ b/test/ipa/ipa_env_var_test.cpp @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * ipa_env_var_test.cpp - IPA environment variable test + */ + +#include + +#include +#include + +#include "test.h" + +using namespace std; +using namespace libcamera; + +class IPAEnvVarTest : public Test +{ +protected: + int init() + { + if (unsetenv("LIBCAMERA_IPA_MODULE_PATH")) { + cerr << "failed to unset LIBCAMERA_IPA_MODULE_PATH" + << endl; + return TestSkip; + } + + cm = CameraManager::instance(); + cm->start(); + + return TestPass; + } + + int run() + { + unsigned int count = 0; + + for (const std::shared_ptr &camera : cm->cameras()) { + cout << "- " << camera->name() << endl; + count++; + } + + return count ? 0 : -ENODEV; + } + + void cleanup() + { + cm->stop(); + } + +private: + CameraManager *cm; +}; + +TEST_REGISTER(IPAEnvVarTest) diff --git a/test/ipa/meson.build b/test/ipa/meson.build index bca39fa..7bc86fb 100644 --- a/test/ipa/meson.build +++ b/test/ipa/meson.build @@ -1,5 +1,6 @@ ipa_test = [ ['ipa_test', 'ipa_test.cpp'], + ['ipa_env_var_test', 'ipa_env_var_test.cpp'], ] foreach t : ipa_test