diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-09-01 10:29:12 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-09-01 10:29:12 +0200 |
commit | c3408332fd0e6d77661a26fade8662a8b9be9970 (patch) | |
tree | 0e1c7acc049f0e4e8ce96d2be68dec38e08507a8 /src/systemcmds/tests | |
parent | 4b018e74a9c22ae4b0a87466392d79409108c1b3 (diff) | |
download | px4-firmware-c3408332fd0e6d77661a26fade8662a8b9be9970.tar.gz px4-firmware-c3408332fd0e6d77661a26fade8662a8b9be9970.tar.bz2 px4-firmware-c3408332fd0e6d77661a26fade8662a8b9be9970.zip |
Added test to test unlink()
Diffstat (limited to 'src/systemcmds/tests')
-rw-r--r-- | src/systemcmds/tests/tests_file.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/systemcmds/tests/tests_file.c b/src/systemcmds/tests/tests_file.c index 6f75b9812..47f480758 100644 --- a/src/systemcmds/tests/tests_file.c +++ b/src/systemcmds/tests/tests_file.c @@ -76,9 +76,39 @@ test_file(int argc, char *argv[]) close(fd); + unlink("/fs/microsd/testfile"); + warnx("512KiB in %llu microseconds", end - start); perf_print_counter(wperf); perf_free(wperf); + warnx("running unlink test"); + + /* ensure that common commands do not run against file count limits */ + for (unsigned i = 0; i < 64; i++) { + + warnx("unlink iteration #%u", i); + + int fd = open("/fs/microsd/testfile", O_TRUNC | O_WRONLY | O_CREAT); + if (fd < 0) + errx(1, "failed opening test file before unlink()"); + int ret = write(fd, buf, sizeof(buf)); + if (ret < 0) + errx(1, "failed writing test file before unlink()"); + close(fd); + + ret = unlink("/fs/microsd/testfile"); + if (ret != OK) + errx(1, "failed unlinking test file"); + + fd = open("/fs/microsd/testfile", O_TRUNC | O_WRONLY | O_CREAT); + if (fd < 0) + errx(1, "failed opening test file after unlink()"); + ret = write(fd, buf, sizeof(buf)); + if (ret < 0) + errx(1, "failed writing test file after unlink()"); + close(fd); + } + return 0; } |