TESTSUITE_README 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. How to merge the testsuite into your codebase
  2. =============================================
  3. - Copy the entire "test" directory into the root directory of the framework.
  4. The framework already contains a test directory with files test1.cvc and
  5. test2.cvc, you can remove these.
  6. - Add the following lines to your Makefile:
  7. ###############################################################################
  8. #
  9. # Testing
  10. #
  11. check: all
  12. @cd test; \
  13. CIVAS=../$(TEST_CIVAS) \
  14. CIVVM=../$(TEST_CIVVM) \
  15. CIVCC=../$(TEST_CIVCC) \
  16. RUN_FUNCTIONAL=$(TEST_RUN_FUNCTIONAL) \
  17. bash run.bash $(TEST_DIRS)
  18. - Add the following lines to your Makefile.Targets (this is configuration, so
  19. edit them accordingly):
  20. ###############################################################################
  21. #
  22. # Testing
  23. #
  24. # Uncomment the necessary parts when adding extensions.
  25. # Subdirectories of "test/" to traverse into during testing. Enable
  26. # "nested_funs" and "arrays" when you start implementing those extensions.
  27. # "preprocess" is optional, for those who implemented the C preprocessor.
  28. TEST_DIRS := basic # nested_funs arrays preprocess
  29. # Flags to pass to your compiler when running tests (e.g., a verbosity level).
  30. TEST_CFLAGS := ""
  31. # Whether to run tests that compare program output. Set to 1 after you have
  32. # implemented your assembly phase.
  33. TEST_RUN_FUNCTIONAL := 0
  34. # Path to toolchain files, relative to the root directory (used for functional
  35. # test).
  36. TEST_CIVAS := bin32/civas
  37. TEST_CIVVM := bin32/civvm
  38. # Path to your compiler binary, relative to the root directory.
  39. TEST_CIVCC := bin/civicc
  40. Types of tests
  41. ==============
  42. The "test" directory has a number of subdirectories that group the tests into
  43. different types:
  44. - The "basic" directory contains tests that test the minimal requirements as
  45. explained in the milestones and reference manual, without any extensions.
  46. - The "nested_funs" and "arrays" directories contain tests that test the
  47. functyionalities added by the corresponding extensions.
  48. - The "preprocess" directory is completely optional, for those students who
  49. chose to implement parsing of C preprocessor directives and have a compiler
  50. pass that calls the C preprocessor (the "cpp" command).
  51. The second nesting level of the test directory has four different formats:
  52. - check_success: Small tests that only check if your compiler exits with a 0
  53. status code.
  54. - check_error: Small tests that only check if your compiler exits with a
  55. non-zero status code.
  56. - functional: These are the important tests. Your compiler is used to compile a
  57. program, which is then assembled and executed with the CiviC VM. The output
  58. is compared to the expected output, which is in the corresponding .out file.
  59. - combined_*: This is a special type of functional test, which requires
  60. multiple source files to be run at the same time, where one of the source
  61. files contains a main function. This is used for testing external variables,
  62. which requires a file that exports a variable and a file that imports that
  63. variable.
  64. How to use the testsuite
  65. ========================
  66. Run all tests by executing "make check" in a terminal. Failed tests will show
  67. the output that your compiler generated while running the test.
  68. The test suite is designed to be part of your workflow, for example:
  69. 1. Implement a compiler feature (e.g., a set of grammar rules in your parser).
  70. 2. Run "make check".
  71. 3. For the tests that fail, see if the printed output of your compiler helps
  72. you to debug the program.
  73. 4. If the output of "make check" is insufficient, have a look at the source
  74. files of the failed tests, add some print statements to your code, and try
  75. to get your compiler to work with only those source files.
  76. 5. When you have debugged a test case, run "make check" again to verify that
  77. the test now succeeds and that you have not broken any other tests.
  78. On a more global level, you have to enable more tests in your Makefile.Targets
  79. file as you advance in the course. First of all, you should uncomment the
  80. "arrays" and "nested_funs" targets of TEST_DIRS when you start working on these
  81. extensions. Second, you should set TEST_FUNCTIONAL to 1 when you have
  82. implemented the first version of your code generation phase, to enable tests
  83. that compare program output.
  84. FAQ
  85. ===
  86. Q: "If a lot of tests fail, will I fail the assignment?"
  87. A: Obviously, the more tests succeed, the higher your grade is likely to be.
  88. Some tests, however, are more important than others (e.g., functional tests
  89. are important). Some features may also (unintendedly) have more test cases
  90. than others. For example, when your parser does not support function
  91. definitions yet, most tests will fail since almost all are wrapped in a
  92. "void foo" function. We will try to look closely to exactly which tests fail
  93. when evaluating your compilers, and not only to the number of failing tests.
  94. Q: "If all test succeed, will I get a 10?"
  95. A: You will probably get close, but we also review code quality. If your C coding
  96. style is horrible, we will subtract points, even if all of the tests
  97. succeed.
  98. Q: "I have my own testsuite, should I switch to yours instead?"
  99. A: Using the testsuite is not mandatory. If you have a fancy automated
  100. testsuite ow your own that covers all input cases, then you can surely use
  101. that. Do keep in mind that we will use our own test suite to evaluate your
  102. compilers, so it is recommended to at run the testsuite at least once to see
  103. if you missed anything.
  104. Q: "Does the testsuite output look awesome with fancy terminal colors?"
  105. A: Yes :-)