Lua Test suites

For a reasonable test of your Lua installation, download the test suite for your release of Lua and follow the instructions below to run basic, complete, and internal tests.

The tests for Lua 5.2.2 work for all later releases of Lua 5.2.

filename date size checksums
lua-5.3.3-tests.tar.gz 2016-05-30 102562 md5: 76f4fb07f2a4970d554645ac26df86df
sha1: 2d95b703222677dfaf56b84c199ccb2161bb1bb7
lua-5.3.2-tests.tar.gz 2015-11-25 101342 md5: a2b7ab1b8ff82a0145376e233ef30a4a
sha1: 87ecda2bd47366d5e79b41fe676aa31e44ff6ce1
lua-5.3.1-tests.tar.gz 2015-06-10 99638 md5: f4e0d83cb658980126464ad92b299b43
sha1: 922acc4d1cdcea2275eeeff9c2ef5555d19a4ae9
lua-5.3.0-tests.tar.gz 2015-01-05 96995 md5: fc0192f21894475da586fe63e3c17d50
sha1: 8fd633ab67edf5e824c2afc62f318de245fce268
lua-5.2.2-tests.tar.gz 2013-03-07 76629 md5: a3dabd30e5a364c87191b0c1e6f64178
sha1: 89abce5ab3080783dec9785c8fe5da6d4896de05
lua-5.2.1-tests.tar.gz 2012-07-02 76093 md5: c30210b7d1c500611bae852f32442fbc
sha1: 034c32751985c74a7422cb40b8aeef0033786932
lua-5.2.0-tests.tar.gz 2011-12-12 75065 md5: a0b3f66d820352b4502a27cf8488ab73
sha1: 9940d9c75fa44b7698e34a63fc314e885e49f55b
lua5.1-tests.tar.gz 2016-01-18 55127 md5: b376d315ada7bd9d379ec820d6cc27ed
sha1: aeddc9f901555c08a5209f077e5413c2ae4b8947

Basic tests

Open the test suite somewhere. You'll see a directory named lua-x.y.z-tests containing several .lua files and a few subdirectories.

To run some basic tests, go to this directory and run the following command:

    path/lua -e"_U=true" all.lua
Make sure you run the exact release of Lua that you wish to test. If you're in doubt, run lua -v and check the output. If the release numbers do not match, you'll have to provide an explicit path.

The tests will print lots of different messages, but no assertion should ever fail. If the test goes all its way to the end, printing a "final OK" message, then all went well.

Note that, by its very nature, Lua is heavily dependent on the underlying standard C libraries. Sometimes the test suite fails because these underlying C libraries do not follow the ANSI standard. There is not much we can do about it.

Complete tests

The test suite uses some variables to control the execution of some tests. By defining the global variable _U (e.g., with the option -e"_U=true" in the command line as done for the basic tests above), the suite skip tests that are not fully portable and that consume too much memory. This option also suppresses messages for tests not performed. The basic tests should work without problems in any system with Lua compiled without changes.

The complete test suite (that is, without the _U option) tries to test every corner of the language, its libraries, and the C API, even corners that are system dependent. Unlike Lua itself, these tests do not aim at portability, small footprint, or easy of use. Their main goal is to try to crash Lua. They are not intended for general use. You are welcome to use them, but expect to get your hands dirty.

To run the complete suite, first make sure that your test directory has subdirectories libs/ and libs/P1/, then go to subdirectory libs/ and build the C libraries there using the makefile provided (or its equivalent in your system). Now you may try to run the full test suite, by running the following command at the top-level test directory:

    path/lua all.lua
Again, make sure you run the correct release of Lua.

Do not worry if it does not work the first time you try. (That is why there is the _U option after all.) You may need to adjust small details for your system. Among others, here is a list of things that may go wrong:

Internal tests

For even harder tests, the test suite uses a special library, testC, that gives access to several internal structures in Lua. This library is only available when Lua is compiled in debug mode, as described below.

If you want to run these internal tests, copy ltests.c and ltests.h from the ltests directory to the directory with the source Lua files, and recompile Lua with the option -DLUA_USER_H='"ltests.h"' (or its equivalent to define LUA_USER_H as the string "ltests.h", including the quotes). This option adds the testC library and enables several other internal tests as well. After the recompilation, run the tests as before. Again, expect to get your hands dirty.

Good luck!