about summary refs log tree commit diff homepage
path: root/test
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-05-18 21:48:31 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2011-05-18 21:48:31 +0000
commit4ea784dd4deaed11dffec28e7dab0f1eb3c4afc0 (patch)
treeafb50158ecf6d1ecb347d7e5b1e9043c30ba51ee /test
parent8fcc75009e69dbf0acaef87b011891a6a86dfa12 (diff)
downloadklee-4ea784dd4deaed11dffec28e7dab0f1eb3c4afc0.tar.gz
Support for arbitrary sized types in ConstantExpr::fromMemory
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@131583 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Feature/LargeReturnTypes.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Feature/LargeReturnTypes.cpp b/test/Feature/LargeReturnTypes.cpp
new file mode 100644
index 00000000..caa345fc
--- /dev/null
+++ b/test/Feature/LargeReturnTypes.cpp
@@ -0,0 +1,27 @@
+// RUN: %llvmgxx -g -fno-exceptions -emit-llvm -O0 -c -o %t.bc %s
+// RUN: %klee --libc=klee --no-output --exit-on-error %t.bc > %t.log
+
+/* Tests the ability to call external functions which return large values
+ * (i.e. structs).  In this test case, fstream::ftellg() returns a
+ * streampos (an {i64, i64} pair) which is implicitly converted to a size_t. */
+
+#include <fstream>
+
+using namespace std;
+
+size_t fileSize(const char *filename) {
+  fstream f(filename, fstream::in | fstream::binary);
+
+  if (f.is_open()) {
+    f.seekg(0, fstream::end);
+    size_t fileSize = f.tellg();
+    return fileSize;
+  }
+
+  return (size_t) -1;
+}
+
+int main(void) {
+  size_t size = fileSize("/bin/sh");
+  return (size != (size_t) -1) ? 0 : 1;
+}