- labels: --> plotting, tests
This is related to bug [#5630].
By Claude:
Several tests write files with fixed names into maxima_tempdir, among them rtest2, rtest_mactex and rtest_numericalio from the test suite. Maxima processes that run the test suite at the same time with the same maxima_tempdir, as parallel test runs do, overwrite and delete each other's files, and these tests fail at random. To reproduce, run this a few times from the top of a build tree:
mkdir -p shared
for i in 1 2 3 4; do
MAXIMA_TEMPDIR=$PWD/shared ./maxima-local --no-init -q --batch-string='run_testsuite(share_tests=true, tests=["rtest_numericalio","rtest_mactex","rtest2"]);' > log$i.txt 2>&1 &
done
wait
grep -h -A1 'problems\?:' log*.txt
In ten such runs, 7 of 40 processes failed, for example like this, because another process had already deleted the file:
****************** rtest_mactex.mac: Problem 264 (line 1040) ******************
Input:
(delete-file(tmpfile_c), delete-file(tmpfile_d), 0)
Result:
Could not delete the file
"<tempdir>/rtest-mactex-c.tex":
No such file or directory
error-catch
This differed from the expected result:
0
Each process passes when it has a temp directory of its own. Tests outside the suite do the same thing: rtest_translator, rtest_plot, rtest_tex, rtest_operatingsystem and rtest_encoding write files with fixed names into maxima_tempdir or the current directory. rtest_encoding takes a random number for its names, but random starts from the same state in every process.
Plots have the same problem. Without gnuplot_out_file, plot2d(sin(x), [x,0,1], [gnuplot_term, png]) writes maxplot.png into maxima_tempdir, and Maxima deletes it when it exits, so the first process to exit deletes the plot of the other. The other temporary files of plots get random names, but the random state is made anew for each name, and GCL seeds it from the clock in whole seconds. So under GCL, all plots made within the same second get the same file names:
(%i1) display2d:false
(%i2) plot2d(sin(x),[x,0,1],[gnuplot_term,png])
(%o2) ["<tempdir>/dih25551z99n753r.gnuplot",
"<tempdir>/maxplot.png"]
(%i3) plot2d(sin(x),[x,0,1],[gnuplot_term,dumb],[run_viewer,false])
(%o3) ["<tempdir>/dih25551z99n753r.gnuplot",
"<tempdir>/dih25551z99n753r.txt"]
(%i4) plot2d(sin(x),[x,0,1],[gnuplot_term,dumb],[run_viewer,false])
(%o4) ["<tempdir>/dih25551z99n753r.gnuplot",
"<tempdir>/dih25551z99n753r.txt"]
(%i5) getpid()
(%o5) 15129
draw_graph with an external layout program uses in.txt and out.txt in maxima_tempdir, and the sound package uses maxout.wav.
rtest_draw avoids the problem by putting ?getpid() into the name of its directory. But under ABCL, ?getpid() returns -1 in every process.
The self-test of the file_search cache in maxima_userdir has a related problem. When it signals an error, which another process testing at the same time can cause, Maxima records the cache as unusable, and file_search stays without its cache for that version of Maxima and Lisp until the file unsuccessful under maxima_userdir/test-directory-cached is deleted.