diff options
author | Joel E. Denny <jdenny.ornl@gmail.com> | 2021-06-25 12:40:04 -0400 |
---|---|---|
committer | Joel E. Denny <jdenny.ornl@gmail.com> | 2021-06-25 13:17:56 -0400 |
commit | 9eaf0d120d3255c43789213c499513ba1be9dde7 (patch) | |
tree | 29bc727c409731d4647a710641f25f47f2ffcdff /clang/test/utils | |
parent | e80a21d632900341258a20134e43ad76a2c93c81 (diff) | |
download | llvm-9eaf0d120d3255c43789213c499513ba1be9dde7.zip llvm-9eaf0d120d3255c43789213c499513ba1be9dde7.tar.gz llvm-9eaf0d120d3255c43789213c499513ba1be9dde7.tar.bz2 |
[UpdateCCTestChecks] Support --check-globals
This option is already supported by update_test_checks.py, but it can
also be useful in update_cc_test_checks.py. For example, I'd like to
use it in OpenMP offload codegen tests to check global variables like
`.offload_maptypes*`.
Reviewed By: jdoerfert, arichardson, ggeorgakoudis
Differential Revision: https://reviews.llvm.org/D104714
Diffstat (limited to 'clang/test/utils')
4 files changed, 108 insertions, 2 deletions
diff --git a/clang/test/utils/update_cc_test_checks/Inputs/check-globals.c b/clang/test/utils/update_cc_test_checks/Inputs/check-globals.c new file mode 100644 index 0000000..a63cec2 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/check-globals.c @@ -0,0 +1,10 @@ +// First, make sure --check-globals doesn't crash on a non-FileChecked command. +// RUN: true +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s + +void foo() { + static int i, j; +} +void bar() { + static int i, j; +} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/lit.cfg.example b/clang/test/utils/update_cc_test_checks/Inputs/lit.cfg.example new file mode 100644 index 0000000..c1afdc4 --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/Inputs/lit.cfg.example @@ -0,0 +1,9 @@ +import lit +lit_config.load_config( + config, os.path.join(lit_config.params.get('clang_obj_root'), + "test/lit.site.cfg.py")) +config.name = 'update_cc_test_checks.py example' +config.suffixes = ['.c', '.cpp'] +config.test_format = lit.formats.ShTest(execute_external=False) +config.test_source_root = os.path.dirname(__file__) +config.test_exec_root = os.path.dirname(__file__) diff --git a/clang/test/utils/update_cc_test_checks/check-globals.test b/clang/test/utils/update_cc_test_checks/check-globals.test new file mode 100644 index 0000000..2af041b --- /dev/null +++ b/clang/test/utils/update_cc_test_checks/check-globals.test @@ -0,0 +1,83 @@ +RUN: rm -rf %t && mkdir %t + +# Check --check-globals in normal mode and in --include-generated-funcs mode. + +RUN: cp %S/Inputs/check-globals.c %t/norm.c +RUN: %update_cc_test_checks %t/norm.c --check-globals +RUN: FileCheck %s --input-file=%t/norm.c --match-full-lines -strict-whitespace \ +RUN: -check-prefixes=BOTH,NRM + +RUN: cp %S/Inputs/check-globals.c %t/igf.c +RUN: %update_cc_test_checks %t/igf.c --check-globals --include-generated-funcs +RUN: FileCheck %s --input-file=%t/igf.c --match-full-lines -strict-whitespace \ +RUN: -check-prefixes=BOTH,IGF + +# Check that repeating doesn't change it, such as duplicating '//.' occurrences. + +RUN: cp %t/norm.c %t/norm-again.c +RUN: %update_cc_test_checks %t/norm-again.c --check-globals +RUN: diff -u %t/norm.c %t/norm-again.c +RUN: rm %t/norm-again.c + +RUN: cp %t/igf.c %t/igf-again.c +RUN: %update_cc_test_checks %t/igf-again.c --check-globals \ +RUN: --include-generated-funcs +RUN: diff -u %t/igf.c %t/igf-again.c +RUN: rm %t/igf-again.c + +# Check that the generated directives actually work correctly. For example, +# they're not in the wrong order. + +RUN: cp %S/Inputs/lit.cfg.example %t/lit.cfg +# Show lit failures while avoiding confusing FileCheck input dump nesting. +RUN: %lit %t +# Lit was successful. Sanity-check the results. +RUN: %lit %t 2>&1 | FileCheck -check-prefix=LIT-RUN %s + +END. + + BOTH-NOT:{{.}} + NRM:// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals + IGF:// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --include-generated-funcs + BOTH-NEXT:// {{.*}} + BOTH-NEXT:// RUN: true + BOTH-NEXT:// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s +BOTH-EMPTY: + IGF-NEXT:void foo() { + IGF-NEXT: static int i, j; + IGF-NEXT:} + IGF-NEXT:void bar() { + IGF-NEXT: static int i, j; + IGF-NEXT:} + BOTH-NEXT://. + BOTH-NEXT:// CHECK: @foo.i = internal global i32 0, align 4 + BOTH-NEXT:// CHECK: @foo.j = internal global i32 0, align 4 + BOTH-NEXT:// CHECK: @bar.i = internal global i32 0, align 4 + BOTH-NEXT:// CHECK: @bar.j = internal global i32 0, align 4 + BOTH-NEXT://. + BOTH-NEXT:// CHECK-LABEL: @foo( + BOTH-NEXT:// CHECK-NEXT: entry: + BOTH-NEXT:// CHECK-NEXT: ret void + BOTH-NEXT:// + NRM-NEXT:void foo() { + NRM-NEXT: static int i, j; + NRM-NEXT:} + IGF-NEXT:// + BOTH-NEXT:// CHECK-LABEL: @bar( + BOTH-NEXT:// CHECK-NEXT: entry: + BOTH-NEXT:// CHECK-NEXT: ret void + BOTH-NEXT:// + NRM-NEXT:void bar() { + NRM-NEXT: static int i, j; + NRM-NEXT:} + BOTH-NEXT://. + BOTH-NEXT:// CHECK: attributes {{.*}} + BOTH-NEXT://. + BOTH-NEXT:// CHECK: !0 = {{.*}} + BOTH-NEXT:// CHECK: !1 = {{.*}} + BOTH-NEXT://. + BOTH-NOT:{{.}} + +LIT-RUN: Testing: 2 tests +LIT-RUN: PASS: {{.*}} igf.c +LIT-RUN: PASS: {{.*}} norm.c diff --git a/clang/test/utils/update_cc_test_checks/lit.local.cfg b/clang/test/utils/update_cc_test_checks/lit.local.cfg index 3fef028..b61309f 100644 --- a/clang/test/utils/update_cc_test_checks/lit.local.cfg +++ b/clang/test/utils/update_cc_test_checks/lit.local.cfg @@ -19,9 +19,13 @@ extra_args += ' --opt ' + shell_quote(opt_path) script_path = os.path.join(config.llvm_src_root, 'utils', 'update_cc_test_checks.py') assert os.path.isfile(script_path) +lit = shell_quote(os.path.join(config.llvm_src_root, 'utils', 'lit', 'lit.py')) +python = shell_quote(config.python_executable) config.substitutions.append( ('%update_cc_test_checks', "%s %s %s" % ( - shell_quote(config.python_executable), shell_quote(script_path), - extra_args))) + python, shell_quote(script_path), extra_args))) config.substitutions.append( ('%clang_tools_dir', shell_quote(config.clang_tools_dir))) +config.substitutions.append( + ('%lit', "%s %s -Dclang_obj_root=%s -j1 -vv" % ( + python, lit, shell_quote(config.clang_obj_root)))) |