Kaitai Struct: tests in all supported programming languages
Python Java C++ Ruby PHP C# Other
Clone or download
Permalink
Failed to load latest commit information.
aggregate Add new Boost Test results XML parser Jun 1, 2018
doc Use ARGV for display_coverage generation Apr 8, 2018
formats Added formats/params_enum.ksy Aug 12, 2018
formats_err Added test for check for unknown parameter type in params declaration Feb 22, 2018
helpers/javascript Added hexString JS helper Mar 13, 2018
spec Switched enum-related PHP tests to KST Aug 12, 2018
src Added process_coerce_switch tests + data Jul 1, 2017
translator PHPSG: fixed to properly generated namespace-aware enum renditions Aug 12, 2018
.gitattributes Add .gitattributes file Aug 25, 2016
.gitignore Ignore locally installed node_modules Nov 3, 2016
README.md Big renaming: all log-generating scripts would be ci-* from now on, a… Apr 17, 2017
aggregate-reports Extracted aggregate-reports into distinct script for easier manual run Apr 14, 2018
build-compiler Build JS compiler too, add JS compiler publish script Aug 8, 2017
build-formats Added new artificial ks_path for build-formats Sep 26, 2017
ci-all Extracted aggregate-reports into distinct script for easier manual run Apr 14, 2018
ci-construct2 Added ci-construct* + plugged them into ci-all Mar 23, 2018
ci-construct3 Added ci-construct* + plugged them into ci-all Mar 23, 2018
ci-cpp_stl Make valgrind optional Apr 11, 2018
ci-csharp Reworked all CI-launched scripts to be strictly ci-* Apr 17, 2017
ci-go Added option to skip recovery by removal of failed-to-compile files Apr 15, 2018
ci-java Reworked all CI-launched scripts to be strictly ci-* Apr 17, 2017
ci-javascript Fix runtime symlink creation Sep 5, 2017
ci-lua Lua: updated ci-lua for process custom test case Sep 9, 2017
ci-perl Reworked all CI-launched scripts to be strictly ci-* Apr 17, 2017
ci-php Reworked all CI-launched scripts to be strictly ci-* Apr 17, 2017
ci-python Added spec/python/extra to add Python runners Aug 29, 2017
ci-python2 Added spec/python/extra to add Python runners Aug 29, 2017
ci-python3 Added spec/python/extra to add Python runners Aug 29, 2017
ci-ruby {run|ci}-ruby: run specs only in spec/ruby dir Mar 16, 2018
config Perl lib moved Oct 5, 2017
publish-js-compiler Build JS compiler too, add JS compiler publish script Aug 8, 2017
publish-targets Pumped copyright year Mar 4, 2018
run-construct Started Construct test runner, based on run-python => seems to work! Mar 23, 2018
run-cpp_stl Use parallel build, where applicable Apr 10, 2018
run-csharp Added passing of CSHARP_TEST_SRC_PATH into C# test runner Jul 21, 2017
run-go run-go now uses NO_RECOVER by default Apr 15, 2018
run-java run-java: special workarounds for partial compilations where order ma… Oct 5, 2017
run-javascript Fix runtime symlink creation Sep 5, 2017
run-lua Lua: added process custom test case Sep 6, 2017
run-perl Removed unnecessary shell variable Sep 1, 2016
run-php run-php: added generation of JUnit reports Aug 15, 2016
run-python Added spec/python/extra to add Python runners Aug 29, 2017
run-python-xml.py Python: use just unittest, not unittest2 Mar 23, 2016
run-ruby {run|ci}-ruby: run specs only in spec/ruby dir Mar 16, 2018
spec_cpp_to_kst Added semi-auto port-to-KST script Mar 14, 2018
spec_kst_to_all Fixed run permissions Apr 8, 2018
spec_python_to_perl Perl: handle comments in conversion script Jan 7, 2017
spec_ruby_to_cpp_stl Added script to aid porting specs to C++ Apr 25, 2016
spec_ruby_to_csharp Added semi-auto ruby-to-C# spec converter Aug 19, 2016
spec_ruby_to_go Ported 8 more tests to Go Aug 13, 2017
spec_ruby_to_java Rewrote spec_ruby_to_java: actually generates worthwhile Java files now Sep 1, 2016
spec_ruby_to_javascript spec_ruby_to_javascript: added proper lowerCamelCase conversion Aug 18, 2016
spec_ruby_to_lua spec_translate_missing: added Lua support Aug 27, 2017
spec_ruby_to_php spec_ruby_to_php: more fixes to make it really usable Sep 1, 2016
spec_ruby_to_python Fix assertEquals -> assertEqual Nov 22, 2016
spec_translate_missing spec_translate_missing: added Lua support Aug 27, 2017
translator-tests translator-tests: added Travis folding Dec 23, 2016
travis-fold Experimenting with travis-fold Dec 23, 2016
valgrind-cpp_stl Switched valgrind to XML output Jul 19, 2017

README.md

Kaitai Struct: specs and tests

This repository contains specifications and tests for Kaitai Struct project.

What's inside

The repository is laid out like that:

  • src/ - binary input files that would be parsed during the tests
  • formats/ - file formats description is Kaitai Struct YAML format for the files in src/
  • spec/ - specifications (i.e. test code) that uses format descriptions to parse binary input files and ensures that they're parsed properly.
    • $LANGUAGE/ - one subdirectory per every supported target language

During the testing the following is expected to be created:

  • compiled/ - formats (described in formats/), compiled into specific programming languages modules
    • $LANGUAGE/ - one subdirectory per every supported target language
  • test_out/ - test running output, in a language-specific format
    • $LANGUAGE/ - one subdirectory per every supported target language

How to test

The overall procedure of testing works as follows:

  • Make sure that KS compiler (ksc) is built and ready to be used
  • Compile format descriptions in formats/ into source files in relevant programming languages (Java, Python, Ruby, etc), which should be placed in compiled/$LANGUAGE.
  • Compile and run test code for particular language (located in spec/$LANGUAGE), which will use files in src/ for input.
  • Aggregate and view results

Automated test tools

There are a few scripts that automate steps specified above:

  • build-compiler builds compiler using special "stage" mode, i.e. without system-wide deployment, ready to be run from a build directory
  • build-formats compiles all format descriptions in formats/ with this compiler for every supported language, placing results in compiled/$LANGUAGE
  • run-$LANGUAGE executes all tests for a particular $LANGUAGE using preferred language-specific testing tool. The output is generally dumped on screen for quick assessment during development.
  • ci-$LANGUAGE also runs all tests for a particular $LANGUAGE, but logs all output into designated log file instead (mostly useful for aggregation within a CI system afterwards).
  • ci-all
    • runs tests for all languages (usually by executing ci-$LANGUAGE)
    • aggregates all testing results into single nice HTML page by running aggregate/aggregate result aggregation & formatting script

Obviously, these scripts require Kaitai Struct compiler and language-specific runtime modules. They are normally located in distinct repositories - there is a file named /config that specifies their default locations. If you've used main Kaitai Struct project to check out all linked repositories as submodules in their default locations, you don't need to adjust anything. If you have these dependencies in some other places, just edit the /config.

Continuous integration

Main Kaitai Struct project includes a Travis CI configuration. This mean that every commit to main project repository gets automatically built and tested throughly. The results are published at Kaitai Struct CI results page.