⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_suite_spec.txt

📁 很少见的源码公开的msc51和z80的c编译器。
💻 TXT
字号:
Proposed Test Suite DesignMichael Hope (michaelh@juju.net.nz)AbstractThis article describes the goals, requirements, and suggestedspecification for a test suite for the output of the SmallDevice C Compiler (sdcc). Also included is a short listof existing works.  GoalsThe main goals of a test suite for sdcc are  To allow developers to run regression tests to check that  core changes do not break any of the many ports.  To verify the core.  To allow developers to verify individual ports.  To allow developers to test port changes. This design only covers the generated code. It does not covera test/unit test framework for the sdcc application itself,which may be useful.One side effect of (1) is that it requires that the individualports pass the tests originally. This may be too hard. Seethe section on Exceptions below. Requirements CoverageThe suite is intended to cover language features only. Hardwarespecific libraries are explicitly not covered. PermutationsThe ports often generate different code for handling differenttypes (Byte, Word, DWord, and the signed forms). Meta informationcould be used to permute the different test cases acrossthe different types. ExceptionsThe different ports are all at different levels of development.Test cases must be able to be disabled on a per port basis.Permutations also must be able to be disabled on a portlevel for unsupported cases. Disabling, as opposed to enabling,on a per port basis seems more maintainable. RunningThe tests must be able to run unaided. The test suite mustrun on all platforms that sdcc runs on. A good minimum maybe a subset of Unix command set and common tools, providedby default on a Unix host and provided through cygwin ona Windows host.The tests suits should be able to be sub-divided, so thatthe failing or interesting tests may be run separately. ArtifcatsThe test code within the test cases should not generate artifacts.An artifact occurs when the test code itself interfereswith the test and generates an erroneous result. Emulatorssdcc is a cross compiling compiler. As such, an emulatoris needed for each port to run the tests. Existing works DejaGnuDejaGnu is a toolkit written in Expect designed to test aninteractive program. It provides a way of specifying aninterface to the program, and given that interface a wayof stimulating the program and interpreting the results.It was originally written by Cygnus Solutions for runningagainst development boards. I believe the gcc test suiteis written against DejaGnu, perhaps partly to test the Cygnusports of gcc on target systems. gcc test suiteI don't know much about the gcc test suite. It was recentlyremoved from the gcc distribution due to issues with copyrightownership. The code I saw from older distributions seemedmore concerned with esoteric features of the language. xUnitThe xUnit family, in particular JUnit, is a library of intest assertions, test wrappers, and test suite wrappersdesigned mainly for unit testing. PENDING: More. CoreLinux++ Assertion frameworkWhile not a test suite system, the assertion framework isan interesting model for the types of assertions that couldbe used. They include pre-condition, post-condition, invariants,conditional assertions, unconditional assertions, and methodsfor checking conditions. SpecificationThis specification borrows from the JUnit style of unit testingand the CoreLinux++ style of assertions. The emphasis ison maintainability and ease of writing the test cases. TermsPENDING: Align these terms with the rest of the world. An assertion is a statement of how things should be. PENDING:  Better description, an example.  A test point is the smallest unit of a test suite, and  consists of a single assertion that passes if the test  passes.  A test case is a set of test points that test a certain  feature.  A test suite is a set of test cases that test a certain  set of features.  Test casesTest cases shall be contained in their own C file, alongwith the meta data on the test. Test cases shall be containedwithin functions whose names start with 'test' and whichare descriptive of the test case. Any function that startswith 'test' will be automatically run in the test suite.To make the automatic code generation easier, the C codeshall have this format  Test functions shall start with 'test' to allow automatic  detection.  Test functions shall follow the K&R intention style for  ease of detection. i.e. the function name shall start  in the left column on a new line below the return specification.  AssertionsAll assertions shall log the line number, function name,and test case file when they fail. Most assertions can havea more descriptive message attached to them. Assertionswill be implemented through macros to get at the line information.This may cause trouble with artifacts.The following definitions use C++ style default argumentswhere optional messages may be inserted. All assertionsuse double opening and closing brackets in the macros toallow them to be compiled out without any side effects.While this is not required for a test suite, they are therein case any of this code is incorporated into the main product.Borrowing from JUnit, the assertions shall include  FAIL((String msg = "Failed")).  Used when execution should not get here.  ASSERT((Boolean cond, String msg = "Assertion  failed"). Fails if cond is false. Parent to REQUIRE  and ENSURE. JUnit also includes may sub-cases of ASSERT, such as assertNotNull,assertEquals, and assertSame.CoreLinux++ includes the extra assertions  REQUIRE((Boolean cond, String msg = "Precondition  failed"). Checks preconditions.  ENSURE((Boolean cond, String msg = "Postcondition  failed"). Checks post conditions.  CHECK((Boolean cond, String msg = "Check  failed")). Used to call a function and to check  that the return value is as expected. i.e. CHECK((fread(in,  buf, 10) != -1)). Very similar to ASSERT, but the function  still gets called in a release build.  FORALL and EXISTS. Used to check conditions within part  of the code. For example, can be used to check that a  list is still sorted inside each loop of a sort routine. All of FAIL, ASSERT, REQUIRE, ENSURE, and CHECK shall beavailable. Meta dataPENDING: It's not really meta data.Meta data includes permutation information, exception information,and permutation exceptions.Meta data shall be global to the file. Meta data names consistof the lower case alphanumerics. Test case specific metadata (fields) shall be stored in a comment block at thestart of the file. This is only due to style.A field definition shall consist of  The field name  A colon.  A comma separated list of values. The values shall be stripped of leading and trailing whitespace.Permutation exceptions are by port only. Exceptions to afield are specified by a modified field definition. An exceptiondefinition consists of The field name.  An opening square bracket.  A comma separated list of ports the exception applies for.  A closing square bracket.  A colon.  The values to use for this field for these ports. An instance of the test case shall be generated for eachpermutation of the test case specific meta data fields.The runtime meta fields are  port - The port this test is running on.  testcase - The name of this test case.  function - The name of the current function. Most of the runtime fields are not very usable. They arethere for completeness.Meta fields may be accessed inside the test case by enclosingthem in curly brackets. The curly brackets will be interpretedanywhere inside the test case, including inside quoted strings.Field names that are not recognised will be passed throughincluding the brackets. Note that it is therefore impossibleto use some strings within the test case.Test case function names should include the permuted fieldsin the name to reduce name collisions. An exampleI don't know how to do pre-formatted text in LaTeX. Sigh.The following code generates a simple increment test forall combinations of the storage classes and all combinationsof the data sizes. This is a bad example as the optimiserwill often remove most of this code./** Test for increment. type: char, int, longZ80 port does not fully support longs (4 byte)type[z80]: char, intclass: "", register, static */static voidtestInc{class}{types}(void){{class} {type} i = 0; i = i + 1;ASSERT((i == 1));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -