浏览代码

ftruncate test

Paul Sajna 7 年之前
父节点
当前提交
2636b6f5b1
共有 3 个文件被更改,包括 14 次插入0 次删除
  1. 2 0
      tests/.gitignore
  2. 1 0
      tests/Makefile
  3. 11 0
      tests/ftruncate.c

+ 2 - 0
tests/.gitignore

@@ -8,6 +8,8 @@
 /dup.out
 /fchdir
 /fsync
+/ftruncate
+/ftruncate.out
 /math
 /printf
 /write

+ 1 - 0
tests/Makefile

@@ -7,6 +7,7 @@ BINS=\
 	dup \
 	fchdir \
 	fsync \
+	ftruncate \
 	math \
 	printf \
 	write

+ 11 - 0
tests/ftruncate.c

@@ -0,0 +1,11 @@
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+int main (int argc, char** argv) {
+    int fd = creat("ftruncate.out", 0777); 
+    int status;
+    status = ftruncate(fd, 100);
+    printf("ftruncate exited with status code %d\n", status);
+    close(fd);
+}