comparison docs/TestingGuide.rst @ 121:803732b1fca8

LLVM 5.0
author kono
date Fri, 27 Oct 2017 17:07:41 +0900
parents 1172e4bd9c6f
children c2174574ed3a
comparison
equal deleted inserted replaced
120:1172e4bd9c6f 121:803732b1fca8
311 311
312 define i32 @main() nounwind { 312 define i32 @main() nounwind {
313 ret i32 0 313 ret i32 0
314 } 314 }
315 315
316 ``ModuleID`` can unexpetedly match against ``CHECK`` lines. For example: 316 ``ModuleID`` can unexpectedly match against ``CHECK`` lines. For example:
317 317
318 .. code-block:: llvm 318 .. code-block:: llvm
319 319
320 ; RUN: opt -S %s | FileCheck 320 ; RUN: opt -S %s | FileCheck
321 321
385 So, if you're testing for a behaviour that you know is platform-specific or 385 So, if you're testing for a behaviour that you know is platform-specific or
386 depends on special features of sub-architectures, you must add the specific 386 depends on special features of sub-architectures, you must add the specific
387 triple, test with the specific FileCheck and put it into the specific 387 triple, test with the specific FileCheck and put it into the specific
388 directory that will filter out all other architectures. 388 directory that will filter out all other architectures.
389 389
390 REQUIRES and REQUIRES-ANY directive 390
391 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 391 Constraining test execution
392 392 ---------------------------
393 Some tests can be enabled only in specific situation - like having 393
394 debug build. Use ``REQUIRES`` directive to specify those requirements. 394 Some tests can be run only in specific configurations, such as
395 with debug builds or on particular platforms. Use ``REQUIRES``
396 and ``UNSUPPORTED`` to control when the test is enabled.
397
398 Some tests are expected to fail. For example, there may be a known bug
399 that the test detect. Use ``XFAIL`` to mark a test as an expected failure.
400 An ``XFAIL`` test will be successful if its execution fails, and
401 will be a failure if its execution succeeds.
395 402
396 .. code-block:: llvm 403 .. code-block:: llvm
397 404
398 ; This test will be only enabled in the build with asserts 405 ; This test will be only enabled in the build with asserts.
399 ; REQUIRES: asserts 406 ; REQUIRES: asserts
400 407 ; This test is disabled on Linux.
401 You can separate requirements by a comma. 408 ; UNSUPPORTED: -linux-
402 ``REQUIRES`` means all listed requirements must be satisfied. 409 ; This test is expected to fail on PowerPC.
403 ``REQUIRES-ANY`` means at least one must be satisfied. 410 ; XFAIL: powerpc
404 411
405 List of features that can be used in ``REQUIRES`` and ``REQUIRES-ANY`` can be 412 ``REQUIRES`` and ``UNSUPPORTED`` and ``XFAIL`` all accept a comma-separated
406 found in lit.cfg files. 413 list of boolean expressions. The values in each expression may be:
414
415 - Features added to ``config.available_features`` by
416 configuration files such as ``lit.cfg``.
417 - Substrings of the target triple (``UNSUPPORTED`` and ``XFAIL`` only).
418
419 | ``REQUIRES`` enables the test if all expressions are true.
420 | ``UNSUPPORTED`` disables the test if any expression is true.
421 | ``XFAIL`` expects the test to fail if any expression is true.
422
423 As a special case, ``XFAIL: *`` is expected to fail everywhere.
424
425 .. code-block:: llvm
426
427 ; This test is disabled on Windows,
428 ; and is disabled on Linux, except for Android Linux.
429 ; UNSUPPORTED: windows, linux && !android
430 ; This test is expected to fail on both PowerPC and ARM.
431 ; XFAIL: powerpc || arm
432
407 433
408 Substitutions 434 Substitutions
409 ------------- 435 -------------
410 436
411 Besides replacing LLVM tool names the following substitutions are performed in 437 Besides replacing LLVM tool names the following substitutions are performed in
439 Example: ``/home/user/llvm.build/test/MC/ELF/Output`` 465 Example: ``/home/user/llvm.build/test/MC/ELF/Output``
440 466
441 ``%{pathsep}`` 467 ``%{pathsep}``
442 468
443 Expands to the path separator, i.e. ``:`` (or ``;`` on Windows). 469 Expands to the path separator, i.e. ``:`` (or ``;`` on Windows).
470
471 ``%/s, %/S, %/t, %/T:``
472
473 Act like the corresponding substitution above but replace any ``\``
474 character with a ``/``. This is useful to normalize path separators.
475
476 Example: ``%s: C:\Desktop Files/foo_test.s.tmp``
477
478 Example: ``%/s: C:/Desktop Files/foo_test.s.tmp``
479
480 ``%:s, %:S, %:t, %:T:``
481
482 Act like the corresponding substitution above but remove colons at
483 the beginning of Windows paths. This is useful to allow concatenation
484 of absolute paths on Windows to produce a legal path.
485
486 Example: ``%s: C:\Desktop Files\foo_test.s.tmp``
487
488 Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
444 489
445 490
446 **LLVM-specific substitutions:** 491 **LLVM-specific substitutions:**
447 492
448 ``%shlibext`` 493 ``%shlibext``
517 their name. For example: 562 their name. For example:
518 563
519 ``not`` 564 ``not``
520 This program runs its arguments and then inverts the result code from it. 565 This program runs its arguments and then inverts the result code from it.
521 Zero result codes become 1. Non-zero result codes become 0. 566 Zero result codes become 1. Non-zero result codes become 0.
522
523 Sometimes it is necessary to mark a test case as "expected fail" or
524 XFAIL. You can easily mark a test as XFAIL just by including ``XFAIL:``
525 on a line near the top of the file. This signals that the test case
526 should succeed if the test fails. Such test cases are counted separately
527 by the testing tool. To specify an expected fail, use the XFAIL keyword
528 in the comments of the test program followed by a colon and one or more
529 failure patterns. Each failure pattern can be either ``*`` (to specify
530 fail everywhere), or a part of a target triple (indicating the test
531 should fail on that platform), or the name of a configurable feature
532 (for example, ``loadable_module``). If there is a match, the test is
533 expected to fail. If not, the test is expected to succeed. To XFAIL
534 everywhere just specify ``XFAIL: *``. Here is an example of an ``XFAIL``
535 line:
536
537 .. code-block:: llvm
538
539 ; XFAIL: darwin,sun
540 567
541 To make the output more useful, :program:`lit` will scan 568 To make the output more useful, :program:`lit` will scan
542 the lines of the test case for ones that contain a pattern that matches 569 the lines of the test case for ones that contain a pattern that matches
543 ``PR[0-9]+``. This is the syntax for specifying a PR (Problem Report) number 570 ``PR[0-9]+``. This is the syntax for specifying a PR (Problem Report) number
544 that is related to the test case. The number after "PR" specifies the 571 that is related to the test case. The number after "PR" specifies the