From 9fa2a2cba92ebc8b1abf9aca431a7ec9318dbd92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franck=20P=C3=A9rignon?= <franck.perignon@imag.fr>
Date: Fri, 20 May 2016 11:58:30 +0200
Subject: [PATCH]  - Set timeout for tests. - Update doc

---
 CMakeLists.txt                                |  6 +++
 cmake/HySoPTests.cmake                        |  6 ++-
 docs/sphinx/devel/index.rst                   |  6 +--
 docs/sphinx/devel/memo_sphinx.rst             | 47 ++++++++++++++++++-
 docs/sphinx/reference/index.rst               | 14 +++---
 docs/sphinx/users_guide/biblio.rst            |  2 +-
 docs/sphinx/users_guide/develnotes.rst        | 14 ------
 .../tests/test_multiresolution_filter.py      | 45 +++++++++---------
 8 files changed, 91 insertions(+), 49 deletions(-)
 delete mode 100644 docs/sphinx/users_guide/develnotes.rst

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12ab08b63..241dbd58a 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,6 +48,7 @@ option(WITH_MPI_TESTS "Enable mpi tests. Default = ON if USE_MPI is ON." ON)
 option(WITH_GOOGLE_TESTS "Enable google tests (c++). Default = OFF." OFF)
 option(FORTRAN_LAYOUT "Choose default data layout ('fortran', column-major or 'C' order, row-major) for arrays. Default = column-major." ON)
 option(WITH_DOCUMENTATION "Build Documentation. Default = OFF" ON)
+option(ENABLE_LONG_TESTS "Enable tests that may run for long time with important memory print. Default = OFF." OFF)
 
 # Set python install mode:
 # - user --> behave as 'python setup.py install --user'
