Merge pull request #16 from apple/lldb-test

Add a test to check lldb on swiftpm system module packages
diff --git a/test-lldb-with-c-package/CFoo/Package.swift b/test-lldb-with-c-package/CFoo/Package.swift
new file mode 100644
index 0000000..7ee71ab
--- /dev/null
+++ b/test-lldb-with-c-package/CFoo/Package.swift
@@ -0,0 +1,5 @@
+import PackageDescription
+
+let package = Package(
+   name: "CFoo"
+)
diff --git a/test-lldb-with-c-package/CFoo/foo.c b/test-lldb-with-c-package/CFoo/foo.c
new file mode 100644
index 0000000..7fc331a
--- /dev/null
+++ b/test-lldb-with-c-package/CFoo/foo.c
@@ -0,0 +1,5 @@
+#include "foo.h"
+
+int foo() {
+    return 5;
+}
diff --git a/test-lldb-with-c-package/CFoo/foo.h b/test-lldb-with-c-package/CFoo/foo.h
new file mode 100644
index 0000000..5d5f8f0
--- /dev/null
+++ b/test-lldb-with-c-package/CFoo/foo.h
@@ -0,0 +1 @@
+int foo();
diff --git a/test-lldb-with-c-package/CFoo/module.modulemap b/test-lldb-with-c-package/CFoo/module.modulemap
new file mode 100644
index 0000000..da99acd
--- /dev/null
+++ b/test-lldb-with-c-package/CFoo/module.modulemap
@@ -0,0 +1,5 @@
+module CFoo {
+    header "foo.h"
+    link "foo"
+    export *
+}
diff --git a/test-lldb-with-c-package/Foo/Package.swift b/test-lldb-with-c-package/Foo/Package.swift
new file mode 100644
index 0000000..766cbb3
--- /dev/null
+++ b/test-lldb-with-c-package/Foo/Package.swift
@@ -0,0 +1,8 @@
+import PackageDescription
+
+let package = Package(
+   name: "Foo",
+    dependencies: [
+        .Package(url: "../CFoo", majorVersion: 1),
+    ]
+)
diff --git a/test-lldb-with-c-package/Foo/main.swift b/test-lldb-with-c-package/Foo/main.swift
new file mode 100644
index 0000000..9feeee7
--- /dev/null
+++ b/test-lldb-with-c-package/Foo/main.swift
@@ -0,0 +1,3 @@
+import CFoo
+print(foo())
+print("OK")
diff --git a/test-lldb-with-c-package/test-xctest-package.txt b/test-lldb-with-c-package/test-xctest-package.txt
new file mode 100644
index 0000000..63283bf
--- /dev/null
+++ b/test-lldb-with-c-package/test-xctest-package.txt
@@ -0,0 +1,38 @@
+// Check that we can debug a system module package.
+//
+// Make a sandbox dir.
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir
+// RUN: cp -r %S/CFoo %t.dir/
+// RUN: cp -r %S/Foo %t.dir/
+//
+// Create and drop the library inside build folder.
+// RUN: mkdir -p %t.dir/Foo/.build/debug
+// RUN: clang -shared %t.dir/CFoo/foo.c -o %t.dir/Foo/.build/debug/libfoo.so
+//
+// Create the git repo for the lib package
+// RUN: git -C %t.dir/CFoo init
+// RUN: git -C %t.dir/CFoo add .
+// RUN: git -C %t.dir/CFoo config user.name "Test User"
+// RUN: git -C %t.dir/CFoo config user.email "test@user.com"
+// RUN: git -C %t.dir/CFoo commit -m "Creating package"
+// RUN: git -C %t.dir/CFoo tag 1.0.0
+//
+// Check the build log.
+// RUN: %{swift} build --chdir %t.dir/Foo 2>&1 | tee %t.build-log
+// RUN: %{FileCheck} --check-prefix CHECK-BUILD-LOG --input-file %t.build-log %s
+// CHECK-BUILD-LOG: Compile Swift Module 'Foo'
+
+// Verify that the build worked.
+// RUN: test -x %t.dir/Foo/.build/debug/Foo
+// RUN: %t.dir/Foo/.build/debug/Foo > %t.out
+// RUN: %{FileCheck} --check-prefix CHECK-APP-OUTPUT --input-file %t.out %s
+// CHECK-APP-OUTPUT: 5
+// CHECK-APP-OUTPUT-NEXT: OK
+
+// Check we can debug the executable.
+// RUN: %{lldb} %t.dir/Foo/.build/debug/Foo -o "b main.swift:2" -o r -o "po foo()" -b &> %t.lldb
+// RUN: %{FileCheck} --check-prefix CHECK-LLDB-LOG --input-file %t.lldb %s
+// CHECK-LLDB-LOG: (lldb) po foo()
+// Unfortunately this doesn't work yet. See: SR-3280 and SR-3863.
+// CHECK-LLDB-LOG-NEXT: error: in auto-import: