• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1---
2layout: default
3title: Integration Tests
4parent: Release & Milestone Tasks
5grand_parent: Contributors
6nav_order: 60
7---
8
9<!--
10© 2021 and later: Unicode, Inc. and others.
11License & terms of use: http://www.unicode.org/copyright.html
12-->
13
14# Integration Tests
15{: .no_toc }
16
17## Contents
18{: .no_toc .text-delta }
19
201. TOC
21{:toc}
22
23---
24
25## Run ICU4J Locale Service Provider tests
26
27JDK 6 introduced the locale service provider interface. ICU4J release include a
28special jar file (icu4j-localespi.jar) implementing the locale service provider
29interface.
30
31The test case for the ICU4J locale service provider requires JRE 6 or later
32version. Otherwise, there is no extra settings except for the standard ant set
33up ( necessary. To run the test cases, use ant with the top-level build.xml with
34target "localespiCheck"
35
36```sh
37$ ant localespiCheck
38```
39
40You should get the output like below -
41
42```
43...
44build:
45
46_runLocalespiCheck:
47     [java] TestAll {
48     [java]   BreakIteratorTest {
49     [java]     TestGetInstance (7.581s) Passed
50     [java]     TestICUEquivalent (0.832s) Passed
51     [java]   } (8.669s) Passed
52     [java]   CollatorTest {
53     [java]     TestGetInstance (0.900s) Passed
54     [java]     TestICUEquivalent (0.040s) Passed
55     [java]   } (0.966s) Passed
56     [java]   CurrencyNameTest {
57     [java]     TestCurrencySymbols (2.682s) Passed
58     [java]   } (2.683s) Passed
59     [java]     DateFormatSymbolsTest {
60     [java]     TestGetInstance (0.348s) Passed
61     [java]     TestICUEquivalent (0.207s) Passed
62     [java]     TestNynorsk (0.000s) Passed
63     [java]     TestSetSymbols (0.071s) Passed
64     [java]   } (0.631s) Passed
65     [java]   DateFormatTest {
66     [java]     TestGetInstance (0.456s) Passed
67     [java]     TestICUEquivalent (0.113s) Passed
68     [java]     TestThaiDigit (0.000s) Passed
69     [java]   } (0.571s) Passed
70     [java]   DecimalFormatSymbolsTest {
71     [java]     TestGetInstance (0.098s) Passed
72     [java]     TestICUEquivalent (0.000s) Passed
73     [java]     TestSetSymbols (0.000s) Passed
74     [java]   } (0.099s) Passed
75     [java]   LocaleNameTest {
76     [java]     TestCountryNames (2.500s) Passed
77     [java]     TestLanguageNames (14.262s) Passed
78     [java]   TestVariantNames (8.638s) Passed
79     [java]   } (25.402s) Passed
80     [java]   NumberFormatTest {
81     [java]     TestGetInstance (0.266s) Passed
82     [java]     TestICUEquivalent (0.209s) Passed
83     [java]   } (0.475s) Passed
84     [java]   TimeZoneNameTest {
85     [java]     TestTimeZoneNames (17.766s) Passed
86     [java]   } (17.766s) Passed
87     [java] } (57.268s) Passed
88     [java]
89     [java] Test cases taking excessive time (>10s):
90     [java] TestAll/LocaleNameTest/TestLanguageNames (14.262s)
91     [java] TestAll/TimeZoneNameTest/TestTimeZoneNames (17.766s)
92     [java]
93
94BUILD SUCCESSFUL
95Total time: 1 minute 46 seconds
96```
97
98---
99
100## Run ICU4J Test cases with JDK TimeZone
101
102ICU4J provides an option to alter TimeZone implementation to use the JRE's own
103implementation. The test cases used for this is the regular ICU4J unit test
104suite, except forcing ICU4J to use JRE TimeZone by special system property -
105com.ibm.icu.util.TimeZone.DefaultTimeZoneType=JDK.
106
107To run the test, you have to apply the latest time zone patch from a JRE vendor,
108because some test cases are sensitive to actual time zone transitions. For
109Oracle JRE, you should go to the J2SE download page
110<http://www.oracle.com/technetwork/java/javase/downloads/index.html> and
111download the latest JDK DST Timezone Update Tool and apply the patch to your
112local JRE.
113
114To run the test case, you just need to invoke the ant target "jdktzCheck".
115
116```sh
117$ ant jdktzCheck
118```
119
120**Note:** You might not be able to get the update tool matching the tzdata
121version used by ICU. In this case, some test cases may reports failures.
122Unfortunately, you have to walk though the failures to see if they are expected
123or not manually in this case.
124
125---
126
127## Verify the Eclipse ICU4J plug-in
128
1291.  Make sure the Eclipse ICU4J plug-in binaries are successfully produced.
1302.  Run the ICU4J plug-in test cases.
1313.  Update license files, build version strings for the new release.
132
133---
134
135## Run Tests Without ICU Data
136
137### ICU4C
138
139ICU data should be removed, so that tests cannot access it. Both cintltst and
140intltest should be run with -w option and they should not crash. Every crash
141should be investigated and fixed.
142
143To do this, build and test normally, then replace the ICU data shared library
144with the stubdata library and run the tests again with the -w option.
145
146Using an in-source build on Linux:
147
148```sh
149cd icu4c/source
150./runConfigureICU Linux
151make -j2 check
152rm lib/libicudata.so*
153cp -P stubdata/libicudata.so* lib/
154cd test/intltest
155INTLTEST_OPTS=-w make check
156cd ../cintltst
157CINTLTST_OPTS=-w make check
158```
159
160For debugging (for example using gdb) you cannot use `make check`. You need
161to set the `LD_LIBRARY_PATH` for the lib folder and then run
162`./cintltst -w` or `./intltest -w` etc. in the debugger.
163Example (in-source build on Linux):
164```sh
165cd test/cintltst
166export LD_LIBRARY_PATH=../../lib:../../tools/ctestfw
167./cintltst -w
168```
169
170### ICU4J
171
172ICU4J has the test target for this, but does not work as designed for now. For
173now, this task is not required for ICU4J.
174
175---
176
177## Verify that ICU4C tests pass without collation rule strings
178
179***ICU4C 53 and later***
180
181Background: [ICU-10636](https://unicode-org.atlassian.net/browse/ICU-10636)
182
183### Rebuild ICU data without collation rule strings
184
185#### ICU 64+
186
187You need to configure ICU with a data filter config file that removes collation
188rule strings.
189
190The file syntax is nicer with hjson rather than json.
191
192```sh
193sudo apt install python3-pip
194pip3 install hjson
195```
196
197Use an `~/icu/coll-norules.hjson` config file like this:
198
199```
200{
201  resourceFilters: [
202    {
203      categories: [
204        coll_tree
205      ]
206      rules: [
207        -/UCARules
208        -/collations/*/Sequence
209      ]
210    }
211  ]
212}
213```
214
215Configure ICU using this file:
216
217```sh
218ICU_DATA_FILTER_FILE=~/icu/coll-norules.hjson ... runConfigureICU ...
219```
220
221Run "make clean" (or delete just the collation .res files), then test as below.
222
223#### ICU 54..63
224
225This should work: `make GENRBOPTS='-k --omitCollationRules'` (-k is --strict)
226
227For ICU 54..63, I went into the build output folder and did:
228
229```sh
230cd data
231ICUDT=icudt63l
232rm out/build/$ICUDT/coll/*.res
233make GENRBOPTS='-k --omitCollationRules'
234```
235
236If this does not work, then add this option to the configure'd data/Makefile,
237see ticket [ICU-10636](https://unicode-org.atlassian.net/browse/ICU-10636).
238
239### Run the tests with data-errors-as-warnings
240
241`INTLTEST_OPTS=-w CINTLTST_OPTS=-w make -j5 check`
242
243See that they pass, or fix them to pass. See ticket #10636 test code changes for
244examples.
245
246---
247
248## Test ICU4J with only little-endian ICU4C data
249
250*Only available since ICU 54.*
251
252#### With ICU 64 and later:
253
254*   Reconfigure ICU4C with
255    <code><b>ICU_DATA_BUILDTOOL_OPTS=--include_uni_core_data</b>
256    ./runConfigureICU Linux</code> or similar
257    *   Should be little-endian for coverage
258*   Clean and build ICU4C: `make -j6 check`
259*   Make a clean directory for testing
260    *   Find the .data file in the build output area, e.g.,
261        `icu4c/source/data/out/tmp/icudt64l.dat`
262    *   Create a temporary directory such as `mkdir -p /tmp/icu4j_data_test`
263    *   Copy the .`dat` file to the new directory.
264*   Build and test ICU4J without its own data: `ant clean && ant
265    -Dicu4c.data.path=/tmp/icu4j_data_test check`
266    *   The configuration option sets the `ICUConfig.properties` data path
267    *   Verify that all tests pass.
268    *   If you get very many test failures, double-check that you enabled
269        unicore data in the ICU4C build (see first step).
270
271#### With ICU 55 through ICU 63:
272
273*   Rebuild ICU4C with <code>make <b>INCLUDE_UNI_CORE_DATA=1</b> check</code> or
274    similar, and provide a path only for the .dat file.
275    *   Should be little-endian for coverage
276    *   Find the .data file in the build output area, e.g.,
277        `data/out/tmp/icudt59l.dat`
278    *   Create a temporary directory such as `mkdir -p
279        /tmp/icu/build/data/out/tmp`
280    *   Copy the .`dat` file to the new directory.
281*   Build and test ICU4J without its own data: `ant clean && ant
282    -Dicu4c.data.path=/tmp/icu/build/data/out/tmp check`
283    *   The configuration option sets the `ICUConfig.properties` data path
284    *   Verify that all tests pass.
285
286#### ICU 54 method:
287
288In `icu4j-core/src/com/ibm/icu/ICUConfig.properties` set
289`com.ibm.icu.impl.ICUBinary.dataPath` to a list of paths with all of the ICU4C
290data (should be little-endian for coverage), with a path to where the .dat file
291is and a path to the source/data/in files for data that is hardcoded in ICU4C
292and therefore not in the .dat file (e.g., uprops.icu).
293
294Change `com.ibm.icu.impl.ICUData.logBinaryDataFromInputStream` to `true`, maybe
295set a breakpoint where such a message is logged.
296
297Run all of the ICU4J tests, maybe in the debugger for the breakpoint, or look
298for logger output to the console.
299
300Revert your config changes.
301
302## Build and run testmap
303
304Build and run the source/test/testmap project. (There is currently no Windows
305project defined for it.)
306
307```sh
308$ cd <root of your ICU build tree>
309$ CONFIG_FILES=test/testmap/Makefile CONFIG_HEADERS= ./config.status
310$ cd test/testmap
311$ make check
312```
313
314---
315
316## Verify XLIFF conversion
317
318<span style="background-color:orange">**Note:** The following instruction does not work. Please read the comments with
319orange background. There are some issues in the current ICU XLIFF tools and the
320test case below. See the comments in
321[ticket ICU-6383](https://unicode-org.atlassian.net/browse/ICU-6383).</span>
322
323Instructions for verifying the XLIFF conversion tools.
324
325*   Convert icu/source/test/testdata/ra.txt to XLIFF
326
327    `genrb -s icu/source/test/testdata -d icu/source/test/testdata/ -x -l en ra.txt`
328
329    <span style="background-color:orange">-d icu/source/test/testdata/ overwrite
330    the existing ra.xlf. Specify another directory.</span>
331
332    <span style="background-color:orange">ra.txt has the top level item "ra",
333    which is supposed to be the content language. Thus, with -l en, you'll get a
334    warning - "The top level tag in the resource and language specified are not
335    the same. Please check the input." We should use "-l ra" here.</span>
336
337*   Verify that the ra.xlf produced is identical to the one in CVS HEAD (except
338    for generation date)
339
340    <span style="background-color:orange">If you use "-l ra" above, you'll get
341    <file .... source-language = "ra" .... />, which is different from ra.xlf in
342    the repository. Also, new line codes is broken for imported contents.</span>
343
344*   Convert icu/source/test/testdata/ra.xlf back to ICU format
345
346    `java -cp icu4j/classes com.ibm.icu.dev.tool.localeconverter.XLIFF2ICUConverter -d . -t ra ra.xlf`
347
348    <span style="background-color:orange">The option "-t ra" does not work,
349    because ra.xlf does not contain target language data. Use "-c ra"
350    instead.</span>
351
352*   Verify that the ra.txt produced is identical to the one in CVS HEAD (except
353    for generation date)
354
355    <span style="background-color:orange">You cannot expect the generated ra.txt
356    exactly matches the original one because of table item re-ordering, new line
357    code changes, and explicit resource types (e.g. "ra {" vs. "ra:table
358    {").</span>
359*   Go through the steps given in
360    <http://icu.sourceforge.net/docs/papers/localize_with_XLIFF_and_ICU.pdf>
361
362---
363
364## Test sample and demo programs
365
366Build and run all of the sample and demo apps that are included with ICU, on
367each of the reference platforms. A list of them is in the
368[readme](http://icu.sanjose.ibm.com/internal/checklist/icu-progs-list.html).
369Also see the build system.
370
371Another worthy test: Test suites and demos *from the previous release* should
372also compile and run with the libraries of the current release, at least when
373certain #defines are set (unless they test APIs that are deprecated and have
374been removed since)!
375
376---
377
378## Test data portability
379
380Test if the data portability (under common endianness & charset family) is ok.
381On the ICU build server, you would use the "Build from source .dat archive"
382option. When it's not available, you would do the following:
383
3841.  Build ICU4C on Win32.
3852.  Copy the icu/source/data/out/icudt<data_version>l.dat file into
386    icu/source/data/in
3873.  Delete non-essential directories from icu/source/data.
3884.  Package up a clean copy of ICU for a non-Windows machine, like Linux on x86.
3895.  Build ICU on the non-Windows machine from the newly created package.
3906.  Run all tests on that non-Windows machine.
391
392---
393
394## Run the environment tests
395
396Run
397[environmentTest.sh](https://github.com/unicode-org/icu/blob/main/tools/release/c/environmentTest.sh)
398on a Linux machine which has many (all possible?) POSIX locales installed. This
399test verifies that the ICU test suite will work regardless of a user's default
400locale and timezone. This test should be run on a fast machine with several CPU
401cores. This will take a long time to run. Here are the steps to run the test.
402
4031.  cd icu4c/source/
4042.  ./runConfigureICU Linux
4053.  make check
4064.  cd ../../tools/release/c/
4075.  ./environmentTest.sh
4086.  Wait a while for the tests to finish. The logs will be written in each test
409    directory. e.g. icu4c/source/test/intltest/intltest-\*.txt. A message will
410    be printed from each spawned test script when it finishes.
4117.  grep the logs for any test failures when the tests are done.
412
413---
414
415## Run Thread Sanitizer tests
416
417Thread sanitizer testing is one of the standard Travis builds. If it is passing
418there, nothing further is required.
419
420To run manually, on a Linux system with clang,
421
422```sh
423cd icu4c/source
424CPPFLAGS=-fsanitize=thread LDFLAGS=-fsanitize=thread ./runConfigureICU --enable-debug --disable-release Linux
425make clean
426make -j6 check
427```
428
429Errors are displayed at the point they occur, and stop further testing.
430
431---
432
433## Run Address Sanitizer tests
434
435Address sanitizer testing is included in the standard Linux with Clang Travis
436builds. If it is passing there, nothing further is required.
437
438To run manually, on a Linux system with clang,
439
440```sh
441cd icu4c/source
442CPPFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address ./runConfigureICU --enable-debug --disable-release Linux
443make clean
444make -j6 check
445```
446
447Memory leaks are summarized at the end. Other errors are displayed at the point
448they occur, and stop further testing.
449
450---
451
452## ICU4J Serialization Compatibility Test Data
453
454The regular ICU4J unit test includes serialization compatibility tests. The test
455case creates an ICU service object from serialized data created by a former
456version of ICU. When we prepare a new release, the serialization compatibility
457test data should be created and checked in for future testing. This task is
458usually done just before publishing release candidate.
459
4601.  Run regular ICU4J unit tests - `ant check`
4612.  Make sure the unit tests pass successfully.
4623.  Run - `ant serialTestData`
4634.  Copy a folder with ICU version (e.g. ICU_61.1) generated under <icu4j
464    root>/out/serialTestData to <icu4j
465    root>/main/tests/core/src/com/ibm/icu/dev/test/serializable/data.
4665.  You may delete older serialization test data from the directory (but keep
467    the oldest one - ICU_3.6).
4686.  Run `ant check` again before committing the changes.
469