Skip to content

Commit

Permalink
add truncate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
droundy committed May 28, 2016
1 parent 501a322 commit 1817cc8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/c-truncate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <unistd.h>

int main() {
truncate("tmp/foobar", 100); /* should fail because foobar does not exist */
truncate("tmp/foo", 100);
return 0;
}
9 changes: 9 additions & 0 deletions tests/c-truncate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import tests.helper as th

def passes(out, err):
return all(
[th.reads(err, '/tests/c-truncate.test'),
th.writes(err, '/tmp/foo'),
th.count_writes(err, 1),
th.count_readdir(err, 0),
])
10 changes: 10 additions & 0 deletions tests/truncate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import tests.helper as th

def passes(out, err):
return all(
[th.reads(err, '/tests/truncate.sh'),
th.count_writes(err, 2),
th.reads(err, '/tmp/root_symlink'),
th.writes(err, '/tmp/foo'),
th.writes(err, '/tmp/foobar'),
])
8 changes: 8 additions & 0 deletions tests/truncate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set -ev

cd tmp/root_symlink/tmp

echo foo > foo
truncate --size 0 foo

truncate --size 0 foobar

0 comments on commit 1817cc8

Please sign in to comment.