Skip to content

Commit abeecb3

Browse files
committed
[embedded] Add a dependency test to show that embedded print() is free of allocations/retains/releases
1 parent a565d1a commit abeecb3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -no-allocations %s -c -o %t/a.o
3+
4+
// RUN: grep DEP\: %s | sed 's#// DEP\: ##' | sort > %t/allowed-dependencies.txt
5+
6+
// Linux/ELF doesn't use the "_" prefix in symbol mangling.
7+
// RUN: if [ %target-os == "linux-gnu" ]; then sed -E -i -e 's/^_(.*)$/\1/' %t/allowed-dependencies.txt; fi
8+
9+
// RUN: %llvm-nm --undefined-only --format=just-symbols %t/a.o | sort | tee %t/actual-dependencies.txt
10+
11+
// Fail if there is any entry in actual-dependencies.txt that's not in allowed-dependencies.txt
12+
// RUN: test -z "`comm -13 %t/allowed-dependencies.txt %t/actual-dependencies.txt`"
13+
14+
// DEP: ___stack_chk_fail
15+
// DEP: ___stack_chk_guard
16+
// DEP: ___divti3
17+
// DEP: ___modti3
18+
// DEP: _memset
19+
// DEP: _putchar
20+
21+
// RUN: %target-clang -x c -c %S/Inputs/print.c -o %t/print.o
22+
// RUN: %target-clang %t/a.o %t/print.o -o %t/a.out
23+
// RUN: %target-run %t/a.out | %FileCheck %s
24+
25+
// REQUIRES: swift_in_compiler
26+
// REQUIRES: executable_test
27+
// REQUIRES: optimized_stdlib
28+
// REQUIRES: OS=macosx || OS=linux-gnu
29+
// UNSUPPORTED: OS=linux-gnu && CPU=aarch64
30+
31+
print("Hello Embedded Swift!") // CHECK: Hello Embedded Swift!
32+
print(42) // CHECK: 42
33+
print(false) // CHECK: false

0 commit comments

Comments
 (0)