1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Building Test Cases</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="The eCos Component Writer's Guide"
20 HREF="cdl-guide.html"><LINK
22 TITLE="The Build Process"
23 HREF="build.html"><LINK
26 HREF="build.make.html"><LINK
28 TITLE="CDL Language Specification"
29 HREF="reference.html"></HEAD
40 SUMMARY="Header navigation table"
52 > Component Writer's Guide</TH
60 HREF="build.make.html"
68 >Chapter 4. The Build Process</TD
88 NAME="BUILD.TESTS">Building Test Cases</H1
108 >The support in the current implementation of the component framework
109 for building and running test cases is limited, and should be enhanced
110 considerably in a future version. Compatibility with the existing
111 mechanisms described below will be maintained if possible, but this
112 cannot be guaranteed.</P
118 >Whenever possible packages should be shipped with one or more test
119 cases. This allows users to check that all packages function correctly
120 in their particular configuration and on their target, which may be
121 custom hardware unavailable to the package developer. The component
122 framework needs to provide a way of building such test cases. For
123 example, if a makefile system is used then there could be a
127 > target to build the test cases, or
131 > target to build and run
132 the test cases and process all the results. Unfortunately there are
133 various complications.</P
135 >Not every test case will be applicable to every configuration. For
136 example if the user has disabled the C library's
139 >CYGPKG_LIBC_STDIO</TT
140 > component then there is no point
141 in building or running any of the test cases for that component. This
142 implies that test cases need to be associated with configuration
143 options somehow. It is possible for the test case to use one or more
147 > statements to check whether or not it is
148 applicable in the current configuration, and compile to a null program
149 when not applicable. This is inefficient because the test case will
150 still get built and possibly run, even though it will not provide any
151 useful information.</P
153 >Many packages involve direct interaction with hardware, for example a
154 serial line or an ethernet interface. In such cases it is only
155 worthwhile building and running the test if there is suitable software
156 running at the other end of the serial line or listening on the same
157 ethernet segment, and that software would typically have to run on the
158 host. Of course the serial line in question may be hooked up to a
159 different piece of hardware which the application needs to talk to, so
160 disconnecting it and then hooking it up to the host for running some
161 tests may be undesirable. The decision as to whether or not to build
162 the test depends not just on the eCos configuration but also on the
163 hardware setup and the availability of suitable host software.</P
165 >There are different kinds of tests, and it is not always desirable to
166 run all of them. For example a package may contain a number of stress
167 tests intended to run for long periods of time, possibly days or
168 longer. Such tests should certainly be distinguished somehow from
169 ordinary test cases so that users will not run them accidentally and
170 wonder how long they should wait for a <TT
174 before giving up. Stress tests may also have dependencies on the
175 hardware configuration and on host software, for example a network
176 stress test may require lots of ethernet packets.</P
178 >In the current implementation of the component framework these issues
179 are not yet addressed. Instead there is only very limited support for
180 building test cases. Any package can define a calculated configuration
184 >CYGPKG_<package-name>_TESTS</TT
186 list of test cases. The <SPAN
189 > property can involve an
190 expression so it is possible to adapt to a small number of
191 configuration options, but this quickly becomes unwieldy. A typical
200 CLASS="PROGRAMLISTING"
201 > cdl_option CYGPKG_UITRON_TESTS {
202 display "uITRON tests"
205 calculated { "tests/test1 tests/test2 tests/test3 \
206 tests/test4 tests/test5 tests/test6 tests/test7 \
207 tests/test8 tests/test9 tests/testcxx tests/testcx2 \
208 tests/testcx3 tests/testcx4 tests/testcx5 \
209 tests/testcx6 tests/testcx7 tests/testcx8 \
210 tests/testcx9 tests/testintr" }
212 This option specifies the set of tests for the uITRON compatibility layer."
218 >This implies that there is a file <TT
225 > in the package's directory.
226 The commands that will be used to build the test case will take the
235 CLASS="PROGRAMLISTING"
236 > $(CC) -c $(INCLUDE_PATH) $(CFLAGS) -o <build path>/test1.o \
237 <source path>/tests/test1.c
238 $(CC) $(LDFLAGS) -o <install path>/tests/test1 <build_path>/test1.o</PRE
246 > and so on are determined in the
247 same way as for custom build steps. The various paths and the current
248 directory will depend on the exact build system being used, and are
249 subject to change. As usual the sources in the component repository
250 are treated as a read-only resources, intermediate files live in the
251 build tree, and the desired executables should end up in the install
254 >Each test source file must be self-contained. It is not possible at
255 present to build a little per-package library that can be used by the
256 test cases, or to link together several object files to produce a
257 single test executable. In some cases it may be possible to
261 > source code from a shared file in order to
262 avoid unnecessary code replication. There is no support for
263 manipulating compiler or linker flags for individual test cases: the
264 flags that will be used for all files are <TT
271 >, as per custom build steps. Note
272 that it is possible for a package to define options of the form
275 >CYGPKG_<PACKAGE-NAME>_LDFLAGS_ADD</TT
279 >CYGPKG_<PACKAGE-NAME>_LDFLAGS_REMOVE</TT
281 will affect test cases, but in the absence of custom build steps they
282 will have no other effect on the build.</P
289 SUMMARY="Footer navigation table"
300 HREF="build.make.html"
309 HREF="cdl-guide.html"
318 HREF="reference.html"
342 >CDL Language Specification</TD