sage icon indicating copy to clipboard operation
sage copied to clipboard

Repair `sage -t --valgrind`

Open mkoeppe opened this issue 1 year ago • 12 comments

As noted in https://github.com/sagemath/sage/pull/36046#issuecomment-1676833196, sage -t --valgrind does not work because it instruments the wrong process.

As part of the fix, we move the contents of src/bin/sage-runtests to src/bin/sage/doctest/__main__.py so that the doctester can be invoked as sage -python -m sage.doctest.

We also arrange for sage -t --valgrind to use the suppressions file added in #36046.

:memo: Checklist

  • [x] The title is concise and informative.
  • [x] The description explains in detail what this PR is about.
  • [x] I have linked a relevant issue or discussion.
  • [ ] I have created tests covering the changes.
  • [ ] I have updated the documentation accordingly.

:hourglass: Dependencies

mkoeppe avatar Mar 08 '24 23:03 mkoeppe

Works fine with my current testing workflow (no --valgrind). However, using --valgrind doesn't work:

> sage -t --installed --valgrind
too many failed tests, not using stored timings
exec valgrind --tool=memcheck --leak-resolution=high --leak-check=full --num-callers=25 --suppressions=/usr/lib/python3.11/site-packages/sage/ext_data/valgrind/pyalloc.supp --suppressions=/usr/lib/python3.11/site-packages/sage/ext_data/valgrind/sage.supp --suppressions=/usr/lib/python3.11/site-packages/sage/ext_data/valgrind/sage-additional.supp --suppressions=/usr/lib/python3.11/site-packages/sage/ext_data/valgrind/valgrind-python.supp  --log-file=/home/antonio/.sage/valgrind/sage-memcheck.%p /usr/bin/python -m sage.doctest --serial --timeout=172800 --stats_path=/home/antonio/.sage/timings2.json --optional=pip,sage 
either use --new, --all, --installed, or some filenames

(which is nonsense, since I did pass --installed)

antonio-rojas avatar Mar 11 '24 07:03 antonio-rojas

Thanks for testing! I'll investigate.

mkoeppe avatar Mar 11 '24 07:03 mkoeppe

This quick fix should take care of --installed, but there is a whole list of other options that would also need to be handled.

mkoeppe avatar Mar 11 '24 07:03 mkoeppe

This quick fix should take care of --installed, but there is a whole list of other options that would also need to be handled.

Since --all is disallowed, shouldn't --installed be disallowed too? Since usually one does have the entire library installed, not just one file.

antonio-rojas avatar Mar 11 '24 07:03 antonio-rojas

Since --all is disallowed, shouldn't --installed be disallowed too?

I've removed this check now. I think it was poorly motivated. Note that one could already pass multiple filenames on the command line.

mkoeppe avatar Mar 15 '24 05:03 mkoeppe

there is a whole list of other options that would also need to be handled.

I've added them all now.

mkoeppe avatar Mar 15 '24 05:03 mkoeppe

Documentation preview for this PR (built with commit 01ce6d76b9747cb8e6dd753b26a47ef7f515b495; changes) is ready! :tada: This preview will update shortly after each push to this PR.

github-actions[bot] avatar Apr 01 '24 10:04 github-actions[bot]

I get

$ sage -t --valgrind src/sage/coding/ag_code_decoders.pyx
exec valgrind --tool=memcheck --leak-resolution=high --leak-check=full --num-callers=25 --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/pyalloc.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/sage.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/sage-additional.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/valgrind-python.supp  --log-file=/home/kwankyu/.sage/valgrind/sage-memcheck.%p /home/kwankyu/GitHub/sage-dev/local/var/lib/sage/venv-python3.12/bin/python3 -m sage.doctest --serial --timeout=172800 --warn_long=46.83061857819557 --random_seed=106105322697099798603050462338239531047 --global_iterations=1 --file_iterations=1 --optional=debian,pip,sage,sage_spkg src/sage/coding/ag_code_decoders.pyx
usage: sage -t [options] filenames
__main__.py: error: unrecognized arguments: --warn_long=46.83061857819557 --random_seed=106105322697099798603050462338239531047

kwankyu avatar Jul 23 '24 04:07 kwankyu

I get

$ sage -t --valgrind src/sage/coding/ag_code_decoders.pyx
exec valgrind --tool=memcheck --leak-resolution=high --leak-check=full --num-callers=25 --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/pyalloc.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/sage.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/sage-additional.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/valgrind-python.supp  --log-file=/home/kwankyu/.sage/valgrind/sage-memcheck.%p /home/kwankyu/GitHub/sage-dev/local/var/lib/sage/venv-python3.12/bin/python3 -m sage.doctest --serial --timeout=172800 --warn_long=46.83061857819557 --random_seed=106105322697099798603050462338239531047 --global_iterations=1 --file_iterations=1 --optional=debian,pip,sage,sage_spkg src/sage/coding/ag_code_decoders.pyx
usage: sage -t [options] filenames
__main__.py: error: unrecognized arguments: --warn_long=46.83061857819557 --random_seed=106105322697099798603050462338239531047

Is this fixed?

kwankyu avatar Aug 13 '24 03:08 kwankyu

I should learn to set a "needs work" PR back to "draft" before rebasing it

mkoeppe avatar Aug 13 '24 03:08 mkoeppe

Ready? As far as I can see, it is working well.

kwankyu avatar Aug 13 '24 06:08 kwankyu

Thanks!

mkoeppe avatar Aug 13 '24 06:08 mkoeppe

I'm getting

**********************************************************************
File "src/sage/doctest/__main__.py", line 38, in sage.doctest.__main__._get_optional_defaults
Failed example:
    DA = DocTestDefaults(runtest_default=True, **D); DA
Expected:
    DocTestDefaults(abspath=False, file_iterations=0, global_iterations=0,
                    optional='sage,optional', random_seed=None,
                    stats_path='.../timings2.json')
Got:
    DocTestDefaults(abspath=False, file_iterations=0, global_iterations=0, optional='sage,optional', stats_path='/var/lib/buildbot/worker/sage_git/dot_sage/timings2.json')
**********************************************************************

vbraun avatar Aug 27 '24 20:08 vbraun

Do you set doctester-related env variables or pass options to sage -t on buildbot?

mkoeppe avatar Aug 27 '24 20:08 mkoeppe

Buildbot sets SAGE_DOCTEST_RANDOM_SEED=0

vbraun avatar Aug 27 '24 20:08 vbraun

Thanks, I'll investigate

mkoeppe avatar Aug 27 '24 20:08 mkoeppe