aboutsummaryrefslogtreecommitdiff
path: root/src/systemcmds
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-09-03 21:22:03 -0700
committerpx4dev <px4@purgatory.org>2013-09-11 13:42:29 -0700
commit514d32e961e37f68443871dd93f4ce4c89c4aad9 (patch)
tree0b353f14edd19c5cdc7851fd3f801752fb3eb7f5 /src/systemcmds
parented4b34547c1bddeb696b9e3c46bdb15407a845c9 (diff)
downloadpx4-firmware-514d32e961e37f68443871dd93f4ce4c89c4aad9.tar.gz
px4-firmware-514d32e961e37f68443871dd93f4ce4c89c4aad9.tar.bz2
px4-firmware-514d32e961e37f68443871dd93f4ce4c89c4aad9.zip
Cut down 'tests file' for debugging
Diffstat (limited to 'src/systemcmds')
-rw-r--r--src/systemcmds/tests/tests_file.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/systemcmds/tests/tests_file.c b/src/systemcmds/tests/tests_file.c
index 47f480758..588d648bd 100644
--- a/src/systemcmds/tests/tests_file.c
+++ b/src/systemcmds/tests/tests_file.c
@@ -52,6 +52,44 @@
int
test_file(int argc, char *argv[])
{
+ const iterations = 10;
+
+ /* check if microSD card is mounted */
+ struct stat buffer;
+ if (stat("/fs/microsd/", &buffer)) {
+ warnx("no microSD card mounted, aborting file test");
+ return 1;
+ }
+
+ uint8_t buf[512];
+ hrt_abstime start, end;
+ perf_counter_t wperf = perf_alloc(PC_ELAPSED, "SD writes");
+
+ int fd = open("/fs/microsd/testfile", O_TRUNC | O_WRONLY | O_CREAT);
+ memset(buf, 0, sizeof(buf));
+
+ start = hrt_absolute_time();
+ for (unsigned i = 0; i < iterations; i++) {
+ perf_begin(wperf);
+ write(fd, buf, sizeof(buf));
+ perf_end(wperf);
+ }
+ end = hrt_absolute_time();
+
+ close(fd);
+
+ warnx("%dKiB in %llu microseconds", iterations / 2, end - start);
+ perf_print_counter(wperf);
+ perf_free(wperf);
+
+ return 0;
+}
+#if 0
+int
+test_file(int argc, char *argv[])
+{
+ const iterations = 1024;
+
/* check if microSD card is mounted */
struct stat buffer;
if (stat("/fs/microsd/", &buffer)) {
@@ -67,7 +105,7 @@ test_file(int argc, char *argv[])
memset(buf, 0, sizeof(buf));
start = hrt_absolute_time();
- for (unsigned i = 0; i < 1024; i++) {
+ for (unsigned i = 0; i < iterations; i++) {
perf_begin(wperf);
write(fd, buf, sizeof(buf));
perf_end(wperf);
@@ -78,7 +116,7 @@ test_file(int argc, char *argv[])
unlink("/fs/microsd/testfile");
- warnx("512KiB in %llu microseconds", end - start);
+ warnx("%dKiB in %llu microseconds", iterations / 2, end - start);
perf_print_counter(wperf);
perf_free(wperf);
@@ -112,3 +150,4 @@ test_file(int argc, char *argv[])
return 0;
}
+#endif