Unitary and non regression testing of Scilab
Contents
before starting
Under Linux
If you receive the error Gtk-WARNING **: Locale not supported by C library. when you start scilab in a terminal. do (as root or via sudo) :
$ cd /usr/lib/locale $ ln -s en_GB.utf8 en_GB
(Replace en_GB with your locale)
On Ubuntu 11.04, you need to define LC_ALL
export LC_ALL="fr_FR.UTF-8"
Replace fr_FR with your locale. For example, if your locale is en_US, then use:
export LC_ALL="en_US.UTF-8"
This trick also works with Ubuntu 12.01.
On Ubuntu 11.10, you need to modify the file /usr/share/i18n/SUPPORTED and check that the locale is defined as UTF-8, for example:
fr_FR UTF-8 ja_JP UTF-8
and then execute:
sudo locale-gen fr_FR sudo locale-gen ja_JP
Testing the Scilab distribution
All tests
Launch Scilab and type :
test_run()
It will run all the tests and provide this kind of output :
01/153 - [cacsd] arma..........................................passed 02/153 - [cacsd] odedi.........................................passed 03/153 - [cacsd] slicot........................................passed 04/153 - [completion] completion...............................passed 05/153 - [core] auto...........................................failed : dia and ref are not equal [...]
At the end of all the testing, it will display the results.
Test only one module
test_run('time')
Test only one function
test_run('time','datenum')
Testing the source version of Scilab
Linux/Unix
To launch all the tests, in the root directory of the source tree, type :
cd $SCI make check
To launch the test of one module, go in the root directory of the module and type :
make check
For example, the following commands will run all the tests for the core module.
cd $SCI cd modules/core/ make check
Creating new test files (draft)
Very incomplete guide to create new tests. Compare these indications with existing tests.
unitary test files are stored per module in SCI/modules/MODULE/tests/unit_tests (where MODULE is the target module name).
to create a new test, add a .tst file holding scilab commands
- this file should generate no output
it should signal errors by the construct if test_fails then pause; end, where test_fails must be set appropriately
- generate the reference output of your test (though the test file must not generate any output, the execution of the test will issue the command lines):
test_run('module','function','create_ref');
- your new test is ready
Troubleshooting
It may happen that, when we export the LC_ALL environment variable, we get the following message:
$ export LC_ALL="fr_FR.UTF-8" bash: warning: setlocale: LC_ALL: cannot change locale (fr_FR.UTF-8): No such file or directory [2]+ Done ~/Downloads/scilab-5.4.0/bin/scilab
This is because the locale is not fr_FR. In this case, we may know which locale is currently used with the "locale" command:
$ locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
We can see that the LC_ALL variable is empty. Now, if we do:
$ export LC_ALL="en_US.UTF-8"
then the LC_ALL variable gets defined, and Scilab now works fine. More details on this topic are available at [1].
References
[1] https://help.ubuntu.com/community/Locale, Locale