[{"id":39631,"web_url":"https://patchwork.libcamera.org/comment/39631/","msgid":"<178349938954.2174993.6595725884795998962@ping.linuxembedded.co.uk>","date":"2026-07-08T08:29:49","subject":"Re: [PATCH] tests: ipa_data_serializer_test: Test serializing fds","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Paul Elder (2026-07-08 05:22:37)\n> Add tests to test IPADataSerializer serializing SharedFDs.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  .../ipa_data_serializer_test.cpp              | 43 +++++++++++++++++++\n>  1 file changed, 43 insertions(+)\n> \n> diff --git a/test/serialization/ipa_data_serializer_test.cpp b/test/serialization/ipa_data_serializer_test.cpp\n> index afea93a6c24d..9b16383c4d5f 100644\n> --- a/test/serialization/ipa_data_serializer_test.cpp\n> +++ b/test/serialization/ipa_data_serializer_test.cpp\n> @@ -11,6 +11,7 @@\n>  #include <iostream>\n>  #include <limits>\n>  #include <stdlib.h>\n> +#include <sys/mman.h>\n>  #include <sys/stat.h>\n>  #include <sys/types.h>\n>  #include <tuple>\n> @@ -140,6 +141,10 @@ protected:\n>                 if (ret != TestPass)\n>                         return ret;\n>  \n> +               ret = testFd();\n> +               if (ret != TestPass)\n> +                       return ret;\n> +\n>                 return TestPass;\n>         }\n>  \n> @@ -431,6 +436,44 @@ private:\n>  \n>                 return TestPass;\n>         }\n> +\n> +       int testFd()\n> +       {\n> +               /* Test serdes of single fd */\n> +               int memfd = memfd_create(\"test\", 0);\n> +               if (memfd < 0) {\n> +                       cerr << \"Failed to create memfd\" << endl;\n> +                       return TestFail;\n> +               }\n> +\n> +               SharedFD fd = SharedFD(std::move(memfd));\n> +               if (memfd != -1) {\n> +                       cerr << \"SharedFD move constructor failed\" << endl;\n> +                       return TestFail;\n> +               }\n> +\n> +               if (testPodSerdes(fd) != TestPass)\n> +                       return TestFail;\n\nThis tests the objects are reconstructed correctly, but doesn't check\nit's still a valid file descriptor which will work after crossing an IPC\nboundary?\n\nIs there anything we can do in the existing infrastructure to validate\nthat bit ? Otherwise as this at least ensures the type is correct, and\ngiven the content will be the same - and we're in the same process the\nFD will be valid so:\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> +\n> +               /* Test serdes of vector of fds */\n> +               std::vector<SharedFD> vecFds;\n> +\n> +               for (unsigned int i = 0; i < 10; i++) {\n> +                       std::string name = \"test\" + std::to_string(i);\n> +                       int mfd = memfd_create(name.c_str(), 0);\n> +                       if (mfd < 0)\n> +                               return TestFail;\n> +\n> +                       vecFds.push_back(SharedFD(std::move(mfd)));\n> +                       if (mfd != -1)\n> +                               return TestFail;\n> +               }\n> +\n> +               if (testVectorSerdes(vecFds) != TestPass)\n> +                       return TestFail;\n> +\n> +               return TestPass;\n> +       }\n>  };\n>  \n>  TEST_REGISTER(IPADataSerializerTest)\n> -- \n> 2.47.2\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 192C4C3301\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Jul 2026 08:29:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 39E9766074;\n\tWed,  8 Jul 2026 10:29:54 +0200 (CEST)","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 74F1B65FEF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Jul 2026 10:29:52 +0200 (CEST)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7EBA719A2;\n\tWed,  8 Jul 2026 10:29:02 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"sX55Y8D8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783499342;\n\tbh=s47E+qOA1IFQmZfFlFKUztkT23fvKGbW5r04XoBedmA=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=sX55Y8D8qBGECYg7bewuefsmlc+RQw2jRcCt2oq0MnNQcLEpRjLFPfi8AFbNf4qFu\n\tsfhiUT6GsrMmzV08HVsnNP9Yo6hhD+mDu4Us2NdYzcFI9jG5nBlBFXwmv9ruryi2Uz\n\tJM70nLb+9R+qbSchR51E+1Jbpefe0puov9ywMFg8=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260708042237.297547-1-paul.elder@ideasonboard.com>","References":"<20260708042237.297547-1-paul.elder@ideasonboard.com>","Subject":"Re: [PATCH] tests: ipa_data_serializer_test: Test serializing fds","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 08 Jul 2026 09:29:49 +0100","Message-ID":"<178349938954.2174993.6595725884795998962@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":39633,"web_url":"https://patchwork.libcamera.org/comment/39633/","msgid":"<178350729190.292172.10945522757751784838@neptunite.rasen.tech>","date":"2026-07-08T10:41:31","subject":"Re: [PATCH] tests: ipa_data_serializer_test: Test serializing fds","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Kieran Bingham (2026-07-08 17:29:49)\n> Quoting Paul Elder (2026-07-08 05:22:37)\n> > Add tests to test IPADataSerializer serializing SharedFDs.\n> > \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > ---\n> >  .../ipa_data_serializer_test.cpp              | 43 +++++++++++++++++++\n> >  1 file changed, 43 insertions(+)\n> > \n> > diff --git a/test/serialization/ipa_data_serializer_test.cpp b/test/serialization/ipa_data_serializer_test.cpp\n> > index afea93a6c24d..9b16383c4d5f 100644\n> > --- a/test/serialization/ipa_data_serializer_test.cpp\n> > +++ b/test/serialization/ipa_data_serializer_test.cpp\n> > @@ -11,6 +11,7 @@\n> >  #include <iostream>\n> >  #include <limits>\n> >  #include <stdlib.h>\n> > +#include <sys/mman.h>\n> >  #include <sys/stat.h>\n> >  #include <sys/types.h>\n> >  #include <tuple>\n> > @@ -140,6 +141,10 @@ protected:\n> >                 if (ret != TestPass)\n> >                         return ret;\n> >  \n> > +               ret = testFd();\n> > +               if (ret != TestPass)\n> > +                       return ret;\n> > +\n> >                 return TestPass;\n> >         }\n> >  \n> > @@ -431,6 +436,44 @@ private:\n> >  \n> >                 return TestPass;\n> >         }\n> > +\n> > +       int testFd()\n> > +       {\n> > +               /* Test serdes of single fd */\n> > +               int memfd = memfd_create(\"test\", 0);\n> > +               if (memfd < 0) {\n> > +                       cerr << \"Failed to create memfd\" << endl;\n> > +                       return TestFail;\n> > +               }\n> > +\n> > +               SharedFD fd = SharedFD(std::move(memfd));\n> > +               if (memfd != -1) {\n> > +                       cerr << \"SharedFD move constructor failed\" << endl;\n> > +                       return TestFail;\n> > +               }\n> > +\n> > +               if (testPodSerdes(fd) != TestPass)\n> > +                       return TestFail;\n> \n> This tests the objects are reconstructed correctly, but doesn't check\n> it's still a valid file descriptor which will work after crossing an IPC\n> boundary?\n\nYes, this only tests the serialization and deserialization.\n\n> \n> Is there anything we can do in the existing infrastructure to validate\n> that bit ? Otherwise as this at least ensures the type is correct, and\n\nI think we can add it to unixsocket_ipc.\n\n(This patch was just a few-year-old patch that I unearthed while cleaning my\nbranches)\n\n> given the content will be the same - and we're in the same process the\n> FD will be valid so:\n> \n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\nThanks,\n\nPaul\n\n> \n> \n> > +\n> > +               /* Test serdes of vector of fds */\n> > +               std::vector<SharedFD> vecFds;\n> > +\n> > +               for (unsigned int i = 0; i < 10; i++) {\n> > +                       std::string name = \"test\" + std::to_string(i);\n> > +                       int mfd = memfd_create(name.c_str(), 0);\n> > +                       if (mfd < 0)\n> > +                               return TestFail;\n> > +\n> > +                       vecFds.push_back(SharedFD(std::move(mfd)));\n> > +                       if (mfd != -1)\n> > +                               return TestFail;\n> > +               }\n> > +\n> > +               if (testVectorSerdes(vecFds) != TestPass)\n> > +                       return TestFail;\n> > +\n> > +               return TestPass;\n> > +       }\n> >  };\n> >  \n> >  TEST_REGISTER(IPADataSerializerTest)\n> > -- \n> > 2.47.2\n> >","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 51A92C3318\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Jul 2026 10:41:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5E0BA66080;\n\tWed,  8 Jul 2026 12:41:40 +0200 (CEST)","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 2238D66003\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Jul 2026 12:41:39 +0200 (CEST)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:7c23:cb25:99bc:17dc])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id CFCEFE9C;\n\tWed,  8 Jul 2026 12:40:48 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RP52aOKw\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783507249;\n\tbh=WircNitsGWckn+XxeuQEqRvRSqqdW5Atrgupk+zQ+kA=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=RP52aOKwtPudj46A35VMY+qz2oLo/stxbm8dS2/JTpY/BhRux88LXjTHpuEeDH6GB\n\tKDansYe91IHTbeowYqHMBMTHAikKWbaT4CEg/FFZWwfuW7zXnBteMhqsRvUbOPAW8x\n\tI+oX2Kkj/tXop6yTetOcSdnrQ05rsSIvk3X8qGzk=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<178349938954.2174993.6595725884795998962@ping.linuxembedded.co.uk>","References":"<20260708042237.297547-1-paul.elder@ideasonboard.com>\n\t<178349938954.2174993.6595725884795998962@ping.linuxembedded.co.uk>","Subject":"Re: [PATCH] tests: ipa_data_serializer_test: Test serializing fds","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 08 Jul 2026 19:41:31 +0900","Message-ID":"<178350729190.292172.10945522757751784838@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]