@@ -461,6 +462,11 @@ add_custom_target(pyclean COMMAND rm -f ${PYCFILES}
 
 # ============= Tests =============
 if(WITH_TESTS)
+  if(NOT ENABLE_LONG_TESTS)
+    set(TEST_TIMEOUT 4 CACHE STRING "Default value for test runtime limit (in seconds)")
+  else()
+    set(TEST_TIMEOUT 500 CACHE STRING "Default value for test runtime limit (in seconds)")
+  endif()
   include(CTest)
   # Number of mpi processes used to run tests.
   include(ProcessorCount)
diff --git a/cmake/HySoPTests.cmake b/cmake/HySoPTests.cmake
index 8138a30b2..bf9948b98 100755
--- a/cmake/HySoPTests.cmake
+++ b/cmake/HySoPTests.cmake
@@ -10,6 +10,7 @@
 # or a call to ctest.
 
 enable_testing()
+
 find_python_module(pytest REQUIRED)
 
 # Declaration of python test
@@ -23,6 +24,8 @@ macro(add_python_test test_name test_file)
   set_tests_properties(${test_name} PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dataForTests)
   set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${HYSOP_BUILD_PYTHONPATH}")
   set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${HYSOP_BUILD_PYTHONPATH},LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${HYSOP_BUILD_PYTHONPATH}")
+  set_tests_properties(${test_name} PROPERTIES TIMEOUT ${TEST_TIMEOUT})
+  
   if(WITH_MPI_TESTS)
     # Run the same test using mpi multi process run.
     # The number of processes used is set with NBPROCS_FOR_TESTS variable (user option for cmake, default=8)
@@ -33,7 +36,8 @@ macro(add_python_test test_name test_file)
     set_tests_properties(${test_name}_mpi PROPERTIES FAIL_REGULAR_EXPRESSION "FAILURE;Exception;[^x]failed;ERROR;Assertion")
     set_tests_properties(${test_name}_mpi PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/dataForTests)
     set_tests_properties(${test_name}_mpi PROPERTIES ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${HYSOP_BUILD_PYTHONPATH},LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${HYSOP_BUILD_PYTHONPATH}")
-  endif()
+    set_tests_properties(${test_name}_mpi PROPERTIES TIMEOUT ${TEST_TIMEOUT})
+ endif()
   
 endmacro()
 
diff --git a/docs/sphinx/devel/index.rst b/docs/sphinx/devel/index.rst
index 53bfc494e..660c46633 100644
--- a/docs/sphinx/devel/index.rst
+++ b/docs/sphinx/devel/index.rst
@@ -12,8 +12,6 @@ This part is for developers of Hysop and provides guidelines on the "proper" way
 
    about_doc
    coding_guidelines
-   writing_tests
-   develnotes
+   about_work_arrays
    memo_sphinx
-
-
+   hysop_validation
diff --git a/docs/sphinx/devel/memo_sphinx.rst b/docs/sphinx/devel/memo_sphinx.rst
index ca787892b..0e0edf97f 100644
--- a/docs/sphinx/devel/memo_sphinx.rst
+++ b/docs/sphinx/devel/memo_sphinx.rst
@@ -3,6 +3,51 @@
 Reminder for sphinx utilities
 =============================
 
+Source code for this page::
+
+  To print source Code::
+
+    for i in xrange(3):
+        do un_truc()
+
+
+  Hyperlinks `HySoP Web`_.
+
+
+  .. math::
+
+     \begin{eqnarray}
+     a &=& \frac{1}{2}\\
+     \alpha &=& 3 \times \nabla \omega
+     \end{eqnarray}
+
+  To print a link to some HySoP object:
+
+  .. currentmodule:: hysop.operator.discrete
+
+  An example of a discrete operator, :class:`stretching.Conservative`, used to represent the
+  stretching part of NS.
+
+  Reference to :ref:`forces`.
+
+  
+  Links
+  -----
+
+  * rst :
+    http://sphinx-doc.org/rest.html
+   
+  * math support
+    http://sphinx-doc.org/ext/math.html
+
+  * numpydoc :
+    https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
+ 
+  .. _Hysop Web: https://forge.imag.fr
+
+
+Which results in:
+  
 To print source Code::
 
   for i in xrange(3):
@@ -29,7 +74,7 @@ Reference to :ref:`forces`.
 
 		 
 Links
-=====
+-----
 
  * rst :
    http://sphinx-doc.org/rest.html
diff --git a/docs/sphinx/reference/index.rst b/docs/sphinx/reference/index.rst
index 6817069a8..6a3a027d2 100644
--- a/docs/sphinx/reference/index.rst
+++ b/docs/sphinx/reference/index.rst
@@ -1,12 +1,12 @@
-.. HySoP reference (auto generated) documentation
+.. _hysop_reference:
 
-Welcome to HySoP's documentation!
-==================================
-
-Contents:
+HySoP reference (auto generated) documentation
+==============================================
 
 .. toctree::
-   :maxdepth: 2
+   :maxdepth: 3
+
+   Python API <../apidoc/modules>
+   fortran_api
 
-   modules
  
diff --git a/docs/sphinx/users_guide/biblio.rst b/docs/sphinx/users_guide/biblio.rst
index b6df74814..c83f5fde2 100644
--- a/docs/sphinx/users_guide/biblio.rst
+++ b/docs/sphinx/users_guide/biblio.rst
@@ -3,6 +3,6 @@
 Bibliography
 ============
       
-.. bibliography:: hysop.bib
+.. bibliography:: ../hysop.bib
    :cited:
    :style: plain
diff --git a/docs/sphinx/users_guide/develnotes.rst b/docs/sphinx/users_guide/develnotes.rst
deleted file mode 100644
index b9a666066..000000000
--- a/docs/sphinx/users_guide/develnotes.rst
+++ /dev/null
@@ -1,14 +0,0 @@
-.. _develnotes:
-
-Notes for developpers
-=====================
-
-Draft. Notes, remarks ... anything which may help developpers
-to write and understand HySoP software.
-
-Contents:
-
-.. toctree::
-   :maxdepth: 2
-
-   forces
diff --git a/hysop/operator/tests/test_multiresolution_filter.py b/hysop/operator/tests/test_multiresolution_filter.py
index 91febfd77..44e3e5e7e 100755
--- a/hysop/operator/tests/test_multiresolution_filter.py
+++ b/hysop/operator/tests/test_multiresolution_filter.py
@@ -14,6 +14,9 @@ L = [1., 1., 1.]
 O = [0., 0., 0.]
 simu = Simulation(tinit=0., tend=0.1, nbIter=1)
 
+# Warning : values too large for tests
+n_middle = 513
+n_large = 1025
 
 def func_periodic_X(res, x, y, z, t=0):
     res[0][...] = np.sin(2. * np.pi * x)
@@ -61,34 +64,34 @@ def filter(d_fine, d_coarse, func, method, atol=1e-8, rtol=1e-5):
 
 
 def test_linear_X():
-    b, e, err = filter(d_coarse=Discretization([513, 5, 5],
+    b, e, err = filter(d_coarse=Discretization([n_middle, 5, 5],
                                                ghosts=[1, 1, 1]),
-                       d_fine=Discretization([1025, 5, 5]),
+                       d_fine=Discretization([n_large, 5, 5]),
                        method={Remesh: Rmsh_Linear, },
                        func=func_periodic_X)
     assert b, "max(|error|)=" + str(e) + " <= " + str(err)
 
 
 def test_linear_Y():
-    b, e, err = filter(d_coarse=Discretization([5, 513, 5],
+    b, e, err = filter(d_coarse=Discretization([5, n_middle, 5],
                                                ghosts=[1, 1, 1]),
-                       d_fine=Discretization([5, 1025, 5]),
+                       d_fine=Discretization([5, n_large, 5]),
                        method={Remesh: Rmsh_Linear, },
                        func=func_periodic_Y)
     assert b, "max(|error|)=" + str(e) + " <= " + str(err)
 
 
 def test_linear_Z():
-    b, e, err = filter(d_coarse=Discretization([5, 5, 513],
+    b, e, err = filter(d_coarse=Discretization([5, 5, n_middle],
                                                ghosts=[1, 1, 1]),
-                       d_fine=Discretization([5, 5, 1025]),
+                       d_fine=Discretization([5, 5, n_large]),
                        method={Remesh: Rmsh_Linear, },
                        func=func_periodic_Z)
     assert b, "max(|error|)=" + str(e) + " <= " + str(err)
 
 
 def test_linear_XY():
-    b, e, err = filter(d_coarse=Discretization([1025, 1025, 5],
+    b, e, err = filter(d_coarse=Discretization([n_large, n_large, 5],
                                                ghosts=[1, 1, 1]),
                        d_fine=Discretization([2049, 2049, 5]),
                        func=func_periodic_XY,
@@ -111,34 +114,34 @@ def order_linear():
 
 
 def test_L21_X():
-    b, e, err = filter(d_coarse=Discretization([513, 5, 5],
+    b, e, err = filter(d_coarse=Discretization([n_middle, 5, 5],
                                                ghosts=[2, 2, 2]),
-                       d_fine=Discretization([1025, 5, 5]),
-                       method={Remesh: L2_1, },
+                       d_fine=Discretization([n_large, 5, 5]),
+                       method={Remesh: L21, },
                        func=func_periodic_X)
     assert b, "max(|error|)=" + str(e) + " <= " + str(err)
 
 
 def test_L21_Y():
-    b, e, err = filter(d_coarse=Discretization([5, 513, 5],
+    b, e, err = filter(d_coarse=Discretization([5, n_middle, 5],
                                                ghosts=[2, 2, 2]),
-                       d_fine=Discretization([5, 1025, 5]),
-                       method={Remesh: L2_1, },
+                       d_fine=Discretization([5, n_large, 5]),
+                       method={Remesh: L21, },
                        func=func_periodic_X)
     assert b, "max(|error|)=" + str(e) + " <= " + str(err)
 
 
 def test_L21_Z():
-    b, e, err = filter(d_coarse=Discretization([5, 5, 513],
+    b, e, err = filter(d_coarse=Discretization([5, 5, n_middle],
                                                ghosts=[2, 2, 2]),
-                       d_fine=Discretization([5, 5, 1025]),
-                       method={Remesh: L2_1, },
+                       d_fine=Discretization([5, 5, n_large]),
+                       method={Remesh: L21, },
                        func=func_periodic_X)
     assert b, "max(|error|)=" + str(e) + " <= " + str(err)
 
 
 def test_L21_XY():
-    b, e, err = filter(d_coarse=Discretization([1025, 1025, 5],
+    b, e, err = filter(d_coarse=Discretization([n_large, n_large, 5],
                                                ghosts=[2, 2, 2]),
                        d_fine=Discretization([2049, 2049, 5]),
                        func=func_periodic_XY,
@@ -169,8 +172,8 @@ def func(res, x, y, z, t=0):
 def test_filter_linear():
     """This test compares the GPU linear filter with python implementation"""
     box = Box(length=L, origin=O)
-    f = Field(box, formula=func, name='f0')
-    d_fine = Discretization([513, 513, 513])
+    f = Field(box, formula=func, name='f1')
+    d_fine = Discretization([n_middle, n_middle, n_middle])
     d_coarse = Discretization([257, 257, 257], ghosts=[1, 1, 1])
     op = MultiresolutionFilter(d_in=d_fine, d_out=d_coarse,
                                variables={f: d_coarse},
@@ -195,8 +198,8 @@ def test_filter_linear():
 def test_filter_l2_1():
     """This test compares the GPU linear filter with python implementation"""
     box = Box(length=L, origin=O)
-    f = Field(box, formula=func, name='f0')
-    d_fine = Discretization([513, 513, 513])
+    f = Field(box, formula=func, name='f1')
+    d_fine = Discretization([n_middle, n_middle, n_middle])
     d_coarse = Discretization([257, 257, 257], ghosts=[2, 2, 2])
     op = MultiresolutionFilter(d_in=d_fine, d_out=d_coarse,
                                variables={f: d_coarse},
-- 
GitLab