aboutsummaryrefslogtreecommitdiff
path: root/test/sanitizer_common/TestCases/Posix/fgetln.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/sanitizer_common/TestCases/Posix/fgetln.cc')
-rw-r--r--test/sanitizer_common/TestCases/Posix/fgetln.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/Posix/fgetln.cc b/test/sanitizer_common/TestCases/Posix/fgetln.cc
new file mode 100644
index 000000000000..e98cf449a272
--- /dev/null
+++ b/test/sanitizer_common/TestCases/Posix/fgetln.cc
@@ -0,0 +1,24 @@
+// RUN: %clangxx -O0 -g %s -o %t && %run %t
+// UNSUPPORTED: linux
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void) {
+ FILE *fp;
+ size_t len;
+ char *s;
+
+ fp = fopen("/etc/hosts", "r");
+ if (!fp)
+ exit(1);
+
+ s = fgetln(fp, &len);
+
+ printf("%.*s\n", (int)len, s);
+
+ if (fclose(fp) == EOF)
+ exit(1);
+
+ return 0;
+}