<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>PYTHONMALLOC=malloc gdb --args python3 -m pytest <span
style="color:#1F497D" lang="EN-US">autotest/ogr/ogr_miramon_vector.py</span></p>
<p>PYTHONMALLOC=malloc valgrind python3 -m pytest <span
style="color:#1F497D" lang="EN-US">autotest/ogr/ogr_miramon_vector.py</span></p>
<div class="moz-cite-prefix">Le 06/03/2024 à 16:02, Abel Pau via
gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:PAXPR07MB7775CCC3C6DD22E8F7EFD401A2212@PAXPR07MB7775.eurprd07.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator"
content="Microsoft Word 15 (filtered medium)">
<style>@font-face
{font-family:"MS Gothic";
panose-1:2 11 6 9 7 2 5 8 2 4;}@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}@font-face
{font-family:"\@MS Gothic";
panose-1:2 11 6 9 7 2 5 8 2 4;}@font-face
{font-family:"Segoe UI Symbol";
panose-1:2 11 5 2 4 2 4 2 2 3;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}pre
{mso-style-priority:99;
mso-style-link:"HTML con formato previo Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}span.HTMLconformatoprevioCar
{mso-style-name:"HTML con formato previo Car";
mso-style-priority:99;
mso-style-link:"HTML con formato previo";
font-family:Consolas;
mso-fareast-language:EN-US;}p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}span.EstiloCorreo22
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}span.EstiloCorreo23
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}span.EstiloCorreo24
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}span.EstiloCorreo25
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}div.WordSection1
{page:WordSection1;}ol
{margin-bottom:0cm;}ul
{margin-bottom:0cm;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Hi
again,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">anyone
have any advice for debuging into python code?<br>
I am using Pdb but it’s a little confusing.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Any
experience?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Thanks<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">apau@ABEL2:/mnt/d/GitHub-repository/gdal/build$
pytest autotest/ogr/ogr_miramon_vector.py<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Test
session starts (platform: linux, Python 3.8.10, pytest
8.0.2, pytest-sugar 1.0.0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">benchmark:
4.0.0 (defaults: timer=time.perf_counter disable_gc=False
min_rounds=5 min_time=0.000005 max_time=1.0
calibration_precision=10 warmup=False
warmup_iterations=100000)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">GDAL
Build Info:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
PAM_ENABLED: YES<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
OGR_ENABLED: YES<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
CURL_ENABLED: YES<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
CURL_VERSION: 7.68.0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
GEOS_ENABLED: YES<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
GEOS_VERSION: 3.8.0-CAPI-1.13.1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
PROJ_BUILD_VERSION: 6.3.1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
PROJ_RUNTIME_VERSION: 6.3.1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
COMPILER: GCC 9.4.0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">GDAL_DOWNLOAD_TEST_DATA:
undefined (tests relying on downloaded data may be skipped)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">GDAL_RUN_SLOW_TESTS:
undefined (tests marked as "slow" will be skipped)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">rootdir:
/mnt/d/GitHub-repository/gdal/build/autotest<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">configfile:
pytest.ini<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">plugins:
benchmark-4.0.0, sugar-1.0.0, env-1.1.3<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">collected
3 items<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">ogr/ogr_miramon_vector.py
</span><span
style="font-family:"Segoe UI Symbol",sans-serif;color:#1F497D"
lang="EN-US">✓✓</span><span style="color:#1F497D"
lang="EN-US">
67%</span><span
style="font-family:"Arial",sans-serif;color:#1F497D"
lang="EN-US">██████</span><span
style="font-family:"MS Gothic";color:#1F497D"
lang="EN-US">▋</span><span style="color:#1F497D"
lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PDB set_trace (IO-capturing turned off)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">>
/mnt/d/GitHub-repository/gdal/build/autotest/ogr/ogr_miramon_vector.py(132)test_ogr_miramon_simple_polygon()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">->
f = lyr.GetNextFeature()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">(Pdb)
s<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">--Call--<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">>
/mnt/d/GitHub-repository/gdal/build/swig/python/osgeo/ogr.py(1654)GetNextFeature()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">->
def GetNextFeature(self, *args) -> "OGRFeatureShadow *":<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">(Pdb)
s<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">>
/mnt/d/GitHub-repository/gdal/build/swig/python/osgeo/ogr.py(1668)GetNextFeature()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">->
return _ogr.Layer_GetNextFeature(self, *args)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">(Pdb)
s<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">ERROR
2: CPLRealloc(): Out of memory allocating 667227037326010464
bytes.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Fatal
Python error: Aborted<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Current
thread 0x00007f67c7140740 (most recent call first):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/mnt/d/GitHub-repository/gdal/build/swig/python/osgeo/ogr.py",
line 1668 in GetNextFeature<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/mnt/d/GitHub-repository/gdal/build/autotest/ogr/ogr_miramon_vector.py",
line 132 in test_ogr_miramon_simple_polygon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/python.py",
line 194 in pytest_pyfunc_call<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py",
line 102 in _multicall<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py",
line 119 in _hookexec<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py",
line 501 in __call__<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/python.py",
line 1831 in runtest<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/runner.py",
line 170 in pytest_runtest_call<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py",
line 102 in _multicall<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py",
line 119 in _hookexec<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py",
line 501 in __call__<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/runner.py",
line 263 in <lambda><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/runner.py",
line 342 in from_call<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/runner.py",
line 262 in call_runtest_hook<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/runner.py",
line 223 in call_and_report<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/runner.py",
line 134 in runtestprotocol<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/runner.py",
line 115 in pytest_runtest_protocol<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py",
line 102 in _multicall<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py",
line 119 in _hookexec<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py",
line 501 in __call__<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/main.py",
line 352 in pytest_runtestloop<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py",
line 102 in _multicall<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py",
line 119 in _hookexec<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py",
line 501 in __call__<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/main.py",
line 327 in _main<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/main.py",
line 273 in wrap_session<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/main.py",
line 320 in pytest_cmdline_main<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py",
line 102 in _multicall<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py",
line 119 in _hookexec<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py",
line 501 in __call__<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/config/__init__.py",
line 175 in main<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File
"/usr/local/lib/python3.8/dist-packages/_pytest/config/__init__.py",
line 198 in console_main<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
File "/usr/local/bin/pytest", line 8 in <module><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="ES">Aborted<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="ES"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="ES"><o:p> </o:p></span></p>
<div>
<div
style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span
style="mso-fareast-language:CA" lang="ES">De:</span></b><span
style="mso-fareast-language:CA" lang="ES"> gdal-dev
<a class="moz-txt-link-rfc2396E" href="mailto:gdal-dev-bounces@lists.osgeo.org"><gdal-dev-bounces@lists.osgeo.org></a>
<b>En nombre de </b>Abel Pau via gdal-dev<br>
<b>Enviado el:</b> dimecres, 6 de març de 2024 15:08<br>
<b>Para:</b> Even Rouault
<a class="moz-txt-link-rfc2396E" href="mailto:even.rouault@spatialys.com"><even.rouault@spatialys.com></a>;
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<b>Asunto:</b> Re: [gdal-dev] Testing the driver<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">About
the question:
</span>. Does <span style="color:#1F497D" lang="EN-US">"pytest
autotest/ogr/ogr_basic_test.py" work?*<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">The
answer is YES.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">ogr/ogr_basic_test.py
</span><span
style="font-family:"Segoe UI Symbol",sans-serif;color:#1F497D"
lang="EN-US">✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓</span><span
style="color:#1F497D" lang="EN-US">
100% </span><span
style="font-family:"Arial",sans-serif;color:#1F497D"
lang="EN-US">██████████</span><span style="color:#1F497D"
lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Results
(5.98s):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
66 passed<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"><o:p> </o:p></span></p>
<div>
<div
style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span
style="mso-fareast-language:CA" lang="ES">De:</span></b><span
style="mso-fareast-language:CA" lang="ES"> Even Rouault
<<a href="mailto:even.rouault@spatialys.com"
moz-do-not-send="true" class="moz-txt-link-freetext">even.rouault@spatialys.com</a>>
<br>
<b>Enviado el:</b> dimecres, 6 de març de 2024 13:09<br>
<b>Para:</b> Abel Pau <<a
href="mailto:a.pau@creaf.uab.cat"
moz-do-not-send="true" class="moz-txt-link-freetext">a.pau@creaf.uab.cat</a>>;
<a href="mailto:gdal-dev@lists.osgeo.org"
moz-do-not-send="true" class="moz-txt-link-freetext">gdal-dev@lists.osgeo.org</a><br>
<b>Asunto:</b> Re: [gdal-dev] Testing the driver<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hi,<o:p></o:p></p>
<p>I don't see anything wrong. I've tried that on my native
Linux build and the test_ogr_miramon_vector_1() is found. Does
<span style="color:#1F497D" lang="EN-US">"pytest
autotest/ogr/ogr_basic_test.py" work?*</span><o:p></o:p></p>
<p><span style="color:#1F497D" lang="EN-US">Note: you don't need
the try / except in your test case unless you'd need to some
particular cleanup, but that's not the case here. pytest
handles test failures nicely</span><o:p></o:p></p>
<p><span style="color:#1F497D" lang="EN-US">Even</span><o:p></o:p></p>
<div>
<p class="MsoNormal">Le 05/03/2024 à 22:28, Abel Pau via
gdal-dev a écrit :<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="color:#1F497D" lang="ES">Hi
again,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">after
solving some issues I used WSL (Windows subsystem Linux)
to create an environment where I am able to run tests.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">I
run the cmake inside build folder in the environment. It’s
slow but finally it finish. After cmake --build . --target
install all is ready to be tested.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">I
create a simple test ogr_miramon_vector.py (see the code
below) to prove that it’s reliable.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">I
run:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">pytest
autotest/ogr/ogr_miramon_vector.py</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">and:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">apau@ABEL2:/mnt/d/GitHub-repository/gdal/build$
pytest autotest/ogr/ogr_miramon_vector.py</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Test
session starts (platform: linux, Python 3.8.10, pytest
8.0.2, pytest-sugar 1.0.0)</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">benchmark:
4.0.0 (defaults: timer=time.perf_counter disable_gc=False
min_rounds=5 min_time=0.000005 max_time=1.0
calibration_precision=10 warmup=False
warmup_iterations=100000)</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">GDAL
Build Info:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
PAM_ENABLED: YES</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
OGR_ENABLED: YES</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
CURL_ENABLED: YES</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
CURL_VERSION: 7.68.0</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
GEOS_ENABLED: YES</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
GEOS_VERSION: 3.8.0-CAPI-1.13.1</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
PROJ_BUILD_VERSION: 6.3.1</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
PROJ_RUNTIME_VERSION: 6.3.1</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
COMPILER: GCC 9.4.0</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">GDAL_DOWNLOAD_TEST_DATA:
undefined (tests relying on downloaded data may be
skipped)</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">GDAL_RUN_SLOW_TESTS:
undefined (tests marked as "slow" will be skipped)</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">rootdir:
/mnt/d/GitHub-repository/gdal/build/autotest</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">configfile:
pytest.ini</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">plugins:
benchmark-4.0.0, sugar-1.0.0, env-1.1.3</span><o:p></o:p></p>
<p class="MsoNormal"><b><span style="color:#1F497D"
lang="EN-US">collected 0 items</span></b><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">My
questions is why it seems it’s not working?</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">Thanks!</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">The
test:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">-------------</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">import
os</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">import
gdaltest</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">import
ogrtest</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">import
pytest</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">from
osgeo import gdal, ogr, osr</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">pytestmark
= pytest.mark.require_driver("MiraMonVector")</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">###############################################################################</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">@pytest.fixture(scope="module",
autouse=True)</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">def
init():</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
with gdaltest.config_option("CPL_DEBUG", "ON"):</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
yield</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">###############################################################################</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">#
basic test </span>
<o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">def
test_ogr_miramon_vector_1():</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
try:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
ds =
gdal.OpenEx("data/miramon/Points/SimplePoints/SimplePointsFile.pnt")</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
lyr = ds.GetLayer(0)</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
assert lyr is not None, "Failed to get layer"</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
assert lyr.GetFeatureCount() == 3</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
assert lyr.GetGeomType() == ogr.wkbPoint</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> f
= lyr.GetNextFeature()</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
assert f.GetFID() == 0</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
assert f.GetGeometryRef().ExportToWkt() == "POINT (513.49
848.81)"</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
assert f.GetField("ID_GRAFIC") == "0"</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
f = lyr.GetNextFeature()</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
assert f.GetField("ID_GRAFIC") == "1"</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
f = lyr.GetNextFeature()</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
assert f.GetField("ID_GRAFIC") == "2"</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
ds = None</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
except Exception as e:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US">
pytest.fail(f"Test failed with exception: {e}")</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D" lang="EN-US"> </span><o:p></o:p></p>
<div>
<div
style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span
style="mso-fareast-language:CA" lang="ES">De:</span></b><span
style="mso-fareast-language:CA" lang="ES"> Even
Rouault
<a href="mailto:even.rouault@spatialys.com"
moz-do-not-send="true"><even.rouault@spatialys.com></a>
<br>
<b>Enviado el:</b> divendres, 9 de febrer de 2024
11:48<br>
<b>Para:</b> Abel Pau <a
href="mailto:a.pau@creaf.uab.cat"
moz-do-not-send="true"><a.pau@creaf.uab.cat></a>;
<a href="mailto:gdal-dev@lists.osgeo.org"
moz-do-not-send="true" class="moz-txt-link-freetext">gdal-dev@lists.osgeo.org</a><br>
<b>Asunto:</b> Re: [gdal-dev] Testing the driver</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p>Abel,<o:p></o:p></p>
<div>
<p class="MsoNormal">Le 09/02/2024 à 10:55, Abel Pau via
gdal-dev a écrit :<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US">Hi,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">I am at the lasts
steps before pulling a request about the MiraMon driver.
<br>
I need to write some documentation and formalize the
tests. </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">After that, I’ll do
the pull request to github.</span><o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span
style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:CA">I'd
suggest first before issuing the pull request that you
push to your fork on github and look at the Actions tab.
That will allow you to fix a lot of things on your side,
before issuing the PR itself<br>
<br>
</span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-US">I am a little
confused about the testing. I can use pytest or ctest,
right? Which is the favourite? Are there any changes
from the official documentation?</span><o:p></o:p></p>
</blockquote>
<p>ctest is just the CMake way of launching the test suite. It
will execute C++ tests of autotest/cpp directly, and for
tests written in python will launch "pytest autotest/XXXXX"
for each directory.
<o:p></o:p></p>
<p>"ctest --test-dir $build_dir -R autotest_ogr -V" will just
run all the autotest/ogr tests, which can be quite long
already.<o:p></o:p></p>
<p>To test your own development, you may have a more pleasant
experience by directly running just the tests for your
driver with something like "pytest
autotest/ogr/ogr_miramon.py" (be careful on Windows, the
content of $build_dir/autotest is copied from
$source_dir/autotest each time "cmake" is run, so if you
edit your test .py file directly in the build directory, be
super careful of not accidentally losing your work, and make
sure to copy its content to the source directory first.
That's admittedly an annoying point of the current test
setup on Windows, compared to Unix where we use symbolic
links)<o:p></o:p></p>
<p>after setting the environment to have PYTHONPATH point to
something like $build_dir/swig/python/Release or
$build_dir/swig/python/Debug (I believe you're on
Windows?). If you look at the first lines output by the
above "ctest --test-dir $build_dir -R autotest_ogr -V"
invokation, you'll actually see the PYTHONPATH value to
specify.<o:p></o:p></p>
<p>You also need to first install pytest and other testing
dependencies with: python -m pip install
autotest/requirements.txt<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US">There is a minimal
test to create?</span><o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span
style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:CA">A
maximal test suite, you mean ;-) You should aim for a
"reasonable" coverage of the code you wrote. Aiming to
test the nominal code paths of your driver is desirable
(testing the error cases generally requires a lot more
effort).
<br>
<br>
</span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US">Can you recommend me
some driver that tests things like:</span><o:p></o:p></p>
<p class="MsoListParagraph"
style="text-indent:-18.0pt;mso-list:l0 level1 lfo2"><!--[if !supportLists]--><span
style="mso-list:Ignore">1.<span
style="font:7.0pt "Times New Roman"">
</span></span><!--[endif]--><span lang="EN-US">Read a
point/arc/polygon layer from some format (gml,kml,
gpckg,..) and assert the number of readed objectes</span><o:p></o:p></p>
<p class="MsoListParagraph"
style="text-indent:-18.0pt;mso-list:l0 level1 lfo2"><!--[if !supportLists]--><span
style="mso-list:Ignore">2.<span
style="font:7.0pt "Times New Roman"">
</span></span><!--[endif]--><span lang="EN-US">Read a
point layer and assert some points (3d included) and
some of the fields values</span><o:p></o:p></p>
<p class="MsoListParagraph"
style="text-indent:-18.0pt;mso-list:l0 level1 lfo2"><!--[if !supportLists]--><span
style="mso-list:Ignore">3.<span
style="font:7.0pt "Times New Roman"">
</span></span><!--[endif]--><span lang="EN-US">The same
with arcs and polygons</span><o:p></o:p></p>
<p class="MsoListParagraph"
style="text-indent:-18.0pt;mso-list:l0 level1 lfo2"><!--[if !supportLists]--><span
style="mso-list:Ignore">4.<span
style="font:7.0pt "Times New Roman"">
</span></span><!--[endif]--><span lang="EN-US">Create
some layer from the own format to anothers and compare
the results with some “good” results.</span><o:p></o:p></p>
<p class="MsoListParagraph"
style="text-indent:-18.0pt;mso-list:l0 level1 lfo2"><!--[if !supportLists]--><span
style="mso-list:Ignore">5.<span
style="font:7.0pt "Times New Roman"">
</span></span><!--[endif]--><span lang="EN-US">Create
multiple layers from one outer format (like gpx) and
verify the name of the created files...</span><o:p></o:p></p>
</blockquote>
<p>You don't necessarily need to use other formats. It is
actually better if the tests of a format don't depend too
much on other formats, to keep things isolated.<o:p></o:p></p>
<p>To test the read part of your driver, add a
autotest/ogr/data/miramon directory with *small* test files,
ideally at most a few KB each to keep the size of the GDAL
repository reasonable, and a few features in each is often
enough to unit test, with different type of geometries,
attributes, and use the OGR Python API to open the file and
iterate over its layers and features to check their content.
Those files should have ideally be produced by the Miramon
software and not by the writing side of your driver, to
check the interoperability of your driver with a "reference"
software.<o:p></o:p></p>
<p>For the write site of the driver, you can for example run
gdal.VectorTranslate(dest, source) on those files, and use
again the test function to validate that the read side of
your driver likes what the write site has produced. An
alternative is also to do a binary comparison of the file
generated by your driver with a reference test file stored
in for example autotest/ogr/data/miramon/ref_output. But
this may be sometimes a fragile approach if the output of
your driver might change in the future (would require
regenerating the reference test files).<o:p></o:p></p>
<p>I'd suggest your test suite also has a test that runs the
"test_ogrsf" command line utility which is a kind of
compliance test suite which checks a number of expectations
for a driver, like that GetFeatureCount() returns the same
number as iterating with GetNextFeature(), etc etc<o:p></o:p></p>
<p>It is difficult to point at a "reference" test suite, as
all drivers have their particularities and may need specific
tests. Potential sources of inspirations:<o:p></o:p></p>
<p>- autotest/ogr/ogr_gtfs.py . Shows very simple testing of
the read side of a driver, and includes a test_ogrsf test<o:p></o:p></p>
<p>- autotest/ogr/ogr_csv.py has examples where the writing
side of the driver is checked by opening the output file and
checking that some strings are present in it (only easily
doable with text based formats)<o:p></o:p></p>
<p>- autotest/ogr/ogr_openfilegdb_write.py . Extensive testing
of the writing side of a driver . A lot in it will be
specific to the format and irrelevant to your concern, but
you should at least find all possible aspects of how to test
the write side of a driver.<o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:CA">Even
</span><o:p></o:p></p>
<pre>-- <o:p></o:p></pre>
<pre><a href="http://www.spatialys.com" moz-do-not-send="true"
class="moz-txt-link-freetext">http://www.spatialys.com</a><o:p></o:p></pre>
<pre>My software is free, but my time generally not.<o:p></o:p></pre>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span
style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:CA"><o:p> </o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>gdal-dev mailing list<o:p></o:p></pre>
<pre><a href="mailto:gdal-dev@lists.osgeo.org"
moz-do-not-send="true" class="moz-txt-link-freetext">gdal-dev@lists.osgeo.org</a><o:p></o:p></pre>
<pre><a
href="https://lists.osgeo.org/mailman/listinfo/gdal-dev"
moz-do-not-send="true" class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre><a href="http://www.spatialys.com" moz-do-not-send="true"
class="moz-txt-link-freetext">http://www.spatialys.com</a><o:p></o:p></pre>
<pre>My software is free, but my time generally not.<o:p></o:p></pre>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>