[{"id":1905,"web_url":"https://patchwork.libcamera.org/comment/1905/","msgid":"<20190618203324.GD23556@pendragon.ideasonboard.com>","date":"2019-06-18T20:33:24","subject":"Re: [libcamera-devel] [PATCH] tests: Add unset IPA environment\n\tvariable test","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Wed, Jun 12, 2019 at 07:15:05PM -0400, Paul Elder wrote:\n> There once was a crash  that was caused by an unset\n\ns/  / /\n\n> LIBCAMERA_IPA_MODULE_PATH environment variable. (Fixed as of\n> \"libcamera: ipa_manager: Fix handling of unset\n> LIBCAMERA_IPA_MODULE_PATH\")\n> \n> All tests have this environment variable set, which is why this error\n> wasn't caught for a while. Add a test (that is essentially the same as\n> list-cameras) that unsets this environment variable.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\nHow about instead unsetting it for a group of existing tests that don't\nneed IPAs ? That would save a bit of runtime by avoiding an extra test.\n\nAnother option would be to only set the variable for the test cases that\ndeal with IPAs. It may be more logical than manually unsetting it for a\ntest case that has nothing to do with IPAs.\n\n> ---\n>  test/ipa/ipa_env_var_test.cpp | 56 +++++++++++++++++++++++++++++++++++\n>  test/ipa/meson.build          |  1 +\n>  2 files changed, 57 insertions(+)\n>  create mode 100644 test/ipa/ipa_env_var_test.cpp\n> \n> diff --git a/test/ipa/ipa_env_var_test.cpp b/test/ipa/ipa_env_var_test.cpp\n> new file mode 100644\n> index 0000000..a221cd9\n> --- /dev/null\n> +++ b/test/ipa/ipa_env_var_test.cpp\n> @@ -0,0 +1,56 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * ipa_env_var_test.cpp - IPA environment variable test\n> + */\n> +\n> +#include <iostream>\n> +\n> +#include <libcamera/camera.h>\n> +#include <libcamera/camera_manager.h>\n> +\n> +#include \"test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +class IPAEnvVarTest : public Test\n> +{\n> +protected:\n> +\tint init()\n> +\t{\n> +\t\tif (unsetenv(\"LIBCAMERA_IPA_MODULE_PATH\")) {\n> +\t\t\tcerr << \"failed to unset LIBCAMERA_IPA_MODULE_PATH\"\n> +\t\t\t     << endl;\n> +\t\t\treturn TestSkip;\n> +\t\t}\n> +\n> +\t\tcm = CameraManager::instance();\n> +\t\tcm->start();\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +\n> +\tint run()\n> +\t{\n> +\t\tunsigned int count = 0;\n> +\n> +\t\tfor (const std::shared_ptr<Camera> &camera : cm->cameras()) {\n> +\t\t\tcout << \"- \" << camera->name() << endl;\n> +\t\t\tcount++;\n> +\t\t}\n> +\n> +\t\treturn count ? 0 : -ENODEV;\n> +\t}\n> +\n> +\tvoid cleanup()\n> +\t{\n> +\t\tcm->stop();\n> +\t}\n> +\n> +private:\n> +\tCameraManager *cm;\n> +};\n> +\n> +TEST_REGISTER(IPAEnvVarTest)\n> diff --git a/test/ipa/meson.build b/test/ipa/meson.build\n> index bca39fa..7bc86fb 100644\n> --- a/test/ipa/meson.build\n> +++ b/test/ipa/meson.build\n> @@ -1,5 +1,6 @@\n>  ipa_test = [\n>      ['ipa_test', 'ipa_test.cpp'],\n> +    ['ipa_env_var_test', 'ipa_env_var_test.cpp'],\n>  ]\n>  \n>  foreach t : ipa_test","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EDBCA60BD8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Jun 2019 22:33:42 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 59E8AD5;\n\tTue, 18 Jun 2019 22:33:42 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1560890022;\n\tbh=LUMxjMmeGi3Zg34GTlHG7aJZwR5W1uj7FSxzUiMAKFo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gQxRj7a0lOAjStM0O5mGOz3jB0MN6h98k//EBx2RLk3fcfUTZn/b59GBFgMkmS4wu\n\tAwU+HaqZRLpIYPhdK0uXPD3lmt+rVvsAs98AF7FRfpnfTsr6D3NpmwkYN1oL1LAb/8\n\tDQn7i2pq29jIP/U7Nt945wC0yArmEYEAcgBUXwuE=","Date":"Tue, 18 Jun 2019 23:33:24 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190618203324.GD23556@pendragon.ideasonboard.com>","References":"<20190612231505.25311-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190612231505.25311-1-paul.elder@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH] tests: Add unset IPA environment\n\tvariable test","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 18 Jun 2019 20:33:43 -0000"}}]