Skip to content

Commit 453033c

Browse files
[CAS] Add llvm-cas test
1 parent 1252de9 commit 453033c

File tree

10 files changed

+124
-0
lines changed

10 files changed

+124
-0
lines changed

llvm/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ llvm_canonicalize_cmake_booleans(
2323
LLVM_ENABLE_EXPENSIVE_CHECKS
2424
LLVM_ENABLE_REVERSE_ITERATION
2525
LLVM_INCLUDE_DXIL_TESTS
26+
LLVM_ENABLE_ONDISK_CAS
2627
LLVM_TOOL_LLVM_DRIVER_BUILD
2728
LLVM_INCLUDE_SPIRV_SIMULATOR_TESTS
2829
LLVM_INCLUDE_SPIRV_TOOLS_TESTS
@@ -73,6 +74,7 @@ set(LLVM_TEST_DEPENDS
7374
llvm-bcanalyzer
7475
llvm-bitcode-strip
7576
llvm-c-test
77+
llvm-cas
7678
llvm-cat
7779
llvm-cfi-verify
7880
llvm-cgdata

llvm/test/lit.cfg.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,17 @@ def have_ld64_plugin_support():
615615
if config.expensive_checks:
616616
config.available_features.add("expensive_checks")
617617

618+
if config.have_ondisk_cas:
619+
config.available_features.add("ondisk_cas")
620+
618621
if "MemoryWithOrigins" in config.llvm_use_sanitizer:
619622
config.available_features.add("use_msan_with_origins")
620623

624+
# Restrict the size of the on-disk CAS for tests. This allows testing in
625+
# constrained environments (e.g. small TMPDIR). It also prevents leaving
626+
# behind large files on file systems that do not support sparse files if a test
627+
# crashes before resizing the file.
628+
config.environment["LLVM_CAS_MAX_MAPPING_SIZE"] = "%d" % (100 * 1024 * 1024)
621629

622630
# Some tools support an environment variable "OBJECT_MODE" on AIX OS, which
623631
# controls the kind of objects they will support. If there is no "OBJECT_MODE"

llvm/test/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ config.llvm_raevict_model_autogenerated = @LLVM_RAEVICT_MODEL_AUTOGENERATED@
5959
config.expensive_checks = @LLVM_ENABLE_EXPENSIVE_CHECKS@
6060
config.reverse_iteration = @LLVM_ENABLE_REVERSE_ITERATION@
6161
config.dxil_tests = @LLVM_INCLUDE_DXIL_TESTS@
62+
config.have_ondisk_cas = @LLVM_ENABLE_ONDISK_CAS@
6263
config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
6364
config.spirv_tools_tests = @LLVM_INCLUDE_SPIRV_TOOLS_TESTS@
6465
config.have_vc_rev = @LLVM_APPEND_VC_REV@
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
content
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
content

llvm/test/tools/llvm-cas/cache.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
RUN: rm -rf %t %t.cas
2+
RUN: mkdir %t
3+
4+
RUN: llvm-cas --cas %t.cas --make-blob \
5+
RUN: --data /dev/null > %t/empty.casid
6+
RUN: echo "abc" | \
7+
RUN: llvm-cas --cas %t.cas --make-blob \
8+
RUN: --data - >%t/abc.casid
9+
10+
RUN: llvm-cas --cas %t/cas --put-cache-key @%t/abc.casid @%t/empty.casid
11+
RUN: llvm-cas --cas %t/cas --get-cache-result @%t/abc.casid > %t/empty2.casid
12+
RUN: diff %t/empty.casid %t/empty2.casid
13+
14+
RUN: not llvm-cas --cas %t/cas --get-cache-result @%t/empty.casid
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if not config.have_ondisk_cas:
2+
config.unsupported = True
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
RUN: rm -rf %t %t.cas
2+
RUN: mkdir %t
3+
4+
RUN: llvm-cas --cas %t.cas --make-blob \
5+
RUN: --data - </dev/null >%t/empty.casid
6+
RUN: sed -e 's,^.,CHECK: ,' <%t/empty.casid >%t/empty.check
7+
RUN: llvm-cas --cas %t.cas --make-blob \
8+
RUN: --data /dev/null | FileCheck %t/empty.check
9+
RUN: echo "abc" | \
10+
RUN: llvm-cas --cas %t.cas --make-blob \
11+
RUN: --data - >%t/abc.casid
12+
RUN: llvm-cas --cas %t.cas --make-blob \
13+
RUN: --data %S/Inputs/oneline >%t/oneline.casid
14+
RUN: llvm-cas --cas %t.cas --make-blob \
15+
RUN: --data %S/Inputs/oneline-nonewline >%t/oneline-nonewline.casid
16+
17+
RUN: llvm-cas --cas %t.cas --cat-blob @%t/empty.casid |\
18+
RUN: FileCheck %s -check-prefix CHECK-EMPTY -allow-empty
19+
RUN: llvm-cas --cas %t.cas --print-kind @%t/empty.casid |\
20+
RUN: FileCheck %s -check-prefix CHECK-KIND
21+
CHECK-EMPTY-NOT: {{.}}
22+
CHECK-KIND: object
23+
24+
RUN: llvm-cas --cas %t.cas --cat-blob @%t/abc.casid |\
25+
RUN: FileCheck %s -check-prefix CHECK-ABC
26+
RUN: llvm-cas --cas %t.cas --print-kind @%t/abc.casid |\
27+
RUN: FileCheck %s -check-prefix CHECK-KIND
28+
CHECK-ABC: abc
29+
30+
RUN: llvm-cas --cas %t.cas --cat-blob @%t/oneline-nonewline.casid |\
31+
RUN: FileCheck %s -check-prefix CHECK-ONELINE
32+
RUN: llvm-cas --cas %t.cas --cat-blob @%t/oneline.casid |\
33+
RUN: FileCheck %s -check-prefix CHECK-ONELINE
34+
CHECK-ONELINE: content
35+
36+
# Double-check newlines.
37+
RUN: llvm-cas --cas %t.cas --cat-blob @%t/oneline-nonewline.casid \
38+
RUN: >%t/oneline-nonewline
39+
RUN: diff %S/Inputs/oneline-nonewline %t/oneline-nonewline
40+
RUN: llvm-cas --cas %t.cas --cat-blob @%t/oneline.casid \
41+
RUN: >%t/oneline
42+
RUN: diff %S/Inputs/oneline %t/oneline
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
RUN: rm -rf %t
2+
RUN: mkdir %t
3+
4+
# Make some empty objects.
5+
RUN: llvm-cas --cas %t/cas --make-node \
6+
RUN: --data - </dev/null >%t/empty.casid
7+
8+
RUN: llvm-cas --cas %t/cas --cat-node-data @%t/empty.casid |\
9+
RUN: FileCheck %s -check-prefix CHECK-EMPTY -allow-empty
10+
RUN: llvm-cas --cas %t/cas --ls-node-refs @%t/empty.casid |\
11+
RUN: FileCheck %s -check-prefix CHECK-EMPTY -allow-empty
12+
CHECK-EMPTY-NOT: {{.}}
13+
14+
RUN: llvm-cas --cas %t/cas --print-kind @%t/empty.casid |\
15+
RUN: FileCheck %s -check-prefix CHECK-NO-KIND
16+
### FIXME: Node ObjectKind with no reference is Blob kind in BuiltinCAS.
17+
CHECK-NO-KIND: object
18+
19+
# Make a complex object, which references existing ones. Reference a blob and
20+
# other objects, and reference one of them twice to be sure they don't get
21+
# deduped.
22+
RUN: llvm-cas --cas %t/cas --make-blob --data /dev/null \
23+
RUN: >%t/empty-blob.casid
24+
RUN: cat %t/empty.casid %t/empty.casid %t/empty-blob.casid \
25+
RUN: >%t/complex.refs
26+
RUN: cat %t/complex.refs | sed -e 's,^.,CHECK: ,' > %t/complex.check
27+
RUN: llvm-cas --cas %t/cas --make-node \
28+
RUN: --data %S/Inputs/oneline @%t/complex.refs \
29+
RUN: >%t/complex.casid
30+
RUN: llvm-cas --cas %t/cas --print-kind \
31+
RUN: @%t/complex.casid | FileCheck %s -check-prefix COMPLEX-KIND
32+
RUN: llvm-cas --cas %t/cas --cat-node-data \
33+
RUN: @%t/complex.casid | FileCheck %s -check-prefix COMPLEX-DATA
34+
RUN: llvm-cas --cas %t/cas --ls-node-refs @%t/complex.casid |\
35+
RUN: FileCheck %t/complex.check
36+
COMPLEX-KIND: object
37+
COMPLEX-DATA: content
38+
39+
RUN: not llvm-cas --cas %t/cas --ls-tree @%t/complex.casid 2>&1 | FileCheck %s --check-prefix=CHECK-WRONG-TYPE
40+
CHECK-WRONG-TYPE: llvm-cas: ls-tree: not a tree object
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
RUN: rm -rf %t
2+
RUN: mkdir %t
3+
4+
RUN: llvm-cas --cas %t/cas --make-blob --data %s > %t/id
5+
6+
# Confirm that the ID has the right prefix, is well-formed, and that there's
7+
# nothing else on the line.
8+
RUN: FileCheck %s --match-full-lines --strict-whitespace <%t/id
9+
CHECK:llvmcas://{{[a-z0-9]+}}
10+
11+
# Confirm that there's a newline after.
12+
RUN: wc -l <%t/id | FileCheck %s -check-prefix=NEWLINE
13+
NEWLINE: 1

0 commit comments

Comments
 (0)